"use strict"; const common_vendor = require("../../common/vendor.js"); const components_request = require("../../components/request.js"); const components_goEasyTool_tool = require("../../components/goEasyTool/tool.js"); const stores_counter = require("../../stores/counter.js"); const counter = stores_counter.useCounterStore(); const _sfc_main = { inject: ["$global"], data() { return { userInfo: {}, info: {}, userSig: "", lastPage: "", myuserSig: "" }; }, onLoad() { common_vendor.index.getUserInfo({ provider: "weixin", success: (res) => { this.userInfo = res.userInfo; } }); common_vendor.index.getStorage({ key: "lastPage", success: (res) => { this.lastPage = "/" + res.data; }, fail: () => { this.lastPage = "/pages/Home/Home"; } }); }, methods: { // 邮箱或者账号登录 loginWithEmailOrAccount() { common_vendor.index.navigateTo({ url: "/pages/loginWithEmailOrAccount/loginWithEmailOrAccount" }); }, // 返回首页 Return() { common_vendor.index.reLaunch({ url: "/pages/Home/Home" }); }, // 获取手机号 getPhoneNumber(e) { if (e.detail.code == void 0) { common_vendor.index.showToast({ title: "登录失败", icon: "none" }); return; } common_vendor.index.showLoading({ title: "登录中...", mask: true }); components_request.request({ url: "user/loginWithPhoneNumber", method: "POST", data: { code: e.detail.code }, userInfo: false }).then((res) => { common_vendor.index.hideLoading(); this.info = res; common_vendor.index.setStorageSync("userinfo", this.info.data.info); const now = Date.now(); common_vendor.index.setStorageSync("last_clean_time", now); counter.$patch({ myitem: this.info.data.info }); if (this.info.code === 200) { if (this.info.data.newAccount) { common_vendor.index.reLaunch({ url: "/pages/UserInformation/UserInformation" }); common_vendor.index.hideLoading(); } else { common_vendor.index.setStorageSync("userinfo", this.info.data.info); common_vendor.index.setStorageSync("token", res.data.info.token); components_goEasyTool_tool.goEasylogin( this.$goeasy, String(this.info.data.info.id), this.info.data.info.headerIcon, this.info.data.info.nickName ); common_vendor.index.hideLoading(); common_vendor.index.reLaunch({ url: this.lastPage }); } } else { common_vendor.index.hideLoading(); common_vendor.index.showToast({ title: "登录失败", icon: "none" }); } }).catch((err) => { common_vendor.index.hideLoading(); common_vendor.index.showToast({ title: "登录失败", icon: "none" }); }); } } }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return { a: common_vendor.o((...args) => $options.Return && $options.Return(...args)), b: $data.userInfo.avatarUrl, c: common_vendor.t($data.userInfo.nickName), d: common_vendor.o((...args) => $options.getPhoneNumber && $options.getPhoneNumber(...args)), e: common_vendor.o((...args) => $options.loginWithEmailOrAccount && $options.loginWithEmailOrAccount(...args)) }; } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/login/login.js.map