var config = require('../../config/config.js'); var Common = require('../../common/common.js'); var app = getApp(); Page({ data: { canIUse: wx.canIUse('button.open-type.getPhoneNumber') }, onLoad: function (options) { var that = this; }, getPhoneNumber: function (e) { var that = this; var iv = e.detail.iv; var encryptedData = e.detail.encryptedData; Common.getUserPhone(encryptedData, iv) .then(function (res) { console.log(res); /** * code:0 授权手机号成功 * code:1 授权手机号失败 */ if (res.data.code == 0) { app.globalData.phone = res.data.phone; wx.showToast({ title: res.data.msg, icon: "success", success: function (res) { wx.redirectTo({ url: '../login/login', }) } }) } else if (res.data.code == 1) { wx.showToast({ title: '请重新授权手机号', icon: "none", }) } }) } })