收藏
回答

调用最新的wx.getUserProfile接口时没有任何反应?

在微信开发者工具中调用了wx.getUserProfile接口时没有任何的反应,开发者工具的版本是1.05.2103042,基础库是2.15.0,也试过了使用wx.getSetting来授权,授权结果返回scope.userInfo:true,调用wx.getUserProfile接口还是没有任何反应,也没有报错,也没有数据返回

wx.getUserProfile({
      lang"en",
      success(res) {
        console.log(res.userInfo)
      }
    })
    
wx.getSetting({
  success (res){
    console.log(res.authSetting)
    if (res.authSetting['scope.userInfo']) {
      // 已经授权,可以直接调用 getUserInfo 获取头像昵称
      wx.getUserProfile({
     success: function(res) {
           console.log(res.userInfo)
         }
      })
     }else{
       console.log(123)
    }
  }
})

 //最终返回的结果是:
//{scope.userInfo: true, scope.address: true, scope.invoice: true, scope.invoiceTitle: true}
回答关注问题邀请回答
收藏

4 个回答

  • 易得优网站定制开发
    易得优网站定制开发
    2021-06-04

    <button class='add-btn3' type='primary' :hidden='openSettingBtnHidden' open-type="getUserInfo" @getuserinfo="getuserinfo">微信授权</button>

    getuserinfo() {

    console.log("刷新:") //+ e.detail.userInfo

    wx.getUserProfile({

      desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写

      success: (res) => {

        this.setData({

          userInfo: res.userInfo,

          hasUserInfo: true

        })

      },

      fail: () => {

      // that.openSettingBtnHidden = false; // 显示 that.openSettingBtnHidden=false;

        console.log('发生错误')

      },

    })

    console.log("刷新2:") //+ e.detail.userInfo

    },


    直接就返回:  console.log('发生错误')

    为什么?

    2021-06-04
    有用
    回复
  • 阿贤
    阿贤
    2021-06-01

    注意的是新的接口wx.getUserProfile,只能使用catchtap或者bindtap进行调用(ps:可以再wx.getUserProfile中使用),并不能再onload、onshow等位置直接调用


    2021-06-01
    有用
    回复
  • 软件开发成晓晓
    软件开发成晓晓
    2021-04-21

    不报错,button的点击事件彻底无效,是有时候可以点击,很多时候一点动静都没有

    2021-04-21
    有用
    回复
  • Mr.Zhao
    Mr.Zhao
    2021-03-05

    getUserProfile 只能通过点击按钮触发

    2021-03-05
    有用
    回复 7
    • juy
      juy
      2021-03-05
      试了点击按钮,也同样没反应。是我写的有问题吗?
      2021-03-05
      回复
    • Mr.Zhao
      Mr.Zhao
      2021-03-05回复juy
      学会排查错误
      2021-03-05
      回复
    • juy
      juy
      2021-03-05
      谢谢,是我的疏忽,下次会注意。
      2021-03-05
      回复
    • 七哥
      七哥
      2021-03-09回复juy
      你现在有反应了嘛?我的还是没有反应啊
      2021-03-09
      回复
    • 成风
      成风
      2021-03-10回复七哥
      desc必填,微信开发者工具版本1.05.2103022及以上,最后看下调试器有没有报错。
      2021-03-10
      回复
    查看更多(2)
登录 后发表内容
问题标签