W3Cschool
恭喜您成為首批注冊(cè)用戶(hù)
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
獲取用戶(hù)綁定的手機(jī)號(hào)。需要用戶(hù)主動(dòng)通過(guò) button 組件的點(diǎn)擊來(lái)觸發(fā)后才能發(fā)起獲取手機(jī)號(hào)接口。
需要將 <button> 組件 open-type 的值設(shè)置為 getPhoneNumber。用戶(hù)點(diǎn)擊后會(huì)彈出一個(gè)授權(quán)彈窗讓用戶(hù)確認(rèn)(若該用戶(hù)賬戶(hù)未綁定手機(jī)號(hào)碼會(huì)執(zhí)行一次綁定手機(jī)號(hào)碼的流程;授權(quán)彈窗每次使用都會(huì)彈出)。 用戶(hù)同意后,開(kāi)發(fā)者可以通過(guò) bindgetphonenumber 事件回調(diào)獲取到一個(gè)加密數(shù)據(jù),開(kāi)發(fā)者可以把該數(shù)據(jù)傳回到自己的服務(wù)端進(jìn)行解密獲取手機(jī)號(hào)。
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumberHandler"></button>
Page({
getPhoneNumberHandler (e) {
console.log(e.detail.errMsg)
console.log(e.detail.iv)
console.log(e.detail.encryptedData)
}
});
參數(shù) | 類(lèi)型 | 說(shuō)明 |
---|---|---|
errMsg
|
string
|
錯(cuò)誤信息 |
encryptedData
|
string
|
包括敏感數(shù)據(jù)在內(nèi)的完整用戶(hù)信息的加密數(shù)據(jù) |
iv
|
string
|
加密算法的初始向量 |
errMsg為發(fā)生錯(cuò)誤時(shí)具體的錯(cuò)誤信息:
參考敏感數(shù)據(jù)處理在開(kāi)發(fā)者后臺(tái)解密。揭秘后獲取得到的數(shù)據(jù)形式如下:
{
"phoneNumber": "138xxxxxxxx", // 用戶(hù)綁定的手機(jī)號(hào)(國(guó)外手機(jī)號(hào)會(huì)有區(qū)號(hào))
"purePhoneNumber": "138xxxxxxxx", // 沒(méi)有區(qū)號(hào)的手機(jī)號(hào)
"countryCode": "86", // 區(qū)號(hào)
"watermark": {
"appid": "ttxxxxxxxxxxxxxxxx",
"timestamp": 15000000000000000
}
}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: