<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>用户登录</title>
		<link rel="stylesheet" href="/public/global/layui/css/layui.css"  media="all">
		<script src="/public/global/jquery/1.11.1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="/public/global/layui/layui.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
	<SCRIPT LANGUAGE="JavaScript">
		document.domain = "{{C('cookie_domain')}}";
	</SCRIPT>
	<style>
		.user_login{
			margin-top: 20px;
		}
		.user_login .layui-form-item{
		    width: 80%;
		}
		.left{
			float: left;
		}
		.w100{
			width: 100px;
		}
		.yzm{
			margin-left: 10px;
			margin-top: 2.5px;
		}
	</style>
	<div class="user_login">
    	<form class="layui-form" action="">
    		<div class="layui-form-item">
    			<label class="layui-form-label">用户名</label>
    			<div class="layui-input-block">
    				<input name="username" lay-verify="username" placeholder="用户名" class="layui-input" type="text">
    			</div>
    		</div>
    		<div class="layui-form-item">
    			<label class="layui-form-label">密码</label>
    			<div class="layui-input-block">
    				<input name="password" lay-verify="password" placeholder="用户密码" class="layui-input" type="password">
    			</div>
    		</div>
    		<if condition="C('LOGIN|LOGIN.login_is_yzm')">
    		<div class="layui-form-item">
    			<label class="layui-form-label">验证码</label>
    			<div class="layui-input-block">
    				<input type="text" placeholder="验证码" class="layui-input w100 left" name="yzm" />
					<img src="/Verification_Code{{C('HTML')}}" alt="点击图片更换验证码" title="点击图片更换验证码" class="yzm left"  onclick="this.src='/Verification_Code{{C('HTML')}}?'+Math.random();"/>
    			</div>
    		</div>
			</if>
    		<div class="layui-form-item">
    			<div class="layui-input-block">
    				<input type="hidden" name="json" value="true" />
    				<input type="hidden" name="step" id="step" value="post" />
    				<button class="layui-btn" lay-submit="" lay-filter="login">登录</button>
    				<a href="/login/index/reg.{{C('html')}}" target="_blank" class="layui-btn">注册</a>
    			</div>
    		</div>
    	</form>
    </div>
    <script>
		var login="";
		layui.use(['form'], function(){
		  	var form = layui.form;
			form.on('submit(login)', function(data) {
				var _data={'json':true}
				var __data=$.extend(_data,data.field);

					$.ajax({
						url:"{{WEBURL}}/login/",
					    type: 'POST',
					    data:__data,
					    dataType: 'json',
					    success: function(data){
					    	//登录不成功
					    	if(data.code !='0'){
								//配置一个透明的询问框
								layer.msg(data.text, {
								    time: 20000, //20s后自动关闭
								    btn: ['确定']
								    ,shadeClose:true
							        ,shade: [0.8, '#393D49']
								});
					    	}else{
					    		parent.location.reload();
					    		var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
								parent.layer.close(index); //再执行关闭        
					    		
					    	}
					    }
					})
					return false;
			})
		});
		var index = parent.layer.getFrameIndex(window.name);
		parent.layer.iframeAuto(index);
	</script>
</body>
</html>