1***@qq.com
1***@qq.com
  • 发布:2017-03-11 10:43
  • 更新:2017-03-11 11:42
  • 阅读:2072

第三方微信登录问题

分类:HTML5+

我后台有做一个激活,可是MUI获取微信登录认证的时候,怎么把信息发送到后台,怎么验证?流程呢?

APP微信认证成功后,发送userInfo到后台,后台怎么去验证是否有效?或者是此平台的用户?

2017-03-11 10:43 负责人:无 分享
已邀请:
韩德宇

韩德宇

app.setState(null);
//第三方登录
var authBtns = ['qihoo', 'weixin', 'sinaweibo', 'qq']; //配置业务支持的第三方登录
var auths = {};
var oauthArea = doc.querySelector('.oauth-area');
plus.oauth.getServices(function(services) {
for (var i in services) {
var service = services[i];
auths[service.id] = service;
if (~authBtns.indexOf(service.id)) {
var isInstalled = app.isInstalled(service.id);
var btn = document.createElement('div');
//如果微信未安装,则为不启用状态
btn.setAttribute('class', 'oauth-btn' + (!isInstalled && service.id === 'weixin' ? (' disabled') : ''));
btn.authId = service.id;
btn.style.backgroundImage = 'url("images/' + service.id + '.png")'
oauthArea.appendChild(btn);
}
}
$(oauthArea).on('tap', '.oauth-btn', function() {
if (this.classList.contains('disabled')) {
plus.nativeUI.toast('您尚未安装微信客户端');
return;
}
var auth = auths[this.authId];
var waiting = plus.nativeUI.showWaiting();
auth.login(function() {
waiting.close();
plus.nativeUI.toast("登录认证成功");
auth.getUserInfo(function() {
plus.nativeUI.toast("获取用户信息成功");
var name = auth.userInfo.nickname || auth.userInfo.name;
// 这里写业务逻辑即可 JSON.stringify(auth );->这里包含了所有微信获取回的信息
// HTML代码,可以在Hbuilder 当中新建一个 登录模板 ,login页面有此内容
}, function(e) {
plus.nativeUI.toast("获取用户信息失败:" + e.message);
});
}, function(e) {
waiting.close();
plus.nativeUI.toast("登录认证失败:" + e.message);
});
});
}, function(e) {
oauthArea.style.display = 'none';
plus.nativeUI.toast("获取登录认证失败:" + e.message);
});

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