Hi FE !
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub
  • 新版的获取用户信息授权

新版的获取用户信息授权

包含用户昵称,头像等

<button  bindtap="bindGetUserInfo" class="btnPhone {{wechat_name !=''?'btnPhoneActive':''}}">授权登录</button>
// 弹出授权 开始
    bindGetUserInfo: function(res) {
      var that = this
      // getUserProfile
      wx.getUserProfile({
              desc: '展示用户信息',    //不能为空
                success(res){
                  console.log("xinban获取用户信息",res)
                  that.setData({
                    wechat_name:res.userInfo.nickName,
                    headimgurl:res.userInfo.avatarUrl,
                    province:res.userInfo.province,
                    country:res.userInfo.country,
                    gender:res.userInfo.gender,
                    city:res.userInfo.city,
                })
                that.postInfo()
                wx.showToast({
                  title: '授权成功!', // 标题
                  icon: 'success',  // 图标类型,默认success
                  duration: 1500  // 提示窗停留时间,默认1500ms
                })
              }      
      })
        console.log(res);
     },
  // 弹出授权 结束
Edit this page
最近更新: 2025/12/2 01:46
Contributors: qdleader
qdleader
本站总访问量 129823次 | 本站访客数 12人