uniapp-小程序获取微信用户名称和头像
uniapp 开发小程序过程中,如何获取微信用户的昵称和头像信息,这个uniapp已经集成,通过getUserInfo即可获取到。
·
uniapp 开发小程序过程中,如何获取微信用户的昵称和头像信息,这个uniapp已经集成,通过getUserInfo即可获取到
loginUser(){
let _this=this;
uni.login({
provider: 'weixin',
success: function (loginRes) {
console.log(loginRes.authResult);
// 获取用户信息
uni.getUserInfo({
provider: 'weixin',
success: function (infoRes) {
console.log(infoRes.userInfo)
console.log('用户昵称为:' + infoRes.userInfo.nickName);
_this.userNickName=infoRes.userInfo.nickName;
_this.userAvatar=infoRes.userInfo.avatarUrl;
},fail(e) {
console.log(e)
}
});
}
});
微信接口返回如下信息:
nickName: "大帅哥", avatarUrl: "http://wx.qlogo.cn/*******", gender: 1, province: "Beijing", city: "Tongzhou"}
更多推荐
已为社区贡献2条内容
所有评论(0)