由于getUserInfo目前不能返回用户的微信名称 和微信头像,更新为getUserProfile方法方可,所以做出以下代码
wxml代码
<view class="header">
<image bindtap="bindViewTap" class="img" src="{
{userInfo.avatarUrl}}" mode="cover"></image>
</view>
</view>
<view class="auth-title">申请获取以下权限</view>
<view class="auth-subtitle">获得你的公开信息(昵称、头像等)</view>
<button wx:if="{
{canIUseGetUserProfile}}" class="login-btn" bindtap="getUserProfile"> 授权登录 </button>
<button wx:else class="login-btn" openType="getUserInfo" lang="zh_CN" bindgetuserinfo="authorLogin">授权登录</button>
</view>
js代码
data: {
userInfo: {