123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
- <title>后台登录</title>
- <link rel="stylesheet" href="__JS__/layui/css/layui.css">
- <link rel="stylesheet" href="__CSS__/admin.css">
- <link rel="stylesheet" href="__CSS__/login.css">
- <!--<link id="layuicss-layer" rel="stylesheet" href="__CSS__/layer.css" media="all">-->
- <script src="http://static.geetest.com/static/tools/gt.js"></script>
- <script>
- /*保证登录页面是顶级页面*/
- if(window.top!==window.self){window.top.location=window.location};
- </script>
- </head>
- <body layadmin-themealias="default">
- <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" >
- <div class="layadmin-user-login-main">
- <div class="layadmin-user-login-box layadmin-user-login-header">
- <h2>layui后台</h2>
- <p>后台管理系统</p>
- </div>
- <div class="layadmin-user-login-box layadmin-user-login-body">
- <form class="layui-form" onsubmit="return false;">
- <div class="layui-form-item">
- <label class="layadmin-user-login-icon layui-icon layui-icon-username"
- for="LAY-user-login-username"></label>
- <input type="text" name="username" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input">
- </div>
- <div class="layui-form-item">
- <label class="layadmin-user-login-icon layui-icon layui-icon-password"
- for="LAY-user-login-password"></label>
- <input type="password" name="password" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input">
- </div>
- <div class="layui-form-item">
- <div class="layui-row">
- {if condition="config('verify_type') eq 1"}
- <div class="layui-col-xs7">
- <label class="layadmin-user-login-icon layui-icon layui-icon-vercode"
- for="LAY-user-login-vercode"></label>
- <input type="text" name="vercode" id="LAY-user-login-vercode" lay-verify="required" placeholder="图形验证码" class="layui-input">
- </div>
- <div class="layui-col-xs5">
- <div style="margin-left: 10px;">
- <img src="{:url('checkVerify')}" onclick="javascript:this.src='{:url('checkVerify')}?tm='+Math.random();" style="float:right;cursor: pointer" id="verify"/>
- </div>
- </div>
- {elseif condition="config('verify_type') eq 2"/}
- <div class="layui-col-xs12" id="geeFa">
- <div id="embed-captcha"></div>
- </div>
- <p id="wait">正在加载验证码.... <i class="layui-icon layui-icon-loading-1 layui-icon layui-anim layui-anim-rotate layui-anim-loop"></i></p>
- {/if}
- </div>
- </div>
- <div class="layui-form-item" style="margin-bottom: 20px;">
- <!--<input type="checkbox" name="remember" lay-skin="primary" title="记住密码">-->
- <!--<div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>记住密码</span><i-->
- <!--class="layui-icon layui-icon-ok"></i></div>-->
- <!--<a href="javascript:;" class="layadmin-user-jump-change layadmin-link" style="margin-top: 7px;">忘记密码?</a>-->
- </div>
- <div class="layui-form-item">
- <button class="layui-btn layui-btn-fluid" lay-submit="" lay-filter="LAY-login">登 录</button>
- </div>
- </form>
- </div>
- </div>
- <div class="layui-trans layadmin-user-login-footer">
- <p>© 2018 <a href="http://www.layui.com/" target="_blank">layui.com</a></p>
- </div>
- </div>
- <script src="__JS__/layui/layui.all.js"></script>
- <script src="__JS__/jquery.min.js"></script>
- <script src="__JS__/wk.js"></script>
- <script>
- $('#LAY-user-login-username').focus();
- var handlerEmbed = function (captchaObj) {
- $("#embed-submit").click(function (e) {
- var validate = captchaObj.getValidate();
- if (!validate) {
- $("#notice")[0].className = "show";
- setTimeout(function () {
- $("#notice")[0].className = "hide";
- }, 2000);
- e.preventDefault();
- }
- });
- // 将验证码加到id为captcha的元素里
- captchaObj.appendTo("#embed-captcha");
- captchaObj.onReady(function () {
- $("#wait")[0].className = "layui-hide";
- });
- // 更多接口参考:http://www.geetest.com/install/sections/idx-client-sdk.html
- };
- var geeCheck = function(){
- $.ajax({
- // 获取id,challenge,success(是否启用failback)
- url: "{:url('getVerify',array('t'=>time()))}", // 加随机数防止缓存
- type: "get",
- dataType: "json",
- success: function (data) {
- // 使用initGeetest接口
- // 参数1:配置参数
- // 参数2:回调,回调的第一个参数验证码对象,之后可以使用它做appendTo之类的事件
- initGeetest({
- gt: data.gt,
- challenge: data.challenge,
- product: "float", // 产品形式,包括:float,embed,popup。注意只对PC版验证码有效
- offline: !data.success, // 表示用户后台检测极验服务器是否宕机,一般不需要关注
- width:"100%",
- }, handlerEmbed);
- }
- });
- }
- if('{:config('verify_type')}' == 2){
- geeCheck();
- }
- layui.use('form', function(){
- var form = layui.form;
- //监听提交
- form.on('submit(LAY-login)', function(data){
- $(".layui-btn").addClass('layui-disabled').attr('disabled','disabled').html('登录中... <i class="layui-icon layui-icon-loading-1 layui-icon layui-anim layui-anim-rotate layui-anim-loop"></i>');
- $.ajax({
- url:"{:url('doLogin')}",
- type:'post',
- dataType:'json',
- data:data.field,
- success:function(res){
- if(res.code == 1){
- setTimeout(function(){
- location.href=res.url;
- },1500);
- }else{
- layer.msg(res.msg,{icon:2,time:1500,anim: 6},function(index){
- if('{:config('verify_type')}' == 2 && res.code != -3){
- $("#wait").removeClass('layui-hide');
- $('#embed-captcha').remove();
- $('#geeFa').append('<div id="embed-captcha"></div>')
- geeCheck();
- }else if('{:config('verify_type')}' == 1){
- $('#verify').attr("src","{:url('checkVerify')}?tm="+Math.random());
- }
- switch(res.code)
- {
- case -1:
- $('#LAY-user-login-username').focus();
- break;
- case -2:
- $('#LAY-user-login-password').focus();
- break;
- case -4:
- $('#LAY-user-login-vercode').focus();
- break;
- }
- layer.close(index);
- })
- $(".layui-btn").removeClass('layui-disabled').removeAttr('disabled').text("登 录");
- return false;
- }
- }
- ,error:function(event, xhr, options, exc){
- switch (event.status) {
- case 403:
- wk.error('403:禁止访问...');
- break;
- case 404:
- wk.error('404:请求服务器出错...');
- break;
- case 500:
- wk.error('500:服务器错误...');
- break;
- }
- $(".layui-btn").removeClass('layui-disabled').removeAttr('disabled').text("登 录");
- }
- })
- });
- });
- //防止页面后退
- history.pushState(null, null, document.URL);
- window.addEventListener('popstate', function () {
- history.pushState(null, null, document.URL);
- });
- </script>
- </body>
- </html>
|