"use strict"; const common_vendor = require("../../common/vendor.js"); const request_api = require("../../request/api.js"); const common_assets = require("../../common/assets.js"); const _sfc_main = { data() { return { contentTop: "", isAgree: false, isBindPhone: true //是否绑定过手机号 }; }, onLoad() { this.contentTop = common_vendor.inject("navHeight") + 230 / 750 * common_vendor.inject("windowWidth"); this.getIsBindPhoneData(); }, methods: { /** * 获取手机号 * @param {Object} e */ getPhoneNumData(e) { common_vendor.index.__f__("log", "at pages/login/login.vue:44", e); if (e.detail.errMsg == "getPhoneNumber:ok") { common_vendor.index.login({ provider: "weixin", success(res) { common_vendor.index.__f__("log", "at pages/login/login.vue:49", res.code); let param = { code: res.code, isJson: 1 }; request_api.loginByWx(param).then((res2) => { if (res2.code == 200) { let token = res2.data.token; common_vendor.index.setStorageSync("token", token); let param2 = { code: e.detail.code }; request_api.wxBindPhone(param2).then((res3) => { if (res3.code == 200) { common_vendor.index.showToast({ title: res3.message }); setTimeout(function() { common_vendor.index.switchTab({ url: "/pages/index/index" }); }, 1e3); } else common_vendor.index.showToast({ title: res3.message, icon: "none" }); }).catch((error) => { }); } else common_vendor.index.showToast({ title: res2.message, icon: "none" }); }).catch((error) => { }); }, fail() { } }); } }, /** * 点击一键登录 */ clickOneClickLogin() { if (!this.isAgree) { common_vendor.index.showToast({ title: "请阅读并同意我们的《用户服务协议》和《隐私政策》", icon: "none" }); return; } common_vendor.index.login({ provider: "weixin", success(res) { common_vendor.index.__f__("log", "at pages/login/login.vue:106", res.code); let param = { code: res.code, isJson: 1 }; request_api.loginByWx(param).then((res2) => { if (res2.code == 200) { let token = res2.data.token; common_vendor.index.setStorageSync("token", token); setTimeout(function() { common_vendor.index.switchTab({ url: "/pages/index/index" }); }, 1e3); } else common_vendor.index.showToast({ title: res2.message, icon: "none" }); }).catch((error) => { }); }, fail() { } }); }, /** * 点击验证码登录 */ clickCodeLogin() { common_vendor.index.navigateTo({ url: "/pages/login/codeLogin/codeLogin" }); }, /** * 点击同意 */ clickAgree() { this.isAgree = !this.isAgree; }, /** * 点击查看协议 */ clickProtocol(type) { common_vendor.index.navigateTo({ url: "/pages/mine/web/web?type=" + type }); }, /** * 获取是否绑定过手机号 */ getIsBindPhoneData() { let that = this; common_vendor.index.login({ provider: "weixin", success(res) { common_vendor.index.__f__("log", "at pages/login/login.vue:166", res.code); let param = { code: res.code, isJson: 1 }; request_api.loginByWx(param).then((res2) => { if (res2.code == 200) { that.isBindPhone = res2.data.user.phone ? true : false; } else common_vendor.index.showToast({ title: res2.message, icon: "none" }); }).catch((error) => { }); }, fail() { } }); } } }; if (!Array) { const _easycom_navBar2 = common_vendor.resolveComponent("navBar"); _easycom_navBar2(); } const _easycom_navBar = () => "../../components/navBar/navBar.js"; if (!Math) { _easycom_navBar(); } function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: common_vendor.p({ leftText: "登录", hideNavBg: true, backBlack: true }), b: common_vendor.s("margin-top:" + $data.contentTop + "px;"), c: common_assets._imports_0$2, d: !$data.isBindPhone }, !$data.isBindPhone ? { e: common_vendor.o((...args) => $options.getPhoneNumData && $options.getPhoneNumData(...args)) } : {}, { f: common_vendor.o(($event) => $data.isBindPhone ? $options.clickOneClickLogin() : ""), g: common_vendor.o(($event) => $options.clickCodeLogin()), h: $data.isAgree }, $data.isAgree ? { i: common_assets._imports_3$4 } : { j: common_assets._imports_4$6 }, { k: common_vendor.o(($event) => $options.clickAgree()), l: common_vendor.o(($event) => $options.clickProtocol(2)), m: common_vendor.o(($event) => $options.clickProtocol(3)) }); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/login/login.js.map