wx.login({ success: function(res) { //首先获取用户code //res.code wx.request({ url: ‘https://api.weixin.qq.com/sns/jscode2session‘, data: { appid: appid,//填入你的id secret: appsecret,//secret js_code: res.code, grant_type: ‘authorization_code‘ }, method: ‘GET‘, success: function (res) { console.log(res);//openid便会包含在这里 }, fail: function (res) { }, complete: function (res) { }, }) }, fail: function(res) {}, complete: function(res) {}, })
原文地址:https://www.cnblogs.com/MainActivity/p/8607518.html
时间: 2024-10-08 14:23:57