<template>
<view style="padding: 40rpx;">
<button type="primary" @click="getProfile">微信授权</button>
</view>
</template>
<script setup>
function getProfile() {
un.getUserProfile({
desc: '测试 getUserProfile 弹窗',
success: (res) => {
console.log('success', res)
uni.showModal({
title: '授权成功',
content: JSON.stringify(res.userInfo, null, 2)
})
},
fail: (err) => {
console.log('fail', err)
uni.showModal({
title: '授权失败',
content: JSON.stringify(err, null, 2)
})
}
})
}
</script>
写了个简单的demo 返回的还是测试数据 调用这个方法也不自动调起微信的授权弹窗
接口能力被收回了,https://developers.weixin.qq.com/community/develop/doc/00022c683e8a80b29bed2142b56c01
这个api废弃很久了,现在只能用头像昵称填写能力,具体参考公告:
https://developers.weixin.qq.com/community/develop/doc/00022c683e8a80b29bed2142b56c01
function getProfile() { uni.getUserProfile({ desc: '测试 getUserProfile 弹窗', success: (res) => { console.log('success', res) uni.showModal({ title: '授权成功', content: JSON.stringify(res.userInfo, null, 2) }) }, fail: (err) => { console.log('fail', err) uni.showModal({ title: '授权失败', content: JSON.stringify(err, null, 2) }) } }) }
"scope.userInfo": {
"desc": "用于完善用户资料"
}
配置里也配置了这个