获取用户信息接口getUserInfo改版wx.getUserProfile接口简单食用方法
发布于 3 年前 作者 fangfan 5110 次浏览 来自 分享

1.官方文档 https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserProfile.html

2.小程序体现

index.wxml

<button class="btnbindtap="getUserProfile">授权登录</button>

    getUserProfile(e{
      // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
      // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
      wx.getUserProfile({
        desc: '用于完善会员资料'// 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
        success: (res) => {
            console.log(res)
          this.setData({
            userInfo: res.userInfo,
            hasUserInfo: true
          })
        }
      })
    },
1 回复

按这方法获取后,没有回调

回到顶部