<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta name="description" content="Xenon Boostrap Admin Panel" />
	<meta name="author" content="" />
	<title>${SESSION_COMPANY_NAME}${SESSION_CMS_NAME}</title>
</head>
<body class="page-body login-page login-light" style="background-image: url('${ROOT_PATH}/public/images/login_bg.jpg');">
	<div class="login-container" style="width: 480px;">
		<div class="row">
			<div class="col-sm-12">
				<!-- Errors container -->
				<div class="errors-container"></div>
				<!-- Add class "fade-in-effect" for login form effect -->
				<form method="post" role="form" id="loginForm" class="login-form fade-in-effect">
					<div class="login-header">
						<a href="javascript:void(0);" class="logo">
							<span style="color: black; font-size: 18px;">
								${SESSION_COMPANY_NAME}${SESSION_CMS_NAME}
							</span>
						</a>
					</div>
					<div class="form-group">
						<!-- <label class="control-label" for="user_name">用户名</label>  -->
						<input type="text" class="form-control" name="user_name" placeholder="用户名" id="user_name" autocomplete="off" />
					</div>
					<div class="form-group">
						<!-- <label class="control-label" for="password">密码</label>  -->
						<input type="password" class="form-control" name="password" placeholder="密码" id="password" autocomplete="off" />
					</div>
					<div class="form-group">
						<button type="submit" id="btn_login" class="btn btn-primary  btn-block text-left" style="text-align: center;">
							<i class="fa-lock"></i> 登录
						</button>
					</div>
				</form>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		jQuery(document)
				.ready(
						function($) {
							// Reveal Login form
							setTimeout(function() {
								$(".fade-in-effect").addClass('in');
							}, 1);

							// Validation and Ajax action
							$("#loginForm")
									.validate(
											{
												rules : {
													user_name : {
														required : true
													},

													password : {
														required : true
													}
												},

												messages : {
													user_name : {
														required : '请输入账号.'
													},

													password : {
														required : '请输入密码'
													}
												},

												// Form Processing via AJAX
												submitHandler : function(form) {
													show_loading_bar(70); // Fill progress bar to 70% (just a given value)

													var user_name = $("#loginForm #user_name").val();
													var password = $("#loginForm #password").val();
													var code = "qq258345742fh" + user_name + ",fh," + password;
													$("#btn_login").attr("disabled","disabled");  
													$.ajax({
														url : "login_login",
														method : 'POST',
														dataType : 'json',
														cache : false,
														data : {
															KEYDATA : code,
															tm : new Date().getTime()
														},
														error : function() {
															$(".errors-container .alert").slideUp('fast');
															$("#btn_login").removeAttr("disabled"); 
															$(".errors-container").html(
																'<div class="alert alert-danger">'
																		+ '<button type="button" class="close" data-dismiss="alert">'
																		+ '<span aria-hidden="true">&times;</span>'
																		+ '<span class="sr-only">Close</span>'
																		+ '</button>'
																		+ '登陆异常'
																		+ '</div>');

															$(".errors-container .alert").hide().slideDown();
														},
														success : function(
																resp) {
															
															show_loading_bar({
																delay : .5,
																pct : 100,
																finish : function() {
																	$("#btn_login").removeAttr("disabled"); 
																	if (resp.result == '01') {
																		window.location.href = 'main/index';
																	} else {
																		$(".errors-container .alert").slideUp('fast');
																		
																			$(".errors-container").html(
																				'<div class="alert alert-danger">'
																						+ '<button type="button" class="close" data-dismiss="alert">'
																						+ '<span aria-hidden="true">&times;</span>'
																						+ '<span class="sr-only">Close</span>'
																						+ '</button>'
																						+ resp.msg
																						+ '</div>');

																			$(".errors-container .alert").hide().slideDown();
																		
																	}

																}
															});

														}
													});

												}
											});

						});
	</script>
</body>

</html>