网页模板中的登录链接和js函数(需要引入cms关键js库)
<a href="___javascript:;dr_wx_login()"> 微信扫码登录 </a>
<script>
function dr_wx_login() {
layer.open({
type: 2,
title: '微信扫码登录',
shadeClose: false,
shade: 0.8,
area: ['380px', '430px'],
content: '/index.php?s=api&c=oauth&m=index&name=wechat&type=login&back='
});
}
</script>新建模板(default是模板目录名可适当的修改):
login_qcode.html代码如下:
<html>
<head>
<title>关注微信公众号</title>
<meta charset="utf-8">
<script src="{THEME_PATH}assets/global/plugins/jquery.min.js?v={CMF_UPDATE_TIME}" type="text/javascript"></script>
<script src="{$THEME_PATH}assets/js/cms.js?v={CMF_UPDATE_TIME}" type="text/javascript"></script>
<style>
a {
height: 16px;
line-height: 16px;
padding: 0 3px;
background-color: #3fa9e2;
text-decoration: none;
color: #fff;
border-radius: 2px;
font-style: inherit;
}
</style>
</head>
<body style="text-align:center">
<img width="90%" src="{$qrcode_url}">
<br><a href="______javascript:dr_weixin_notify();">扫码之后单击登录网站</a>
<script>
function dr_weixin_notify() {
$.ajax({
type : "get",
url : "{$notify_url}",
dataType : "json",
success : function(json){
if (json.code == 1) {
dr_tips(1, '登录成功');
var oss_url = json.data.sso;
// 发送同步登录信息
for(var i in oss_url){
$.ajax({
type: "GET",
url:oss_url[i],
dataType: "jsonp",
success: function(json){ },
error: function(){ }
});
}
if (json.data.url) {
setTimeout("top.location.href = '"+json.data.url+"'", 2000);
} else{
setTimeout("top.location.href = '{$back_url}'", 2000);
}
} else {
dr_tips(0, '没有收到扫码信息');
}
},
error:function(){ }
});
}
</script>
</body>
</html>
上一篇:微信登录失败,错误代码10003
下一篇:没有了
有站啦CMS®万能建站系统基于 CodeIgniter4 高性能的开发框架,支持接入Laravel、ThinkPHP三种内核可选,基于MIT开源许可协议,免费且不限制商业使用。 提供PC + 手机 + 微信 + 小程序 + APP API + 多终端一体化网站技术解决方案。