废弃getUserInfo以后,无从下手

发布于 6 年前作者 juanhan19192 次浏览最后编辑 6 年前来自 ask

scope.userInfo 已废弃 如何知道是否已经授权

官方 demo  有点自相矛盾,

wx.getSetting({
      success: function(res){
        if (res.authSetting['scope.userInfo']) {
          // 已经授权,可以直接调用 getUserInfo 获取头像昵称
          wx.getUserInfo({
            success: function(res) {
              console(res.userInfo)
            }
          })
        }
      }
    })

这样写还能用吗

截图来源:https://developers.weixin.qq.com/miniprogram/dev/api/open.html\#wxgetuserinfoobject

9 回复
ming12
ming121 楼6 年前

旧的内容不能也修改下嘛?搞得一头雾水,你们的api文档真的很难看懂

zsun
zsun2 楼6 年前

马上要给客户演示了,突然出来这坑,坑惨了,紧张的弄了好久

mingfeng
mingfeng3 楼6 年前

我也刚刚碰到这样的问题。。。天了噜

changlei
changlei4 楼6 年前

坑啊

yongyu
yongyu5 楼6 年前

我也是这个问题,怎么解决的?

ucheng
ucheng7 楼6 年前

var button = wx.createUserInfoButton({

type: ‘text’,

text: ‘进入游戏’,

style: {

left: window.innerWidth/2-70,

top: window.innerHeight/2+50,

width: 140,

height: 40,

lineHeight: 40,

backgroundColor: ‘#ff0000’,

color: ‘#ffffff’,

textAlign: ‘center’,

fontSize: 16,

borderRadius: 8

}

})

button.onTap((res) => {

console.log(res)

if(res.userInfo)

{

    console.log(res.userinfo)

}

tips:真机调试才显示按钮

qzhao
qzhao9 楼5 年前