wx.getUserInfo(OBJECT)
獲取用戶信息缠诅,需要先調用 wx.login接口。
- 獲取用戶基本信息
wx.getUserInfo({
success: function(res) {
var userInfo = res.userInfo
var nickName = userInfo.nickName
var avatarUrl = userInfo.avatarUrl
var gender = userInfo.gender
var province = userInfo.province
var city = userInfo.city
var country = userInfo.country
}
})
- 獲取用戶的openid和unionID信息
{
"openId": "OPENID",
"nickName": "NICKNAME",
"gender": GENDER,
"city": "CITY",
"province": "PROVINCE",
"country": "COUNTRY",
"avatarUrl": "AVATARURL",
"unionId": "UNIONID",
"watermark": {
"appid":"APPID",
"timestamp":TIMESTAMP
}
}
從代碼上可以看出钳吟,用戶的所有信息都能從接口上獲取到,可以用于給用戶添加標簽與后臺數(shù)據(jù)結合窘拯,對目標用戶進行分類