问题描述:微信7.0.0版本,所有机型,未上线正在测试的体验版本,登录切换手机号无效,只能登录原来绑定手机号账号;切换手机号点击允许授权调wx.login()发送code到后台换取对应openId,后台反应换取的还是原来绑定账号的openId !!
代码断:
wxml:
<!-- 微信授权登录 --> <view class = "wxland" > <p><image src= "../../images/land_page/wx.png" ></image></p> <text>微信授权登录</text> <button wx: if = "{{canIUse}}" open-type= "getPhoneNumber" bindgetphonenumber= "getPhoneNumber" ></button> </view> |
js:
getPhoneNumber: function (e) { if (e.detail.errMsg === 'getPhoneNumber:ok' ) { //用户同意授权 this .setData({ phoneInfo: e.detail }) this .login() } else { //用户拒绝授权 return ; //用户按了拒绝按钮 } }, login: function (e) { let that = this wx.login({ success(res) { if (res.code) { wxGetData({ api: 'weixin/xcxLogin' , //登录接 data: { code: res.code, encryptedData: that.data.phoneInfo.encryptedData, iv: that.data.phoneInfo.iv } }).then(res => { console.log(res) if (!res.data || res.data.code != '0' ) { wx.hideLoading(); wx.showModal({ title: '提示' , content: res.data.message, showCancel: false }) return ; } let userInfo = res.data.data.member wx.setStorageSync( 'token' , res.data.data.access_token) wx.setStorageSync( 'userInfo' , userInfo); wx.navigateBack(); }) } else { wx.hideLoading(); wx.showModal({ title: '提示' , content: '无法登录,请重试' , showCancel: false }) return ; } } })
onLoad: function(options) {}, onShow: function() {}, |
请勿重复发帖,原帖已有跟进
确定??????