进入 wx.getSetting后 res.authSetting为空

今天发现微信废弃了授权API:’scope.userInfo’

授权允许-> wx. getSetting ,进入success()  后 res.authSetting={}

我不得不说其实腾讯真心垃圾,做的东西全是坑


这个问题主要是因为微信最近刚好废弃了授权API;

大家可以去看调整的公告:https://developers.weixin.qq.com/blogdetail?action=get_post_info&lang=zh_CN&token=384460955&docid=000aee01f98fc0cbd4b6ce43b56c01

没办法,我只能改,想想只能在首页的时候加一个BUTTON授权了


然后首页的JS再添加getUserInfo方法进行授权,然后就OK了。

getUserInfo: function(){
var that = this
wx.getSetting({
success(res) {
if (!res.authSetting[ 'scope.userInfo']) {
wx.authorize({
scope: 'scope.userInfo',
success() {
that.UserLogin();
}
})
}
else{
that.UserLogin();
}
}
})
},

that.UserLogin()登录方法大家可以加自己的业务,这里就不写了;

你可能感兴趣的:(微信小程序)