2026最新 · 最低基础库 2.21.2+

wx.getUserProfile 废弃替代方案(获取头像与昵称)

新版基础库中 wx.getUserProfile 不再弹窗返回真实微信头像和昵称,而是固定返回灰色默认头像和“微信用户”。提审时若用户无法修改个人资料会被判体验异常。

❌ 旧写法(已废弃 / 易拒审)

// ❌ 已失效:只返回灰头像和“微信用户”
wx.getUserProfile({
  desc: '用于完善会员资料',
  success: (res) => console.log(res.userInfo)
});

✅ 2026 最新合规写法

<!-- ✅ 2026 最新合规写法 (WXML) -->
<button open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
  <image src="{{avatarUrl}}" style="width:80rpx;height:80rpx;" />
</button>
<input type="nickname" placeholder="请输入昵称" bind:change="onInputNickname" />
查看相关驳回申诉话术 →运行本地代码合规体检查看完整过审源码模板