<%@ page language="java" contentType="text/html;charset=UTF-8" trimDirectiveWhitespaces="true"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fastboot" prefix="fb"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<c:set var="base" value="${pageContext.request.contextPath}" />
<!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, maximum-scale=1">
<title><spring:message code="login"/> - </title>
<!--  -->
<link href="${base}/static/js/adminlte/adminlte.min.css" rel="stylesheet" />
<link href="${base}/static/js/layuiadmin/layuiadmin/style/admin.css" rel="stylesheet" />
<link href="${base}/static/css/ionicons/5.0.1/collection/components/icon/icon.min.css" rel="stylesheet" />
<link href="${base}/static/js/layuiadmin/layuiadmin/layui/css/layui.css" rel="stylesheet" />
<link href="${base}/static/nprogress/0.2.0/nprogress.min.css" rel="stylesheet" />
<!--  -->
	<script src="${base}/static/js/layuiadmin/layuiadmin/layui/layui.js"></script>
	<script src="${base}/static/jquery/2.2.1/jquery.min.js"></script>
	<script src="${base}/static/html5shiv/r29/html5.min.js"></script>
	<script src="${base}/static/respond.js/1.4.2/respond.min.js"></script>
	<script src="${base}/static/nprogress/0.2.0/nprogress.min.js"></script>
	<script src="${base}/static/js/adminlte/adminlte.min.js"></script>
<!--  -->
<script src="${base}/static/js/adm/adm.js"></script>
<script src="${base}/static/js/adm/killie.min.js"></script>
<!--  -->
<script type="text/javascript">
	NProgress.configure({
		speed : 500,
		showSpinner : false
	});
	$().ready(function() {
		NProgress.start();
	});
	$(window).load(function() {
		NProgress.done();
	});
</script>
<script type="text/javascript">
	layui.use([ 'tool', 'sdvy', 'form' ], function() {
		// 操作对象
		var $ = layui.jquery, tool = layui.tool, form = layui.form, sdvy = layui.sdvy, layer = layui.layer;
		//
		var slider = sdvy.render({
			text : '<spring:message code="login.drag"/>',
			elem : '#slider',
			isAutoVerify : false,//关闭自动验证
			onOk : function() {//当验证通过回调
				console.log("ok");
			}
		});
		//监听提交【管理员】
		form.on('submit(login)', function() {
			if (!slider.isOk()) {
				layer.msg('<spring:message code="login.drag"/>');
			} else {
				tool.post('${base}/admin/login', $("#inputForm").serializeArray(), function(data) {
					if (data.code === 0) {
						layer.msg(data.msg, {
							time : 1000
						}, function() {
							window.location.href = data.data;
						});
					} else {
						$('#login-msg').html(_msg);
						slider.reset();
					}
				});
			}
			return false;
		});



		$("#reg").on("click",function(){
			parent.layer.open({
				type : 2,
				title : false,
				content : [ "${base}/reg/input" ],
				shade : 0.1,
				resize : true,
				area : [ '30%', '75%' ],
				closeBtn : 2,
				anim : 0,
				isOutAnim : false,
				scrollbar : false,
				btnAlign : 'r',
				btn : [ '<spring:message code="submit"/>', '<spring:message code="back"/>' ],
				yes : function(index, layero) {
					// 得到iframe页的窗口对象
					// var iframeWin = window[layero.find('iframe')[0]['name']];
					// iframeWin.reset();
					var iframeBody = parent.layer.getChildFrame('body', index);
					iframeBody.find('#submit').click();
				},
				btn2 : function(index, layero) {

				}
			});
		})
	});
</script>
</head>
<body class="hold-transition login-page" >
	<div class="login-box" style="width: 500px;">
		<div class="login-logo"  >农业一张图平台</div>
		<div class="card" style="width: 360px;margin: 0 auto">
			<div class="card-body login-card-body">
				<!-- <p id="login-msg" class="login-box-msg"></p> -->
				<form id="inputForm" class="layui-form">
					<input type="hidden" name="redirect_url" value="${param['redirect_url']}" />
					<div class="input-group mb-3">
						<input type=text name="username" lay-verify="required" lay-verType="tips" placeholder="<spring:message code="account"/>" class="form-control" />
						<div class="input-group-append">
							<div class="input-group-text">
								<i class="layui-icon layui-icon-username"></i>
							</div>
						</div>
					</div>
					<div class="input-group mb-3">
						<input type="password" name="password" lay-verify="required|pass" lay-verType="tips" placeholder="<spring:message code="password"/>" class="form-control" />
						<div class="input-group-append">
							<div class="input-group-text">
								<i class="layui-icon layui-icon-password"></i>
							</div>
						</div>
					</div>
					<div class="social-auth-links text-center mb-3">
						<div class="layui-btn layui-btn-normal layui-btn-fluid" id="slider"></div>
					</div>

					<div class="social-auth-links text-center mb-3">
						<div class="layui-col-xs12" >
							<button id="submit" class="layui-btn layui-btn-normal layui-btn-fluid"  lay-submit lay-filter="login"><spring:message code="login"/></button>
						</div>
					</div>
					<div class="text-center mb-3" >
						<br/><br/>
					</div>
				</form>
			</div>
		</div>
	</div>
</body>

</html>
