收藏
回答

wx.getUserInfo的使用

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug wx.getUserInfo 微信安卓客户端 6.5.3 3.1.1

你好,我看到文档上面写“wx.getUserInfo (已回收)”,是什么意思呢?是这个api不能用了吗

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

6 个回答

  • optimistic
    optimistic
    2023-09-26

    是这样的,在废弃之前的版本库是有效的,废弃之后的版本库无效,如果想要足够的兼容性,头像填充能力和这个getUserProfile 都要做,判断的话使用 canIUse('button.chooseAvatar') 判断是否可用,不可用就降级处理

    参考:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/userProfile.html

    2023-09-26
    有用 1
    回复
  • bug
    bug
    2023-09-26

    我们已经没用这个接口了,头像和昵称已经获取不到了

    2023-09-26
    有用
    回复
  • CRMEB
    CRMEB
    2023-09-26

    用这个也是不能直接获取头像昵称

    2023-09-26
    有用
    回复
  • BOBO
    BOBO
    2023-09-26

    昵称和头像不会返回了。如果只是用unionId和opneId 没影响

    2023-09-26
    有用
    回复
  • ^3^
    ^3^
    2023-09-26

    getphone(e) {

    const code = e.detail.code;

    if (!code) return;

    const appid = uni.getStorageSync('appid');

    const openid = uni.getStorageSync('openid');

    const unionId = uni.getStorageSync('unionId');

    wx.getUserInfo({

    success: res => {

    const userName = res.userInfo.nickName;

    getAppletPhoneByCode({

    code,

    appid,

    openid,

    unionId,

    userName

    }).then(res => {

    if (res.code === 200) {

    uni.setStorageSync('userid', res.data);

    //更新消息列表语言

    const type = uni.getSystemInfoSync().uniPlatform

    console.log(type) // mp-weixin

    updateLanguageType({

    user: uni.getStorageSync('userid') || '',

    manage: '',

    languageType: this.$i18n.locale === 'zh_CN' ? 1 : 2,

    systemType: type === 'mp-weixin' ? 1 : 2

    }).then(res => {

    console.log(res, '1')

    })

    if (this.contractId || this.rtuaddr) {

    // this.$refs['uToast'].show({

    // title: '授权成功!',

    // back: true

    // });

    uni.navigateBack({

    delta: 1, // 返回的页面数,1 表示返回上一个页面

    });

    } else {

    uni.reLaunch({

    url: '/pages/user/index/index'

    });

    }

    } else {

    let str = this.errorCode(res.msg);

    this.$refs.uToast.show({

    title: str

    });

    }

    });

    },

    fail: err => {

    console.log(err, '1')

    }

    });

    },

    2023-09-26
    有用
    回复
  • Hlxuan.
    Hlxuan.
    2023-09-26

    能用,就是不能获取到用户的头像和昵称。

    2023-09-26
    有用
    回复
登录 后发表内容