小程序登录流程
获取用户头像,昵称信息(首次需要首次)
<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
实现鉴权
小程序登录流程
最新推荐文章于 2024-05-21 01:00:00 发布