<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String basePath = request.getContextPath();
    String resourcePath = basePath + "/resource";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>城市运行监测预警</title>
    <jsp:include page="../../../common/admin/head_css.jsp"></jsp:include>
</head>
<body class="blue-bg">
<div class="loginColumns text-center">
    <div class="login-top">
        <img alt="image"  src="<%=resourcePath%>/images/logo.png" />
    </div>
    <div class="login-middle ibox-content">
        <h2><strong>城市运行监测预警</strong></h2>
        <h3>登录</h3>
        <form id="formLogin" action="<%=basePath%>/admin/account/login.action">
            <div class="form-group">
                <input type="text" id="username" name="username" class="form-control" placeholder="用户名" />
                <span class="field-validation-valid help-block"></span>
            </div>
            <div class="form-group">
                <input type="password" id="password" name="password" class="form-control" placeholder="密码" />
                <span class="field-validation-valid help-block"></span>
            </div>
            <button id="btnLogin" type="button" class="btn btn-primary full-width">登录</button>
        </form>
        <p>忘记密码请联系管理员</p>
    </div>
    <div class="login-bottom">
        <a href="http://www.ges-china.com" target="_blank">衡水市建设投资集团有限公司</a> 版权所有 <br/>All Rights Reserved 2018<br/>
        <a href="http://www.lightinit.com" target="_blank">衡水智慧城市建设有限公司</a> 技术支持
    </div>
</div>
<script type="text/javascript" src="<%=basePath %>/resource/plugins/jquery/jquery-2.1.4.min.js"></script>
<link  rel="stylesheet" type="text/css" href="<%=basePath%>/resource/plugins/jquery-toast/jquery.toast.min.css">
<script type="text/javascript" src="<%=basePath %>/resource/plugins/jquery-toast/jquery.toast.min.js"></script>
<script type="text/javascript">
    $(function(){
        $("#btnLogin").bind("click",function(){
            var win = null;
            $.ajax({
                type:"post",//请求方式
                url:"<%=basePath %>/admin/account/login.action",//发送请求地址
                timeout:30000,//超时时间：30秒
                dataType:"json",//设置返回数据的格式
                data: {username:$("#username").val(),password:$("#password").val()},
                //请求成功后的回调函数 data为json格式
                beforeSend:function(XMLHttpRequest){
                    $.toast({text: '正在校验用户信息...',position:'mid-center',allowToastClose: false,loader: false});
                },
                success:function(data){
                    if(data.status==2001){
                        $.toast({text: '授权成功,正在跳转...',position:'mid-center',allowToastClose: false,loader: false,afterHidden: function () {
                            window.location.href ="<%=basePath%>/admin/";
                        }});
                    }else{
                        $.toast({text: data.message,position:'mid-center',allowToastClose: false,loader: false});
                    }
                },
                complete:function(XMLHttpRequest, textStatus){

                },
                //请求出错的处理
                error:function(XMLHttpRequest, textStatus, errorThrown){
                    $.toast({text: '请求出错',position:'mid-center',allowToastClose: false,loader: false});
                }
            });
        });

        $("#formLogin input").keypress(function (event) {
            if (event.keyCode == 13 || event.switch == 13){
                $("#btnLogin").click();
            }
        });
    });
</script>
</body>
</html>