<?php
/**
 * @var \yii\web\View $this
 * @var string $tip
 */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>BIT System 后台管理平台</title>
    <link href="<?= STATIC_URL ?>/static/cp/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="<?= STATIC_URL ?>/static/cp/css/base.css" rel="stylesheet" type="text/css" />
    <link href="<?= STATIC_URL ?>/static/cp/css/login.css" rel="stylesheet" type="text/css" />
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <script src="<?= STATIC_URL ?>/static/cp/js/jquery-1.7.2.min.js"></script>
    <script src="<?= STATIC_URL ?>/static/cp/bootstrap/js/bootstrap.js"></script>
    <script src="<?= STATIC_URL ?>/static/cp/js/base.js"></script>
    <script language="JavaScript">
    if (window != top)
        top.location.href = location.href;
    </script>
</head>
<body>
<div class="container">
    <div class="logo">BIT System</div>
    <div class="login">
        <?php if (!empty($tip)) : ?>
        <div class="alert alert-error">
            <button class="close" data-dismiss="alert">×</button>
            <strong>错误!</strong>
            <?= $tip ?>
        </div>
        <?php endif; ?>
        <form id="login-form" class="well form-inline" method="post">
            <input type="hidden" name="<?= Yii::$app->request->csrfParam ?>" value="<?= Yii::$app->request->getCsrfToken() ?>" />
            用户名：
            <input type="text" id="j_username" name="j_username" class="input-medium">
            密码：
            <input type="password" id="j_password" name="j_password" class="input-medium">
            <label class="checkbox">
                <input id="j_remember" type="checkbox" value="记住我">
                记住我 </label>
            <button type="submit" class="btn">登陆</button>
        </form>
        <span class="fn-left"><a data-toggle="modal" href="#pwd-modal">忘记密码?</a></span> </div>
</div>
<div id="pwd-modal" class="modal hide fade" style="display: none; ">
    <div class="modal-header"> <a class="close" data-dismiss="modal">×</a>
        <h4>忘记密码?</h4>
    </div>
    <div class="modal-body">
        <p>请联系您的网站管理员重置密码!</p>
    </div>
    <div class="modal-footer"> <a href="#" class="btn btn-primary" data-dismiss="modal">确定</a> </div>
</div>
</body>
<script type="text/javascript">
$(document).ready(function() {
    var $loginForm = $("#login-form");
    var $username = $("#j_username");
    var $password = $("#j_password");
    var $remember = $("#j_remember");
    // 判断"记住用户名"功能是否默认选中,并自动填充登录用户名
    if (getCookie("j_username") != null) {
        $remember.attr("checked", true);
        $username.val(getCookie("j_username"));
        $password.focus();
    } else {
        $remember.attr("checked", false);
        $username.focus();
    }
    // 提交表单认证,记住登录用户名
    $loginForm.submit(function() {
        if ($username.val() == "") {
            alert("用户名不允许为空！");
            return false;
        }
        if ($password.val() == "") {
            alert("密码不允许为空！");
            return false;
        }
        if ($remember.attr("checked")) {
            var expires = new Date();
            expires.setTime(expires.getTime() + 1000 * 60 * 60 * 24 * 7);
            setCookie("j_username", $username.val(), expires);
        } else {
            removeCookie("j_username");
        }
    });
})
</script>
</html>