微信小程序获得openid免密登录
{ wx.login({ success: res => { let d = { appid: 'wx111111111111', // 从微信公众平台开发设置中获取 secret: 'sec2222222222' // 从微信公众平台开发设置中获取 }; // 微信官方的获取openid的接口 var wxLoginUrl = 'https://api.weixin.qq.com/sns/jscode2session?appid=' + d.appid +'&secret=' + d.secret + '&js_code=' + res.code + '&grant_type=authorization_code'; wx.request({ url: wxLoginUrl, data: {}, method: 'GET', success: res => { let openid = res.data.openid; this.judgeIsWxlogin(openid); // 向后端发送openid判断是否可以直接用该微信号登陆 } }); } }); }
从微信公众平台开发设置中获取appid和secret:
相关推荐
zuoliangzhu 2020-05-16
蓝色深海 2020-03-24
cbao 2020-05-12
caiyiii 2020-04-29
cdkey 2020-05-04
powderhose 2020-04-25
zengfanpei 2020-04-22
powderhose 2019-12-13
zengfanpei 2019-11-02
CodeAndroid 2019-05-05
资源分享 2019-04-29
newhappy 2019-04-10
czsong 2011-06-13
small 2019-07-01
klshige 2019-06-30
XGQ 2019-06-29