getUserProfile(e) {
var that = this
wx.getUserProfile({
desc: '用于完善会员资料',
success: (res) => {
if (res) {
//用户名 res.userInfo.nickName
//头像res.userInfo.avatarUrl
//获取code
wx.login({
success: (ress) => {
//code获取 ress.code
//app.globalData.URL是封装的接口通用地址部分
let url = app.globalData.URL + '接口地址'
//data是传参的值
let data = {
avatarUrl: res.userInfo.avatarUrl,
code: that.data.code,
nickName: res.userInfo.nickName,
}
//app.wxRequest是封装的请求方法
app.wxRequest(
'POST',
url,
data,
(res) => {
if (res.code == 200) {
//登录成功跳转到首页
wx.switchTab({
url: '../index/index',
})
} else {
that.onLoad()
}
},
(err) => {
console.log(err.errMsg)
}
)
},
})
}
},
})
},
08-19
193
02-22
4967
02-12
2802