收藏
回答

获取用户信息un.getUserProfile 为什么一直返回测试数据?

AppID
wx39db5c3ec534fdab
<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 返回的还是测试数据 调用这个方法也不自动调起微信的授权弹窗

回答关注问题邀请回答
收藏

4 个回答

  • peng
    peng
    07-12

    接口能力被收回了,https://developers.weixin.qq.com/community/develop/doc/00022c683e8a80b29bed2142b56c01

    07-12
    有用
    回复
  • 啊哈
    啊哈
    07-12

    这个api废弃很久了,现在只能用头像昵称填写能力,具体参考公告:

    https://developers.weixin.qq.com/community/develop/doc/00022c683e8a80b29bed2142b56c01

    07-12
    有用
    回复
  • (●—●)
    (●—●)
    07-12
    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)
            })
          }
        })
      }
    
    07-12
    有用
    回复
  • (●—●)
    (●—●)
    07-12

        "scope.userInfo": {

          "desc": "用于完善用户资料"

        }

    配置里也配置了这个

    07-12
    有用
    回复
登录 后发表内容