微信小程序发送 res.code 到后台换取 openId

// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
if(res.code){
wx.request({
url: 'https://mini.yuehuayueyou.com/Meeting/wx/onlogin', //仅为示例,并非真实的接口地址
method: "GET",
data: {
"code":res.code
},
header: {
'content-type': 'application/json' // 默认值
},
success: function (res) {
if (res.data.openid){
wx.setStorage({
key: "tokenId",
data:res.data.openid,
})
}
}
})
}
}
})

猜你喜欢

转载自blog.csdn.net/weixin_40292626/article/details/79667580
今日推荐