支付宝小程序之蜻蜓设备刷脸核身获取手机号
程序员文章站
2022-03-11 22:37:44
支付宝小程序之蜻蜓设备刷脸核身获取手机号viewjs// 监听事件 onGetAuthorize(e) { my.getPhoneNumber({ s...
支付宝小程序之蜻蜓设备刷脸核身获取手机号
view
<button class="btn-item btn-print" open-type="getAuthorize" onGetAuthorize="onGetAuthorize" onError="onAuthError" scope='phoneNumber'>会员中心</button>
js
// 监听事件
onGetAuthorize(e) {
my.getPhoneNumber({
success: (res) => {
console.log(res)
// 加密串
let encryptedData = res.response;
this.setData({
'memberLoginForm.encryptedData': encryptedData
})
Promise.all([this.getSn(), this.getAuthCode()]).then(res => {
console.log(res)
let [snStatus, codeStatus] = res
if (snStatus && codeStatus) {
if(!this.checkLoginData()) return
// this.goMembers()
this.memberLogin()
}
})
},
fail: (err) => {
console.log(err)
},
});
},
// 静默获取code
// 获取auth_code
getAuthCode() {
return new Promise((resolve, reject) => {
my.getAuthCode({
scopes: 'auth_user',
success: ({ authCode }) => {
console.log(authCode)
this.setData({
'memberLoginForm.code': authCode
})
resolve(true)
}
});
})
},
本文地址:https://blog.csdn.net/w_minx/article/details/108702866