<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ezEIP_Login.aspx.cs" Inherits="whir_system_ezEIP_Login" %>
<%@ Import Namespace="Whir.Framework" %>

<!DOCTYPE html ">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=9" />
    <title>
        <%=Whir.Framework.AppSettingUtil.GetString("ProductName")%></title>
    <link href="<%=SystemPath %>res/css/blue.css" rel="stylesheet" type="text/css" />
    <link href="<%=SystemPath %>res/assets/css/loader-style.css" rel="stylesheet" type="text/css" />
    <link href="<%=SystemPath %>res/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="<%=SystemPath %>res/assets/css/signin.css" rel="stylesheet" type="text/css" />
    <link href="<%=SystemPath %>res/assets/js/iCheck/flat/all.css" rel="stylesheet" type="text/css" />
    <link href="<%=SystemPath %>Res/assets/js/toastr-master/toastr.css" rel="stylesheet" type="text/css" />
    <link href="<%=SystemPath %>res/css/css_whir_V450.css" rel="stylesheet" type="text/css" />
    <script src='<%=SystemPath %>res/script/jquery-1.7.2.min.js' type="text/javascript"></script>
    <script src="<%=SystemPath %>Res/assets/js/toastr-master/toastr.js" type="text/javascript"></script>
    <script src="<%=SystemPath %>Res/script/Whir/whir.ajax.js" type="text/javascript"></script>
    <script src="<%=SystemPath %>Res/script/Whir/whir.ui.js" type="text/javascript"></script>
</head>
<body>
    <div >
        <div  id="login-wrapper">
            <div class="row">
                <div class="col-md-4 col-md-offset-4">
                    <div id="logo-login">
                        <h1>ezEIP <span><%=AppSettingUtil.GetString("Version")%></span>
                        </h1>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-4 col-md-offset-4">
                    <div class="account-box">
                        <form role="form" id="aspnetForm">
                            <div class="form-group">
                                <label>用户名</label>
                                <input type="text" id="txtUserName" name="UserName" class="form-control">
                            </div>
                            <div class="form-group">
                                <label>密码</label>
                                <input type="password" id="txtPassword" name="Password" onfocus="this.value=''" class="form-control">
                            </div>
                            <div class="form-group" style="display: none" id="divCode">
                                <label>验证码</label>
                                <div class="input-group">
                                    <input type="text" name="Code" id="txtCode" class="form-control" autocomplete="off" maxlength="4" />
                                    <span class="login-checkcode input-group-addon">
                                        <img alt="看不清楚，请点击换一张." src="checkcode.ashx" onclick="this.src=this.src+'?'" />
                                    </span>
                                </div>
                            </div>
                            <div class="checkbox pull-left">
                                <label>
                                    <input type="checkbox" id="Remember" name="Remember" />记住用户名</label>
                            </div>
                            <input type="button" class="btn btn-primary pull-right" id="btnLogin" onclick="submitLogin();" value="登录" />
                        </form>
                        <div>
                            <div class="row"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="space15"></div>
        <div style="text-align: center; margin: 0 auto;">
            <h6 style="color: #fff;">Prower by WHIR
            </h6>
        </div>
    </div>


    <%if (SystemConfig.SystemLoginBgType == 0)
      {%>
    <div class="login-bg"></div>
    <div class="map login-map">
        <div style="width: 100%; height: 100%;" id="allmap"></div>
    </div>
    <script type="text/javascript" src="http://api.map.baidu.com/api?key=&v=1.1&services=true"></script>
    <script type="text/javascript">

        var map = new BMap.Map("allmap");
        var locationPoint = new BMap.Point(<%=SystemConfig.SystemLoginBgForMap%>);
        var centerPoint =  new BMap.Point(locationPoint.lng, locationPoint.lat+0.002);//偏离量0.002，避免登录窗口挡住中心点
        map.centerAndZoom(centerPoint, 16);
        var mkr = new BMap.Marker(locationPoint); map.addOverlay(mkr);

    </script>
    <%}
      else if (SystemConfig.SystemLoginBgType == 1)
      {%>
    <div class="login-custom" style="background: url('<%=UploadFilePath+ SystemConfig.SystemLoginBgForCustom %>') no-repeat center center"></div>

    <%}
      else
      {%>
    <div class="login-banner">
        <div class="bd">
            <ul>
                <li style="background: url('http://area.sinaapp.com/bingImg') no-repeat center center"></li>
                <li style="background: url('http://area.sinaapp.com/bingImg?daysAgo=1') no-repeat center center"></li>
                <li style="background: url('http://area.sinaapp.com/bingImg?daysAgo=2') no-repeat center center"></li>
            </ul>
        </div>
    </div>

    <script type="text/javascript" src="<%=SystemPath %>../cn/js/jquery.SuperSlide.2.1.1.js"></script>
    <script type="text/javascript">
        jQuery(".login-banner").slide({ effect: "fold", mainCell: ".bd ul", autoPlay: true, delayTime: <%=SystemConfig.SystemLoginBgForRandom%> });
    </script>

    <%} %>
    <script type="text/javascript">

        function submitLogin() {

            var userName = $("#txtUserName").val();
            var password = $("#txtPassword").val();
            var verifiyCode = $("#txtCode").val();
            var isRemember = "1";
            if ($("[name='Remember']").is(":checked"))
                isRemember = "1";
            else
                isRemember = "0";
            if (userName == "" || password == "") {
                whir.toastr.warning("请填写账号、密码");
                return;
            }
            whir.ajax.post('<%=SystemPath%>Handler/Security/User.aspx', {
                data: {
                    _action: "Login",
                    userName: userName,
                    password: password,
                    verifiyCode: verifiyCode,
                    isRemember: isRemember
                },
                success: function (result) {
                    if (result.Status) {
                        location.href = '<%=AppPath%>' + 'Main.aspx';
                    }
                    else {
                        if(result.Message=="-1")
                            location.href='RegKey.aspx'; //跳转到授权页面
                        else
                        {
                            isShowCode();
                            whir.toastr.warning(result.Message);
                        }
                    }
                    whir.loading.remove();
                },
                error:function(result){
                    whir.toastr.error(result.responseText);
                    whir.loading.remove();
                }
            });
        }

        function isShowCode() {
            whir.ajax.post('<%=SystemPath%>Handler/Security/User.aspx', {
                data: {
                    _action: "IsShowCode"
                },
                success: function (result) {
                    if (result.Status) {
                        $("#divCode").show();
                    }
                    whir.loading.remove();
                }
            });

        }

        function getLoinName() {
            whir.ajax.post('<%=SystemPath%>Handler/Security/User.aspx', {
                data: {
                    _action: "GetLoinName"
                },
                success: function (result) {
                    if (result.Status) {
                        $("#txtUserName").val(result.Message);
                        $("[name='Remember']").attr("checked", 'checked');
                    }
                    whir.loading.remove();
                }
            });
        }


        $(document).ready(function () {
            isShowCode();
            getLoinName();
            $("#txtUserName").focus();
            document.onkeydown = function (e) {
                var ev = document.all ? window.event : e;
                if (ev.keyCode == 13) {
                    submitLogin();
                }
            };

        });

      
    </script>
</body>
</html>
