5***@qq.com
5***@qq.com
  • 发布:2018-04-08 10:06
  • 更新:2018-05-02 17:51
  • 阅读:3983

mui-app,第三方登录QQ授权登录获取不到openid

分类:MUI

<div class="wx_logo">
<img src="img/wxloggin.png" onclick="authLogin('weixin')" />
<img src="img/qqloggin.png" onclick="authLogin('qq')" />
</div>

var auths = null;
// 监听plusready事件
document.addEventListener("plusready", function() {
// 扩展API加载完毕,现在可以正常调用扩展API
plus.oauth.getServices(function(services) {
auths = services;
}, function(e) {
mui.toast("获取分享服务列表失败:" + e.message + " - " + e.code);
});
}, false);
// 登录操作
function authLogin(type) {
document.getElementById('my_loading_id').style.display = "block";
document.getElementById('login_id').style.display = "none";
var s;
for (var i = 0; i < auths.length; i++) {
if (auths[i].id == type) {
s = auths[i];
break;
}
}
if(!s.authResult) {
s.login(function(e) {
mui.toast("登录认证成功!");
authUserInfo(type);
}, function(e) {
mui.toast("登录认证失败!");
});
} else {
mui.toast("已经登录认证!");
}
}
// 获取登录用户信息操作
function authUserInfo(type) {
var s;
for (var i = 0; i < auths.length; i++) {
if (auths[i].id == type) {
s = auths[i];
break;
}
}
if(!s.authResult) {
mui.toast("未登录授权!");
} else {
s.getUserInfo(function(e) {
console.log("获取用户信息成功:" + JSON.stringify(s.userInfo));
var jsonObj = s.userInfo;
wxlogin(type,jsonObj);
authLogout();
}, function(e) {
console.log("获取用户信息失败:" + e.message + " - " + e.code);
});
}
}

2018-04-08 10:06 1 条评论 负责人:无 分享
已邀请:
6***@qq.com

6***@qq.com

怎么解决的,老哥跪求解决方案

该问题目前已经被锁定, 无法添加新回复