const url = require('../../utils/httpUrl') var app = getApp(); Page({ /** * 页面的初始数据 */ data: { ApppId:'wx1d994f0e42ec45c9', AppSecret :'3c2aa6a1950d75f8a656155fe30b7887', sq:'授权', avatarUrl:'', }, /** * 生命周期函数--监听页面加载 * */ onLoad: function (options) { }, // 获取手机号 getPhoneNumber (e) { var that = this; wx.login({ complete: (res) => { wx.request({ url: app.coreUrl+'PostPhoneNumber', data: { encryptedData: e.detail.encryptedData, iv: e.detail.iv, code:res.code }, method: "post", success: function (resphone) { if(res.data==''){ wx.showModal({ title: '提示', content: '未获取,再起点击授权', showCancel:true, success (res) { if (res.confirm) { } else if (res.cancel) { } } }) } else{ if(resphone.data.phoneNumber!=undefined&&resphone.data.phoneNumber!=''&&resphone.data.phoneNumber!=null){ wx.setStorageSync( 'phone',resphone.data.phoneNumber+','+that.data.avatarUrl ) wx.request({ url: app.coreUrl+'updateOwnerUrl', data:{ tel:resphone.data.phoneNumber, url:that.data.avatarUrl }, method: "post", success:function(e){ if(e!="微信头像更新成功"){ return; } } }) } wx.navigateBack({ delta: 1 }) } } }) }, }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, })