当前位置:网站首页>微信小程序获取手机号
微信小程序获取手机号
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开发库,那直接使用其 敏感信息加/解密 功能就再简单不过了
要下载的话可以去之前微信支付的博文里下载,这里就不一一列出来了
边栏推荐
- 3. opencv几何变换
- 同心向前,Google Play 十周年啦!
- [MIT 6.S081] Lec 6: Isolation & system call entry/exit 笔记
- Common commands of database 1
- Chained storage structure of dynamic linked list 3 queue (linkedqueue Implementation)
- 荣耀、小米发双十一战报:都称自己是冠军
- 深度识别:论文阅读_2S-AGCN CVPR2019(基于骨架的动作识别的两流自适应图卷积网络)
- 深度学习:GAN优化方法-DCGAN案例
- 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)
- NowCoder(5选)
猜你喜欢

Deep learning: gat
![[MIT 6.S081] Lab 11: networking](/img/9d/cca59a662412f3c3c57c26c5987a24.png)
[MIT 6.S081] Lab 11: networking

CFA exam registration instructions

What every Salesforce developer should know about Dates and Times in Apex
![[mit 6.s081] LEC 9: interrupts notes](/img/b6/a8d39aa7ede4eb1c5a74e6d15b3b1c.png)
[mit 6.s081] LEC 9: interrupts notes

数据库的常用命令1

Local development using LWC in salesforce

MySQL学习 Day1 DDL、DML、DQL基础查询

深度学习:GAN案例练习-minst手写数字

Localization within Communities
随机推荐
深度学习:STGCN学习笔记
@Convert 注解在jpa中进行查询的注意事项
[learning notes] the implementation principle of the ordered set Zset in redis - skip table
Mysql四种锁
英特尔发布新一代Movidius VPU:性能提升10倍,功耗仅30W
动态链表4单向循环链表(LoopSingle实现)
[MIT 6.S081] Lab 5: xv6 lazy page allocation
被“赶出”比特大陆之后,詹克团首度发声:将通过法律途径尽快回归!
华为Mate30 Pro 5G拆解:自研芯片占比过半,美系芯片依然存在!
@Considerations for query of convert annotation in JPA
MySQL学习 Day1 DDL、DML、DQL基础查询
@DateTimeFormat 接收不到时分秒,转换时报类型异常
Binary tree concept
2021.8.7笔记 servlet
深度学习:GAN案例练习-minst手写数字
深度学习:安装包记录
Local development using LWC in salesforce
Huawei mate30 Pro 5g disassembly: self developed chips account for more than half, and American chips still exist!
[MIT 6.S081] Lec 10: Multiprocessors and locking 笔记
Deep learning: Gan case exercise -minst handwritten digits