<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/9/11
  Time: 12:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    session.removeAttribute("s_btn");
    session.removeAttribute("s_have_btn");
    session.removeAttribute("session_login_id");
    session.removeAttribute("session_login_name");
    String path = request.getContextPath() + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <title>值班管理系统</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="<%=path%>/js/html5shiv.js"></script>
    <script type="text/javascript" src="<%=path%>/js/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="<%=path%>css/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="<%=path%>css/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="<%=path%>js/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="<%=path%>css/h-ui.admin/skin/green/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="<%=path%>css/h-ui.admin/css/style.css"/>
    <!--_footer 作为公共模版分离出去-->
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/css/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/css/h-ui.admin/js/H-ui.admin.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/My97DatePicker/4.8/WdatePicker.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/datatables/1.10.0/jquery.dataTables.min.js"></script>

</head>
<body>
<link href="<%=request.getContextPath()%>/css/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css"/>

<div class="loginWraper">
    <div id="loginform" class="loginBox">
        <form class="form form-horizontal" id="form-admin-add">
            <input type="hidden" name="s_id" value="<%=session.getId()%>"/>
            <input type="hidden" name="action" value="login"/>
            <div class="row cl">
                <label class="form-label col-xs-10" style="font-size:30px;">值班管理系统</label>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
                <div class="formControls col-xs-8">
                    <input name="login_id" type="text" placeholder="工号" class="input-text size-L">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60e;</i></label>
                <div class="formControls col-xs-8">
                    <input id="" name="passwd" type="password" placeholder="密码" class="input-text size-L">
                </div>
            </div>
            <div class="row cl">
                <div class="formControls col-xs-7 col-xs-offset-3" style="text-align:right">
                    <input onclick="loginForm()" type="button" class="btn btn-success radius size-L" value="&nbsp;登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;"/>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    function iGetInnerText(testStr) {
        var resultStr = testStr.replace(/\ +/g, ""); //去掉空格
        resultStr = testStr.replace(/[ ]/g, "");    //去掉空格
        resultStr = testStr.replace(/[\r\n]/g, ""); //去掉回车换行
        return resultStr;
    }

    function loginForm() {

        $.ajax({
            type: "POST",
            url: "./login_check_ztj.jsp",
            data: $('#form-admin-add').serialize(),
            success: function (msg) {
                msg = iGetInnerText(msg);
                if (msg.indexOf("success") >= 0) {
                    var tablename=msg.substring(msg.indexOf(",")+1);
                    if(tablename=='zb_bgs_user'){
                        window.location.href = "./home_bgs-t.jsp";
                    }else{
                        window.location.href = "./home_ztj-t.jsp";
                    }

                } else {
                    layer.msg('登录失败,' + msg, {
                        icon: 5,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function () {
                    });
                }
            }
        });
    }

    $(document).keyup(function (event) {
        if (event.keyCode == 13) {
            loginForm();
        }
    });
</script>
</body>
</html>