Dragon Boat Festival bean sprouts at home about uni-app Knowledge points of , When operating , When Douya found out that I was calling the wechat Avatar , I used the old way to get my avatar , Now we get a white status and the name of wechat users . Below, first post the code for obtaining wechat avatar and wechat name before bean sprout .
<template> <view class="content"> <u-button
@click="getList"> Click to get the current wechat information </u-button> <text>{{userList.nickName}}</text>
<u-image width="300rpx" height="300rpx" :src="userList.avatarUrl"></u-image>
</view> </template> <script> export default { data() { return { userList: {} }
}, onLoad() { }, methods: { getList() { uni.getUserInfo({ provider: "weixin",
success: (res) => { this.userList = res.userInfo; console.log(res.userInfo) }
}) } } } </script> <style> </style>

Bean sprouts Click to find that the data exists , But when you find the data that is not the current login person . Only the data of a simple wechat user .

Because bean sprouts were obtained in the previous project operation, there was no problem , Then Douya goes to check the documents of wechat applet , In the announcement , Found the problem ,
Originally in 4.28 after , Cannot be used getUserInfo To get the user's personal information , Then bean sprouts were found getUserProfile To get the user's personal information . Post code below .
<template> <view class="content"> <u-button
@click="getList"> Click to get the current wechat information </u-button> <text>{{userList.nickName}}</text>
<u-image width="300rpx" height="300rpx" :src="userList.avatarUrl"></u-image>
</view> </template> <script> export default { data() { return { userList: {} }
}, onLoad() { }, methods: { getList() { uni.getUserProfile({ desc:" Get personal information ",
success: (res) => { this.userList = res.userInfo; console.log(res.userInfo) }
}) } } } </script> <style> </style>
At this time, we will find a normal pop-up page for obtaining user information . You will find that you can normally obtain wechat personal information such as the user's Avatar and wechat name .

Welcome to communicate with bean sprouts in the comment area ???

Technology