getAuthServices(fun: Function) {
let plus = window['plus'];
plus.oauth.getServices(function (services) {
fun(services);
}, function (e) {
console.log("获取分享服务列表失败:" + e.message + " - " + e.code);
return null;
});
}
getAuthServices((auths) => {
var s = auths["weixin"];
if (s) {
// 获取登录操作结果
s.authorize(async (event) => {
console.log("获取code成功:" + event.code);
try {
//客户端发送code给服务器,进行验证
let result = await NetMgr.Instance.httpGet({
code: event.code,
shareplayerid: "null"
}, Router.WeixinOpenPlatform);
//继续登录流程
} catch (error) {
}
}, (e) => {
console.log("获取code失败:" + e.message + " - " + e.code);
}, { scope: 'snsapi_userinfo', appid: 'wx0036105ea0a7417b' })
} else {
console.log("不支持微信登录");
}
})
1 个回复
9***@qq.com (作者) - ----
后来发现这个问题其实是使用了默认的调试基座造成的。即使在XHuilder中填写了微信的appid没有正式打包前实际用的还是默认基座的appid,导致获取的code与服务器对应不上。