<%@page import="com.iamberry.wechat.autiXSS.XSSHandler"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/html5.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/respond.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/PIE_IE678.js"></script>
<![endif]-->
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.login.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/css/style.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>后台登录 - 爱贝源微商场管理系统</title>
<meta name="keywords" content="水时代微商场管理系统">
</head>
<body>

	<%
		String loginName = (String) request.getAttribute("loginName");
		if (loginName == null) {
			loginName = "";
		} else {
			loginName = XSSHandler.handle(loginName, true, false, false);
		}
	%>
	<input type="hidden" id="TenantId" name="TenantId" value="" />
	<div class="header"></div>
	<div class="loginWraper">
		<div id="loginform" class="loginBox bk-gray radius box-shadow">
			<form onsubmit="checkLogin()" class="form form-horizontal" id="login-from" action="${pageContext.request.contextPath }/login" method="post">
				<input type="hidden"
					value="<%=session.getAttribute("loginToken")%>" name="loginToken">
				<c:if test="${!empty isShowDiv}">
				<c:choose>
					<c:when test="${isShowDiv == true }">
						<div id="errorDiv"
							style="margin-left: 20%; width: 60%; height: 55px; line-height: 55px; margin-top: 10px; padding: 0px 12px; border: 1px solid rgb(235, 204, 209); background-color: rgb(242, 222, 222);" class=".Validform_wrong">
							<span id="errinfo" style="color: #A94442; font-size: 13px;">${divText }</span>
							<span id="closediv"
								style="width: 20px; height: 20px; text-align: center; float: right; cursor: pointer;">x</span>
						</div>
					</c:when>
					<c:otherwise>
						<div id="errorDiv"
							style="display: hidden; margin-left: 20%; width: 60%; height: 55px; line-height: 55px; margin-top: 10px; padding: 0px 12px; border: 1px solid rgb(235, 204, 209); background-color: rgb(242, 222, 222);">
							<span id="errinfo" style="color: #A94442; font-size: 13px;"></span>
							<span id="closediv"
								style="width: 20px; height: 20px; text-align: center; float: right; cursor: pointer;">x</span>
						</div>
					</c:otherwise>
				</c:choose>
				</c:if>
				<div class="row cl">
					<label class="form-label col-3"><i class="Hui-iconfont">&#xe60d;</i></label>
					<div class="formControls col-8">
						<input id="adminLoginName" autocomplete="off" name="adminLoginName" type="text" value="<%= loginName %>" placeholder="请输入账号" class="input-text size-L">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-3"><i class="Hui-iconfont">&#xe60e;</i></label>
					<div class="formControls col-8">
						<input id="adminLoginPwd" autocomplete="off" name="adminLoginPwd" type="password" placeholder="请输入密码" class="input-text size-L">
					</div>
				</div>
				<div class="row cl">
					<div class="formControls col-8 col-offset-3">
						<input class="input-text size-L" autocomplete="off" id="verifyCode" name="verifyCode"
							type="text" placeholder="验证码"
							onblur="if(this.value==''){this.value='验证码:'}"
							onclick="if(this.value=='验证码:'){this.value='';}" value="验证码:"
							style="width: 150px;"> <img
							src="${pageContext.request.contextPath }/verify.image"
							id="verifyCode"> <a id="kanbuq" href="javascript:;">看不清，换一张</a>
					</div>
				</div>
				<div class="row">
					<div class="formControls" style="margin: 0 auto;text-align: center;">
						<input name="" id="login-btn-id" type="button" class="btn btn-iamberry" value="立即登录"> 
					</div>
				</div>
			</form>
		</div>
	</div>
	<div class="footer">Copyright 深圳爱贝源科技有限公司</div>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/common/admin/lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/common/js/utils/md5.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#kanbuq").click(function() {
				$("#verifyCode").attr("src", "${pageContext.request.contextPath }/verify.image?date=" + new Date().getTime());
				return false;//取消动作
			});
			$("#closediv").click(function() {
				$("#errorDiv").hide(100);
			});
			$("#adminLoginName").blur(function() {
				var adminLoginName = $(this).val();
				var re = /^[a-zA-z]\w{5,15}$/;
				if (!(re.test(adminLoginName))) {
					$(this).select();
					$("#errorDiv").show(100);
					$("#errinfo").html("用户名必须以字母、数字、下划线组成，字母开头，6-16位");
				}
			});
			$("#adminLoginPwd").blur(function() {
				var adminLoginPwd = $(this).val();
				var re = /^[a-zA-z]\w{5,15}$/;
				if (!(re.test(adminLoginPwd))) {
					$(this).select();
					$("#errorDiv").show(100);
					$("#errinfo").html("密码必须以字母、数字、下划线组成，字母开头，6-16位");
				}
			});
			$("#verifyCode").blur(function() {
				var verifyCode = $(this).val();
				if (verifyCode.length != 6) {
					$(this).select();
					$("#errorDiv").show(100);
					$("#errinfo").html("验证码必须必须为6位");
				}
			});
			$("#login-btn-id").click(function() {
				if(checkLogin()) {
					$("#login-from").submit();
				}
			});
		});

		function checkLogin() {
			var adminLoginName = $("#adminLoginName").val();
			var re = /^[a-zA-z]\w{5,15}$/;
			if (!(re.test(adminLoginName))) {
				$("#adminLoginName").select();
				$("#errorDiv").show(100);
				$("#errinfo").html("用户名必须以字母、数字、下划线组成，字母开头，6-16位");
				return false;
			}
			var adminLoginPwd = $("#adminLoginPwd").val();
			if (!(re.test(adminLoginPwd))) {
				$("#adminLoginPwd").select();
				$("#errorDiv").show(100);
				$("#errinfo").html("密码必须以字母、数字、下划线组成，字母开头，6-16位");
				return false;
			}
			var verifyCode = $("#verifyCode").val();
			if (verifyCode.length != 6) {
				$("#verifyCode").select();
				$("#errorDiv").show(100);
				$("#errinfo").html("验证码必须必须为6位");
				return false;
			}
			$("#adminLoginPwd").val(hex_md5(adminLoginPwd));
			return true;
		}
	</script>
</body>
</html>