[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
端午节豆芽在家整理关于uni-app的知识点,动手操作的时候,豆芽发现我去调用微信头像的时候,我用以前获取头像的方法,现在获取的是一个白色状态和微信用户的名称。下面先贴豆芽以前获取微信头像和微信名的代码。
<template> <view class="content"> <u-button
@click="getList">点击获取当前微信信息</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>
豆芽点击发现数据是存在的,但是当会发现不是当前登陆人的数据。只是单纯一个微信用户的数据。
因为豆芽以前项目操作是这么获取的没有什么问题,然后豆芽去查阅微信小程序的文档,在公告中,发现了问题的所在,
原来在4.28之后,就无法使用getUserInfo去获取用户的个人信息,随后豆芽发现新增了getUserProfile去获取用户的个人信息。下面贴代码。
<template> <view class="content"> <u-button
@click="getList">点击获取当前微信信息</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:"获取个人信息",
success: (res) => { this.userList = res.userInfo; console.log(res.userInfo) }
}) } } } </script> <style> </style>
这个时候我们就会发现正常弹出的一个申请获取用户信息的页面。会发现正常去获取到了用户的头像和微信名等微信个人信息。
欢迎大家在评论区和豆芽一起交流???