新版的获取用户信息授权
包含用户昵称,头像等
<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);
},
// 弹出授权 结束