用户调用wx.login()方法,获取登录用户凭证code
wx.login({
success: function(res) {
console.log('loginCode', res.code)
}
});
code传给后台,凭证code获取session_key和openid
https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code
后台会获的用户的openid和session_key
getPhoneNumber组件
拿到encryptedData和iv
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber"></button>
Page({
getPhoneNumber: function(e) {
console.log(e.detail.errMsg)
console.log(e.detail.iv)
console.log(e.detail.encryptedData)
}
})
将encryptedData和iv传给后台