开发了个小程序,出现很奇怪事情,几十个人都能正常使用,但就有2个无法通过授权,点授权,跳开,但是后台获取不到信息,不知道是什么原因,代码如下:
import requestb from '../../../utils/requs.js'
var api=require('../../../config/api.js');
const app = getApp()
Page({
data:{
navUrl: '',
userInfo: {},
hasUserInfo: false,
canIUseGetUserProfile: true,
code: '',
token:''
},
getUserProfile() {
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
let that=this;
wx.getUserProfile({
desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
that.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
console.log("useif:",res.userInfo)
this.bindgetuser();
}
});
},
bindgetuser:function () {
let that = this;
var codeab=that.data.code;
if(codeab ){
console.log("code:", that.data.code);
console.log("usde",that.data.userInfo)
requestb({
url:api.AuthLoginByWeixin,
data:{
code: that.data.code,
userInfo: that.data.userInfo
},
method: 'POST',
header:'application/json'
})
.then(res => {
// console.log("df:"+res.data.token);
if (res.respCode == 0 ) {
//存储用户信息
// console.log(res);
wx.setStorageSync('userInfo', that.data.userInfo);
wx.setStorageSync('token', res.data.token);
wx.setStorageSync('userId', res.data.userId);
wx.setStorageSync('wxid', res.data.wxid);
console.log(wx.getStorageSync("userInfo"));
console.log(wx.getStorageSync("token"));
}
if (res.respCode != 0 ) {
wx.showModal({
title: '提示',
content: res.data.errmsg,
showCancel: false
});
}
})
}
if (that.data.navUrl && that.data.navUrl == '/pages/index/index') {
wx.switchTab({
url: that.data.navUrl,
})
} else if (that.data.navUrl) {
wx.redirectTo({
url: that.data.navUrl,
})
}
},
// onload begin
onLoad: function(options) {
var tokena=wx.getSystemInfoSync("token");
let that = this;
this.setData({
hasUserInfo: false
})
// console.log("toke"+ tokena+"/"+that.data.hasUserInfo +"/"+that.data.canIUseGetUserProfile)
//---index huoqu end
if (wx.getStorageSync("navUrl")) {
that.setData({
navUrl: wx.getStorageSync("navUrl")
})
} else {
that.setData({
navUrl: '/pages/index/index'
})
}
wx.login({
success: function(res) {
if (res.code) {
that.setData({
code: res.code
})
}
}
});
}
})
有什么报错信息吗