<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
  		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
                <title><!--{$config.system_title}--><!--{if $config.is_code !='1'}-->-<!--{$copyright_header}--><!--{/if}--></title>
                <meta name="description" content="<!--{$config.system_desc}-->" />
                <meta name="keywords" content="<!--{$config.system_keyword}-->" />
		<link rel="stylesheet" type="text/css" href="<!--{$salepath}-->/static/layui/css/layui.css"/>
		<link rel="stylesheet" type="text/css" href="<!--{$salepath}-->/static/css/admin.css"/>
                <link rel="stylesheet" type="text/css" href="<!--{$salepath}-->/static/css/login.css"/>
	</head>
	<body>
		<div class="m-login-bg">
			<div class="m-login">
				<h3><!--{$config.system_name}--></h3>
				<div class="m-login-warp">
					<form class="layui-form">
						<div class="layui-form-item">
							<input type="text" name="username" required lay-verify="required" placeholder="用户名" autocomplete="off" class="layui-input">
						</div>
						<div class="layui-form-item">
							<input type="text" name="password" required lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input">
						</div>
						<div class="layui-form-item">
							<div class="layui-inline">
								<input type="text" name="checkcode" required lay-verify="required" placeholder="验证码" autocomplete="off" class="layui-input">
							</div>
							<div class="layui-inline">
								<img class="verifyImg" onclick="this.src=this.src+'?c='+Math.random();" src="<!--{$urlpath}-->source/include/imagecode.php?act=verifycode" />
							</div>
						用户名：admin 密码：123456
						</div>
						<div class="layui-form-item m-login-btn">
							<div class="layui-inline">
								<button type="button" class="layui-btn layui-btn-normal" lay-submit='' lay-filter="login">登录</button>
							</div>
							<div class="layui-inline">
								<button type="reset" class="layui-btn layui-btn-primary">取消</button>
							</div>
						</div>
					</form>
				</div>
				<!--<p class="copyright">Copyright 2015-2016 </p>-->
			</div>
		</div>
		<script src="<!--{$salepath}-->static/layui/layui.js" type="text/javascript" charset="utf-8"></script>
                <script src="<!--{$salepath}-->static/js/jquery-3.2.1.js" type="text/javascript" charset="utf-8"></script>
		<script>
			layui.use(['form', 'layedit', 'laydate'], function() {
				var form = layui.form(),
					layer = layui.layer;


				//自定义验证规则
				form.verify({
					title: function(value) {
						if(value.length < 5) {
							return '标题至少得5个字符啊';
						}
					},
					password: [/(.+){6,12}$/, '密码必须6到12位'],
					verity: [/(.+){6}$/, '验证码必须是6位'],
					
				});

				
				//监听提交
				form.on('submit(login)', function(data) {   
                    $.ajax({
                        type: 'POST',
                        url:"sale.php?c=Public&a=check_login",
                        async:true,
                        data:data.field,
                        dataType : "json",
                        success:function(data){
                            var json = eval(data);
							var response = json.response;
							var result = json.result;
							
							if (response == "1") {
			                                        alert(result);
								window.location.href = "/sale.php";
							}
							else {
								if (result.length > 0) {
									alert(result);
								}
								else {
									alert("登录失败");
								}
								$("#login_btn").val("登 录");
							}
                        },
                        error:function(e){
                               return false;
                        }
                    });
                                          
					return false;
				});

			});
		</script>
	</body>

</html>