<?php
/* @var $this \yii\web\View */
/* @var $content string */
use yii\helpers\Html;
use yii\helpers\Url;
use yii\web\YiiAsset;

YiiAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="IE=edge">
    <?= Html::csrfMetaTags() ?>

    <title>管理登录</title>

    <link href="<?= STATIC_URL ?>/ui/css/bootstrap.min.css" rel="stylesheet">
    <link href="<?= STATIC_URL ?>/ui/font-awesome/css/font-awesome.css" rel="stylesheet">

    <link href="<?= STATIC_URL ?>/ui/css/animate.css" rel="stylesheet">
    <link href="<?= STATIC_URL ?>/ui/css/style.css" rel="stylesheet">

    <link href="<?= STATIC_URL ?>/ui/css/plugins/toastr/toastr.min.css" rel="stylesheet">





</head>

<body class="gray-bg">
<?php $this->beginBody() ?>
<div class="loginColumns animated fadeInDown">
    <div class="row">
        <div class="col-md-2"></div>
        <div class="col-md-8">
            <h1 class="text-center">ADMIN LOGIN</h1>
            <hr/>
        </div>
        <div class="col-md-2"></div>
    </div>
    <div class="row">
        <div class="col-md-2"></div>
        <div class="col-md-8">
            <div class="ibox-content">
                <form id="form" class="m-t" role="form">
                    <div class="form-group">
                        <input type="text" id="username" name="username" class="form-control" placeholder="账户" required="">
                    </div>
                    <div class="form-group">
                        <input type="password" id="password" name="password" class="form-control" placeholder="密码" required="">
                    </div>
                    <button id="login" type="button" class="btn btn-primary block full-width m-b">登录</button>
                    <!--  
                    <a href="#">
                        <small>忘记密码?</small>
                    </a>
                    -->
                </form>
            </div>
            <hr/>
        </div>
        <div class="col-md-2"></div>
    </div>
    <div class="row">
        <div class="col-md-2"></div>
        <div class="col-md-4"></div>
        <div class="col-md-4 text-right">
            <small>© 2017</small>
        </div>
        <div class="col-md-2"></div>
    </div>
</div>


<?php $this->endBody() ?>


<script src="<?= STATIC_URL ?>/ui/js/jquery.1.9.1.min.js"></script>
<script src="<?= STATIC_URL ?>/ui/js/bootstrap.min.js"></script>
<script src="<?= STATIC_URL ?>/ui/js/plugins/toastr/toastr.min.js"></script>
<script type="text/javascript">

$("#login").on("click",function(){
    $.ajax({
        type: "POST",
        url: "/account/adminlogin-post",
        data: $('#form').serialize(),
        dataType: "json",
        beforeSend: function() {},
        success: function(data) {
            if(data.isSuccess){
                var url="/admin/dashboard";
                window.location.href=url;
            }else{
                toastr.error("用户名或密码错误", "提示");
            }
        },
        complete: function(XMLHttpRequest, textStatus) {},
        error: function() {}
    });
});

</script>

</body>
</html>
<?php $this->endPage() ?>