@Model
@{
    Layout = null;
}<!DOCTYPE html>
<html>
<head>
    <title>PageAdmin网站管理系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no,minimal-ui">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="Author" content="www.pageadmin.net" />
    <meta name="Copyright" content="http://www.pageadmin.net" />
    <link rel="stylesheet" href="~/Incs/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/Areas/Admin/Css/login.css" type="text/css">
    <script src="/Js/jquery.min.js" type="text/javascript"></script>
    <script src="/Js/basic.js" type="text/javascript"></script>
    <script src="~/Js/dialog.js" type="text/javascript"></script>
    <script src="/Js/UI/ui.js" type="text/javascript"></script>
    <script src="~/Js/ValidateForm/validateForm.js" type="text/javascript"></script>
    <!--[if lte IE 9]>
    <script src="/Incs/bootstrap/js/respond.min.js"></script>
    <script src="/Incs/bootstrap/js/html5.js"></script>
    <![endif]-->
    <script src="/Incs/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        if (self != top) {
            top.location.href = location.href;
        }
    </script>
</head>
<body>
    <div class="main clearfix">
        <div class="hidden-xs left-area">
            <div class="intro">
                <h2>感谢您使用PageAdmin网站管理系统!</h2>
                <ul class="remark-list hidden-sm">
                    <li>
                        <i class="glyphicon glyphicon-ok"></i> PageAdmin是一款基于最新Web技术的通用网站管理系统，具有强大的功能和卓越的可扩展性，最大程度上帮助您提升网站管理效率，节约时间成本...
                    </li>
                    <li>
                        <i class="glyphicon glyphicon-ok"></i> 我们将会持续的改进并不断加入更多的功能，欢迎您你能提供宝贵的建议。
                    </li>
                </ul>
                <div class="href-box hidden-sm">
                    <a href="/" target="_blank" class="btn btn-info"><i class="glyphicon glyphicon-link"></i> 返回首页</a>
                    <a href="http://www.pageadmin.net" target="_blank" class="btn btn-info"><i class="glyphicon glyphicon-link"></i> PageAdmin官网</a>
                </div>
            </div>
        </div>
        <div class="background-area"></div>
        <div class="right-area" id="loginbox">
            <div class="login-box">
                <form method="post" id="_form" class="" data-validate-params="tipsStyle:3">
                    <span class="login-title"><i class="glyphicon glyphicon-user"></i> 管理员登录<span>/Administrator login</span></span>

                    <div class="validate-all-tips-box"></div>
                    <div class="form-group">
                        <div class="controls ">
                            <input type="text" id="username" name="username" class="form-control" maxlength="50" placeholder="管理员账户" data-validate="dataType:'*',nullMsg:'请填写管理员账户!'">
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="controls">
                            <input type="password" id="password" name="password" class="form-control" maxlength="50" placeholder="密码" data-validate="dataType:'password',nullMsg:'请填写密码!'">
                            <span class="help-block"></span>
                        </div>
                    </div>
                    @{
                        string AuthenticationCode = Model;

                        if (!string.IsNullOrWhiteSpace(AuthenticationCode))
                        {
                            <div class="form-group">
                                <div class="controls">
                                    <input type="text" id="code" name="code" class="form-control" maxlength="50" placeholder="认证码" data-validate="dataType:'*',nullMsg:'请填写认证码!'">
                                    <span class="help-block"></span>
                                </div>
                            </div>
                        }
                    }

                    <div class="form-group">
                        <div class="controls form-inline">
                            <input type="text" id="verificationCode" name="verificationCode" class="form-control" maxlength="10" placeholder="验证码" data-validate="dataType:'*',nullMsg:'请填写验证码!',minLength:4,minLengthErrorMsg:'验证码最少4个字符!',checkUrl:'/E/VerificationCode/Validate',checkError:'验证码填写错误!'">
                            <img src="/E/VerificationCode/" id="verificationCodeImg" class="ui-verificationCodeImage" />
                            <span class="help-block"></span>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="controls">
                            <input id="cookies" type="checkbox" name="cookies" value="1"> <span for="cookies">&nbsp;记住我的登录信息</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="controls">
                            @Html.AntiForgeryToken()
                            <button type="button" class="btn btn-primary form-control ui-pagePost" data-custom-params="url:'@Url.Action()',failCallBack:'FailCallBack',callBack:'LoginSuccess',successMsg:''">登录</button>
                        </div>
                    </div>
                </form>

            </div>
        </div>
    </div>

    <script type="text/javascript">
        var $form = $("#_form");
        var $verificationCode = $("#verificationCode");

        function SaveInfo() {
            if ($("#cookies").prop("checked")) {
                var serializerStr = $form.SerializeJson();
                serializerStr = JsonToString(serializerStr);
                SetLocalStorage("LoginAdminUserInfo", serializerStr);
            }
            else {
                RemoveLocalStorage("LoginAdminUserInfo");
            }
        }
        //初始化登录信息
        function InitLoginInfo() {
            var serializerStr = GetLocalStorage("LoginAdminUserInfo");
            $form.FormBind({}, serializerStr);
            $verificationCode.val("");
        }
        InitLoginInfo();

        
        function Init() {
            var bgNum = Math.floor(Math.random() * 10 + 1);
            $("body").css("background-image", "url(/Areas/Admin/Css/images/login/" + bgNum + ".jpg)");
            var winHeight = $(window).height();
            var $intro = $(".intro")
            var $loginBox = $(".login-box");
            var introHeight = $intro.height();
            var mHeight = $loginBox.height();
            var topIntroMargin = parseInt(winHeight / 2) - parseInt(introHeight / 2) - 40;
            var topMargin = parseInt(winHeight / 2) - parseInt(mHeight / 2) - 40;
            $intro.css("margin-top", topIntroMargin + "px");
            $loginBox.css("margin-top", topMargin + "px");
            $intro.fadeIn("slow");
            //$("#loginbox").animate({ opacity: "10" }, 2000);
        }
        $(function () {
            Init();
        });

        var $tipsBox = $form.find(".validate-all-tips-box");
        function FailCallBack(data) {
            var msg = data.Msg;
            $tipsBox.html(msg);
            if (msg.indexOf("验证码")>=0)
            {
                $("#verificationCodeImg").click();
            }
        }
        function LoginSuccess() {
            layer.msg('登录成功...', {
                icon: 16,
                time: 200000, //200秒
                shade: 0.01
            });
            SaveInfo();
            location.href = "@(Url.Action("index","Default"))";
        }
    </script>
</body>
</html>