当前位置:网站首页>微信小程序获取手机号
微信小程序获取手机号
2022-07-27 16:11:00 【mr_cmx】
首先得先获取session_key,不知道怎么获取可以看我之前的博文
wxml:
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">
获取手机号
</button>
js:
//获取用户手机号
getPhoneNumber (e) {
if(e.detail.errMsg=='getPhoneNumber:ok'){
let self=this;
wx.showLoading({
title: '加载中',
mask:true
})
let data={
sessionkey:app.globalData.session_key,//先前获取到的session_key
iv: e.detail.iv,
encryptedData: e.detail.encryptedData//加密数据
};
//这里我们已经拿到encryptedData加密数据,接下来就发送到后台进行AES解密
wx.request({
url: app.globalData.requestUrl+'/wx/get_phoneNumber ', //改成你自己的url
data,
header: {
"Content-Type": "application/x-www-form-urlencoded"
},
method:'POST',
success (res) {
wx.hideLoading()
console.log(res.data)
//预计解密后json 结构
/*{ "phoneNumber": 用户绑定的手机号(国外手机号会有区号), "purePhoneNumber": 没有区号的手机号, "countryCode": 区号, "watermark": { "appid": APPID, "timestamp": TIMESTAMP } }*/
}
})
}
}
后台解密
微信官方提供了多种编程语言的示例代码((点击下载)。每种语言类型的接口名字均一致。调用方式可以参照示例
如果已使用过之前微信支付讲过的微信官方提供的wechatpay开发库,那直接使用其 敏感信息加/解密 功能就再简单不过了
要下载的话可以去之前微信支付的博文里下载,这里就不一一列出来了
边栏推荐
- 联发科首款5G SoC来了!A77+G77+APU3.0,11月26日正式发布!
- Huawei mate30 Pro 5g disassembly: self developed chips account for more than half, and American chips still exist!
- Read only mode of buffer
- [MIT 6.S081] Lab 6: Copy-on-Write Fork for xv6
- [learning notes] Lombok's @builder annotation
- 3. opencv几何变换
- [mit 6.s081] LEC 4: page tables notes
- Three consecutive high-frequency interview questions of redis online celebrity: cache penetration? Cache breakdown? Cache avalanche?
- @Considerations for query of convert annotation in JPA
- NVIDIA released the world's smallest edge AI supercomputing: 21tops computing power, power consumption is only 10W!
猜你喜欢
![[MIT 6.S081] Lab 9: file system](/img/f5/ea30b1fe5b6d73c86f2509c690ca20.png)
[MIT 6.S081] Lab 9: file system

深度学习:STGCN学习笔记

深度学习:GAN案例练习-minst手写数字
![[MIT 6.S081] Lab 6: Copy-on-Write Fork for xv6](/img/ca/e8c0827b13805c7c74cc41bf84c6ff.png)
[MIT 6.S081] Lab 6: Copy-on-Write Fork for xv6
![[MIT 6.S081] Lab 7: Multithreading](/img/f4/26e513fb8678a88cfba29c1a636b37.png)
[MIT 6.S081] Lab 7: Multithreading

数据库的常用命令2

二叉树概念

Common commands of database 1
![[learning notes] advanced version of MySQL database - index optimization, slow query, locking mechanism, etc](/img/7a/7497a73b435c3ed4fa0f3a3e908298.jpg)
[learning notes] advanced version of MySQL database - index optimization, slow query, locking mechanism, etc

Chained storage structure of dynamic linked list 3 queue (linkedqueue Implementation)
随机推荐
Intel releases a new generation of movidius Vpu: 10 times higher performance and 30W power consumption
zabbix6.0的安装部署
[learning notes] solutions to hot account problems
深度学习:GCN(图卷积神经网络)理论学习总结
Announcing the acquisition of 30% shares of Wenye, what is the general intention of Dalian United?
2021.8.6笔记 jsoup
[MIT 6.S081] Lec 3: OS organization and system calls 笔记
请教大神一个问题 flinkcdc,同步mysql中的datetime字段会变为时间戳 有人遇到过吗
OEM "made in the United States", domestic security equipment has been installed on the U.S. aircraft carrier!
深度学习:GAN案例练习-minst手写数字
CFA exam registration instructions
Set up SSO based on SAML 2.0 in salesforce and enable JIT user provisioning (between SF orgs / between SF org and experience cloud / other IDPs)
荣耀、小米发双十一战报:都称自己是冠军
深度学习:安装包记录
记一次 .NET 某智慧物流 WCS系统 CPU 爆高分析
[MIT 6.S081] Lab 3: page tables
1. opencv图片基础操作
MySQL four locks
Huawei mate30 Pro 5g disassembly: self developed chips account for more than half, and American chips still exist!
Guoju spent $1.8 billion to acquire its competitor KEMET, and the transaction may be completed in the second half of next year