wx.getUserProfile({
desc:'获取用户信息',
success(res) {
wx.login({
success(response) {
//获取到code
console.log(response.code)
/** 用appid,appsecret通过wx.request方法可获取openid **/
var appid = ' ';
var secret = ' ';
wx.request({
url: 'https://api.weixin.qq.com/sns/jscode2session?appid='+appid+'&secret='+secret+'&grant_type=authorization_code&js_code=' + loginCode.code,
header: {
'content-type': 'application/json'
},
success: function (response) {
console.log(response)
console.log(response.data.openid) //获取openid
}
})
}
})
}
})