微信小程序使用uniapp 开发时,需要获取用户信息用于注册
<button type="default" @click="getinfo">获取用户信息</button>
getinfo() {
var that = this;
console.log('获取用户信息')
wx.getUserProfile({
desc: '用于用户登录', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
console.log(res)
that.iv = res.iv
that.encryptedData = res.encryptedData
that.nickName = res.userInfo.nickName
that.sex = res.userInfo.gender
that.pic = res.userInfo.avatarUrl
uni.login({
provider: 'weixin',
success: function(loginRes) {
that.code = loginRes.code
that.wxlogin()
}
});
}
})
},