收藏
回答

wx.login无响应

<button open-type="getUserInfo" lang="zh_CN" bindgetuserinfo="getUserInfo" class="nameNOLogin"style="">点击登录</button>

getUserInfo - wx.login({   下面到这里就进不去了  ,在开发工具中没问题,用手机(华为荣耀V10,Version7.0.6)调试就有问题,手机上不打开调试就不行打开调试就可以



onLoad: function (options) {

var that=this;

wx.getStorage({

key: 'men_openid',

success: function (res) {

that.setData({

men_openid: res.data

});

}

});

if (app.globalData.userInfo) {

this.setData({

userInfo: app.globalData.userInfo,

hasUserInfo: true

})

} else if (this.data.canIUse){

// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回

// 所以此处加入 callback 以防止这种情况

app.userInfoReadyCallback = res => {

this.setData({

userInfo: res.userInfo,

hasUserInfo: true

});

//请求个人中心信息

this.personalCenterInformation();

}


} else {

// 在没有 open-type=getUserInfo 版本的兼容处理

wx.getUserInfo({

success: res => {

app.globalData.userInfo = res.userInfo

this.setData({

userInfo: res.userInfo,

hasUserInfo: true

});

}

})

}

},



//登录授权

getUserInfo: function (e) {

var that=this;

var imgcommon = app.globalData.imgcommon;

// app.globalData.userInfo = e.detail.userInfo;

if (e.detail.errMsg == "getUserInfo:ok") {

that.setData({

userInfo: e.detail.userInfo,

hasUserInfo: true

});

wx.login({   //到这里就进不去了

success: res => {

var code = res.code;//登录凭证

wx.request({

url: imgcommon+'WeChatMallService/getUserinfoMall',

data: {

encryptedData: e.detail.encryptedData,

iv: e.detail.iv,

code: code

},

success: function (rest) {

console.log(JSON.stringify(rest))

var openid = rest.data.result[0].strPar2; //返回openid

getApp().globalData.men_openid = openid;

wx.setStorage({

key: 'men_openid',

data: openid

});

if (rest.data.ret=="3"){//提示绑定手机

that.setData({

dialogShow: true

})

} else if (rest.data.ret == "1"){

wx.setStorageSync("configuration", rest.data.result);

that.personalCenterInformation();

}else{

that.personalCenterInformation();

}

}

});

}

});

}

},


最后一次编辑于  09-30
回答关注问题邀请回答
收藏

1 个回答

问题标签