当前位置:网站首页>微信小程序获取手机号
微信小程序获取手机号
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开发库,那直接使用其 敏感信息加/解密 功能就再简单不过了
要下载的话可以去之前微信支付的博文里下载,这里就不一一列出来了
边栏推荐
- [mit 6.s081] LEC 5: calling conventions and stack frames risc-v notes
- LootCode动态数组练习(724,118,766)
- 给程序界面增加音乐,加载背景照片。
- The end of another era!
- [learning notes] solutions to hot account problems
- [MIT 6.S081] Lec 4: Page tables 笔记
- 小米CC9 Pro拆解:后置五摄成本是骁龙855数倍!
- 超实用!阿里P9私藏的Kubernetes学习笔记,看完直呼NB
- 数据库的常用命令2
- Three consecutive high-frequency interview questions of redis online celebrity: cache penetration? Cache breakdown? Cache avalanche?
猜你喜欢
![[MIT 6.S081] Lab8: locks](/img/9f/0ff7a0226837a3c420f49e6da8209f.png)
[MIT 6.S081] Lab8: locks

2021.8.9笔记 request

1. opencv图片基础操作

Deep learning: a survey of behavior recognition

Chained storage structure of dynamic linked list 3 queue (linkedqueue Implementation)

Super practical! After reading the kubernetes study notes hidden by Alibaba P9, call NB directly
![[MIT 6.S081] Lab 10: mmap](/img/5d/a59a6f723518553b9232bc09991075.png)
[MIT 6.S081] Lab 10: mmap
![[mit 6.s081] LEC 1: introduction and examples notes](/img/5d/2fc4bde8eebbb22605d314b5292e05.png)
[mit 6.s081] LEC 1: introduction and examples notes

Solve the problem that reids cannot be accessed by other IPS
![[MIT 6.S081] Lab 11: networking](/img/9d/cca59a662412f3c3c57c26c5987a24.png)
[MIT 6.S081] Lab 11: networking
随机推荐
[MIT 6.S081] Lab 6: Copy-on-Write Fork for xv6
Getting started with typora: the most complete tutorial in the whole network
2021.8.1笔记 DBA
深度学习:行为识别综述
Super practical! After reading the kubernetes study notes hidden by Alibaba P9, call NB directly
[MIT 6.S081] Lab 7: Multithreading
NowCoder(5选)
英特尔发布新一代Movidius VPU:性能提升10倍,功耗仅30W
深度学习:GAN优化方法-DCGAN案例
Lotcode dynamic array exercise (724118766)
荣耀、小米发双十一战报:都称自己是冠军
[mit 6.s081] LEC 6: isolation & system call entry/exit notes
Collection! 0 basic open source data visualization platform flyfish large screen development guide
Common commands of database 1
View port PID and end process
Common commands of database 2
[MIT 6.S081] Lab 11: networking
3. Opencv geometric transformation
江苏华存首发PCIe 5.0 SSD主控:台积电12nm工艺,2020年量产
OEM "made in the United States", domestic security equipment has been installed on the U.S. aircraft carrier!