小程序登录流程
获取用户头像,昵称信息(首次需要首次)
<button open-type="getUserInfo" bindgetuserinfo="getUserInfo">获取图像信</button>// 单击手动授权 getUserInfo(e){ console.log(e) this.setData({userInfo:e.detail.userInfo}) },api自动
// 自动授权按钮 onLoad: function (options) { var that=this; wx.getUserInfo({ complete:(res)=>{ console.log(res,"api") this.setData({userInfo:res.userInfo}) } }) that.getOpenId(); },
code 临时的code
// 获取用户唯一id getOpenId(){ wx.login({ complete:(res)=>{ // code用户加密的临时id console.log(res.code) // 去后端通过code小程序+小程序密码 可以到微信获取openid // openid用户唯一标识 } }) },res.code临时的code
扩展:后端 用openid
(用户唯一的识别id)
code
前端给的
appid
小程序id
AppSecret
小程序密码
向微信后端 获取openid
后端登录与注册
都只需要,一个code,后端自己拿到openid
实现鉴权
小程序登录流程
最新推荐文章于 2025-06-10 18:45:00 发布
本文详细介绍了小程序登录的具体流程,包括用户授权获取头像和昵称信息的方法,利用API实现自动授权的过程,以及如何通过code获取用户的唯一标识openid,实现用户鉴权。
1664

被折叠的 条评论
为什么被折叠?



