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) { switch (options.type) { case 'watch': this.setData({ title: '查看填报', value: options.data || '', type: options.type }); break; case 'draftsupdate': this.setData({ title: "修改草稿", value: options.data || '', type: options.type }); break; case 'providedupdate': this.setData({ title: "修改已填报", value: options.data || '', type: options.type }); break; default: this.setData({ type: options.type, value: options.data || '', title: "新增填报" }) } }, 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 () { }, })