import Dialg from "../../miniprogram_npm/@vant/weapp/dialog/dialog"; const app = getApp(); Page({ data: { CustomBar: app.globalData.CustomBar, }, // 登录 async getphonenumber (e) { try { if (!e.detail.hasOwnProperty('iv')) return false; let { encryptedData, iv } = e.detail, { appId: appid } = app.globalData.mustArg, { openid } = app.globalData.user; let res = await wx.$request({ url: "/account/wxbind/", data: { appid, openid, encryptedData, iv }, method: "post" }); let { face, name, tel, token, type, user_id } = res.data; wx.setStorageSync("token", token ? 'JWT ' + token : ''); app.globalData.user = { ...app.globalData.user, face, name, tel, token, type, user_id }; this.onShow(); } catch (err) { wx.$err(err) } }, onLoad: function (options) { options.data && this.setData({ value: options.data }); }, onReady: function () { }, onShow: function () { if (!app.globalData._initState) { wx.navigateTo({ url: '/pages/index/index', }); return false; } !wx.getStorageSync('token') && Dialg.confirm({ message: "您尚未登录,不能操作该功能!", confirmButtonText: '微信快捷登录', confirmButtonOpenType: "getPhoneNumber" }).then(res => { }).catch(() => { wx.navigateBack({ delta: 1 }) }) ; }, onHide: function () { }, onUnload: function () { }, onPullDownRefresh: function () { }, onReachBottom: function () { }, })