<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort() + path+"/";
	request.setAttribute("contextPath", basePath);
	
	String redirectUrl= request.getParameter("redirectUrl");
	request.setAttribute("redirectUrl", redirectUrl);
%>
<!DOCTYPE html>
<html lang="en">
<head>
	<base href="<%=basePath%>">
	<meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <title>登录</title>
    <c:set var="path" value="${pageContext.request.contextPath}" />
    <script src="${contextPath }app/lib/flexible.js"></script>
    <script type="text/javascript" src="${contextPath }res/js/jquery.min.js"></script>
    <script type="text/javascript" src="${contextPath }res/js/layer/layer.min.js"></script>
    <script type="text/javascript" src="${contextPath }app/js/aes.js"></script>
    <link rel="stylesheet" href="${contextPath }app/lib/flexible.css">
	<link rel="stylesheet" href="${contextPath }app/css/basem.css">
	<link rel="stylesheet" href="${contextPath }app/css/logome.css">
	<script type="text/javascript"> 
	$(function(){
 
		$('#btnLogin').click(function(){ 
			var username=$("input[name='username']").val();
			var password=$("input[name='password']").val();
			
			if(username=='' || password== '' ){
				layer.msg("用户名和密码必须输入！");
				return false;
			}
			$.post('${contextPath}web/mgmUserCtl/ajaxLogin.cs', {
				"username" : username,
				"password" : password  
			}, function(data) {
				var datas=eval(data.data);
				if (data.ret == 1) {
					//集团用户
					if(datas.type=="0"){
						//首次登陆跳转手机绑定
						if(datas.firstLogin=="0"){
							window.location.href = '${contextPath}web/mgmUserCtl/phone_bang.cs?userId='+datas.id;
						}else{
							window.location.href = '${contextPath}web/mgmUserCtl/index.cs?userId='+datas.id;
						}
					//非集团用户
					}else{
						//首次身份认证
						if(datas.idnumber=="" || datas.idnumber==null){
							window.location.href = '${contextPath}web/mgmUserCtl/info_personal.cs?userId='+datas.id+'&phone='+datas.phone;
						}else{
							window.location.href = '${contextPath}web/mgmUserCtl/index.cs?userId='+datas.id;
						}
					}
				}else{
					layer.msg(data.msg);
				}
			}, "json");
		});
	}); 
	</script>
</head>

<body>
	<div class="logbox">
		<div class="safe">
			<div class="logobg">
				<img class="logo" src="${contextPath }app/img/logo@2x.png" alt="">
				<h2>欢迎您！</h2>
				<%-- <form id="loginForm" action="<%=basePath%>web/mgmUserCtl/ajaxLogin.cs" method="post"> --%>
					<ul class="logul">
						<li>
							<div><img class="logicon" src="${contextPath }app/img/iphone@2x.png" alt=""><span>账号</span></div>
							<input name="username" type="text" placeholder="请输入工号或手机号">
						</li>
						<li>
							<div><img class="logicon" src="${contextPath }app/img/pw@2x.png" alt=""><span>密码</span></div>
							<input name="password" id="password" type="password" placeholder="请输入密码">
						</li>
					</ul>
					<div id="button">
							<a  class="redbtn" href="javascript:void(0);" id="btnLogin">登录</a>
					</div>
					<div class="loga">
						<a class="left" href="${contextPath }app/login/forget.jsp">忘记密码</a>
						<a class="right" href="${contextPath }app/login/register.jsp">立即注册</a>
					</div>
				<!-- </form> -->
			</div> 
		</div>
	</div>
</body>
</html>