【微信小程序】如何获取用户绑定手机号
2023-09-11 14:16:52 时间
用户调用wx.login()方法,获取登录用户凭证code
wx.login({
success: function(res) {
console.log('loginCode', res.code)
}
});
code传给后台,凭证code获取session_key和openid
https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code
后台会获的用户的openid和session_key
[外链图片转存失败(img-rQSCUZCI-1563290280720)(https://upload-images.jianshu.io/upload_images/2481127-09ea7e9e1f7fecbb.png?imageMogr2/auto-orient/strip|imageView2/2/w/346/format/webp)]
getPhoneNumber组件
拿到encryptedData和iv
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber"></button>
Page({
getPhoneNumber: function(e) {
console.log(e.detail.errMsg)
console.log(e.detail.iv)
console.log(e.detail.encryptedData)
}
})
将encryptedData和iv传给后台
[外链图片转存失败(img-XB74dpNR-1563290280723)(https://upload-images.jianshu.io/upload_images/2481127-b2d4800dcac8925b.png?imageMogr2/auto-orient/strip|imageView2/2/w/703/format/webp)]
请点赞!因为你们的赞同/鼓励是我写作的最大动力!
欢迎关注达叔小生的简书!
这是一个有质量,有态度的博客
[外链图片转存失败(img-ACAtKBpw-1563290280725)(https://upload-images.jianshu.io/upload_images/11158618-9ab0d3fef85d80ce?imageMogr2/auto-orient/strip|imageView2/2/w/1240)]
相关文章
- 探讨:微信小程序应该如何设计
- 微信小程序_(表单组件)button组件的使用
- 微信小程序转百度小程序代码
- 微信小程序开发(五)数据绑定
- 微信小程序 —— button按钮去除border边框
- 微信小程序如何转换成分与秒
- 【转载】微信小程序-开发入门(一)
- EasyNVR网页/微信播放RTSP摄像机HLS/RTMP播放时出现起播等待问题的优化过程
- uni-app:运行到微信小程序模拟器(hbuilderx 3.6.18)
- 微信小程序----折叠面板(MUI折叠面板)
- manjaro安装微信命令
- 微信小程序开发系列 (二) :微信小程序的单步调试和控制器实现步骤概述
- uniapp微信小程序如何动态设置图片的高度和宽度
- 实时视频直播客户端技术盘点:Native、HTML5、WebRTC、微信小程序
- 微信公众号支付(JSAPI)对接备忘
- cocos2dx游戏开发——微信打飞机学习笔记(十)——碰撞检测的搭建
- 微信小程序(登录、分享、支付)
- 微信小程序(原生)——去掉原生导航栏
- WordPress对接微信小程序遇到的问题
- 微信小程序基本语法介绍
- 基于SpringCloud+redis+Springsecurity实现的微信小程序外卖系统
- 【微信小程序】选择宝——选择困难症的拯救者