getphonenumber和wx.login调用顺序
发布于 6 年前 作者 yinjie 18918 次浏览 来自 问答

最近在写获取微信手机号,调用getphonenumber时,文档说先调用wx.login,那么wx.login在什么地方调用合适?

getPhoneNumber: function(e) {
 
    let that = this;
 
    console.log("e.info", e);
 
    if (e.detail.errMsg == 'getPhoneNumber:ok') {
 
      that.data.phoneEncryptedData = e.detail.encryptedData;
      that.data.phoneIV = e.detail.iv;
 
      wx.login({
        success: function(res) {
          if (res.code) {
 

           // 通过code从自己服务器获取解密的手机号

            that.getPhoneNumberInfo(res.code);
 
          } else {
 
          }
        }
      });
 
    }
  },

1 回复

循环地狱

回到顶部