用户登录时提示undefined is not an object?
在测试版进行小程序测试时一个测试账号发生登录错误导致无法使用微信登陆,但其他账号是正常的
手机型号iphone 12 pro ios14.3
微信版本8.0.0
基础库版本2.15.0[502]
otherlogin:function(e){
let that = this;
// 获取用户信息
wx.getSetting({
success(res) {
if (res.authSetting['scope.userInfo']) {
wx.getUserInfo({
success(res) {
console.log(res)
that.setData({
nickName:res.userInfo.nickName,
avatarUrl:res.userInfo.avatarUrl
})
// 登录
wx.login({
success:(res)=>{
// console.log(res)
// 请求后台登录存储token
wx.request({
url: app.globalData.URL+'/api/user/third',
method:'GET',
data:{
'platform':'微信',
'code':res.code
},
header:{"content-type":"application/json"},
success:(res)=>{
console.log(res)
wx.setStorageSync('token', res.data.data.userinfo.token)
if(res.data.data.status==1){
wx.request({
url: app.globalData.URL+'/api/user/profile',
method:'GET',
data:{
'avatar':that.data.avatarUrl,
'nickname':that.data.nickName
},
header:{"content-type":"application/json",'token':res.data.data.userinfo.token},
success:(res)=>{
wx.reLaunch({
url: '../index/index',
})
}
})
}else if(res.data.data.status==0){
wx.navigateTo({
url: '../choseposition/choseposition',
})
}
}
})
}
})
},
fail(res) {
console.log("获取用户信息失败", res)
}
})
} else {
console.log("未授权=====")
that.showSettingToast("请授权")
}
},
fail(res){
console.log(res)
}
})
},