1卡骂、直接使用open-data
組件
<open-data type="groupName" open-gid="xxxxxx"></open-data>
<open-data type="userAvatarUrl"></open-data>
<open-data type="userGender" lang="zh_CN"></open-data>
2、wx.getUserProfile
- 每次調(diào)用此接口均會彈窗讓用戶授權(quán)形入,因此要注意保存用戶信息
- 頁面產(chǎn)生點擊事件(例如 button 上 bindtap 的回調(diào)中)后才可調(diào)用
//.wxml
<button bindtap="getUserProfile"> 獲取頭像昵稱 </button>
//.js
getUserProfile(e) {
wx.getUserProfile({
desc: '展示用戶信息', /
success: (res) => {
console.log(res)
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
}