微信小程序 ---- 用户信息获取篇
用户信息
让用户登录
<button class='bottom' type='primary' open-type="getUserInfo" withCredentials="true" lang="zh_CN" @getuserinfo="wxGetUserInfo">授权登录</button>
//在 methods 里面写
wxGetUserInfo(res){
console.log(res.detail.userInfo)
},
获得手机号码
<button class='bottom' type='primary' open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">获取手机号</button>
//在 methods 里面写
wxGetUserInfo(res){
console.log(res)
},
获得登录人信息
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
console.log(res);
}
})
}
}
})
获得的数据
用户信息详情
还没有评论,来说两句吧...