.wxml文件
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">微信登录</button>
.js文件
// 微信授权获取手机号弹窗
getPhoneNumber: function (e) {
var that = this;
if (e.detail.errMsg == "getPhoneNumber:ok") {
this.getLocation()
wx.request({
url: 'http://localhost/index/users/decodePhone',
data: {
encryptedData: e.detail.encryptedData,
iv: e.detail.iv,
sessionKey: that.data.session_key,
uid: "",
},
method: "post",
success: function (res) {
console.log('res...', res);
}
})
}
}