收藏
回答

紧急重大bug!!!微信小程序重新授权登录切换不了账号









问题描述:微信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() {},




回答关注问题邀请回答
收藏

2 个回答

  • 灵芝
    灵芝
    2019-01-03

    请勿重复发帖,原帖已有跟进

    2019-01-03
    有用
    回复
  • 🚗🚕🚙🚌🚎🚒🚐🚚
    🚗🚕🚙🚌🚎🚒🚐🚚
    2019-01-03

    确定??????

    2019-01-03
    有用
    回复
登录 后发表内容