const app = getApp() import request from '../../utils/request' import Dialog from '@vant/weapp/dialog/dialog'; Page({ /** * 页面的初始数据 */ data: { isAgree: false }, /** * 生命周期函数--监听页面加载 */ onLoad() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, getPhoneNumber(e) { const that = this if (e.detail.iv) { const openId = wx.getStorageSync('openId') const appId = request.appId const iv = e.detail.iv const encryptedData = e.detail.encryptedData const data = { openId, appId, encryptedData, iv, } that.loginWithPhone(data) } else { wx.showToast({ title: '授权失败', icon: "error" }) } }, checkUserPro() { if (!this.data.isAgree) { Dialog.confirm({ title: '提示', message: '同意智像相机用户使用协议?', }) .then(() => { this.setData({ isAgree: true }) }) .catch(() => { // on cancel }); } }, checkboxChange(e) { if (e.detail.value[0]) { this.setData({ isAgree: true }) } else { this.setData({ isAgree: false }) } }, goPro() { wx.navigateTo({ url: '/pages/userProtocol/userProtocol', }) }, loginWithPhone(data) { request.post({ url: '/api/miniApp/loginPhone', data }).then(res => { wx.showToast({ title: '登录成功!', icon: "success", duration: 1500, complete: () => { setTimeout(() => { wx.redirectTo({ url: '/pages/index/index', }) }, 1500); } }) }).catch(err => { console.log(err, 'err'); }) }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })