>[danger] ## 三方登录说明
目前插件集成了QQ、微信、微博等主流平台的各设备适配。你可以完全舍弃其他的插件使用一门app插件进行统一登录实现用户同步。提高app的用户体验性。
>[info] PC登录接口(自定义DIV必读)
>
我们封装了`toLogin(type)`的js函数你可以快捷的进行登录,使用说明如下(QQ登录为例)
~~~
<div class="login_box" onclick="toLogin('qq')">
<div class="box_img">
<div class="login_icon iconfont icon-qq qq"></div>
</div>
<div class="box_text">
QQ登录
</div>
</div>
~~~
type的类型为:`qq` 、`pc_wechat`、`sina`,完整的js代码如下:
~~~
//引入jquery的js库
<script src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js"></script>
//引入layer的弹窗(可以不使用)
<script src="https://cdn.staticfile.org/layer/2.3/layer.js"></script>
<script >
//将jquery的$换成jq,否则和discuz的js冲突
var jq = jQuery.noConflict();
//登录函数的实现
function toLogin(type) {
var names = {
qq: "QQ登录",
pc_wechat: "微信登录",
sina: '新浪微博登录'
};
jq.ajax({
url: "./plugin.php?id=yimen_app&s=login/get_oauth_url&type=" + type,
type: "POST",
success: (res) => {
if (res.code == 1) {
//这里可以直接拿到res.url进行跳转,不弹窗
// window.location.href = res.url
//下面是弹窗模式 两者选其一 默认 弹窗登录 体验比较良好
layer.open({
type: 2,
title: names[type],
maxmin: true,
shadeClose: true, //点击遮罩关闭层
area: ['800px', '520px'],
content: res.url
});
}
},
error: (res) => {
//alert(JSON.stringify(res));
}
});
}
</script>
~~~