<?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 lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <?= Html::csrfMetaTags() ?>
    <title>欢迎使用X Trader</title>
    <?php $this->head() ?>
    <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-3"></div>
        <div class="col-md-6">
            <h1 class="text-center">X Trader</h1>
            <hr/>
        </div>
        <div class="col-md-3"></div>
    </div>
    <div class="row">
        <div class="col-md-3"></div>
        <div class="col-md-6">
            <div class="ibox-title">
                欢迎使用X Trader
            </div>
            <div class="ibox-content">
                <form id="form" class="m-t" role="form">
                    <div class="input-group" style="margin-bottom:15px;">
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-default">邮箱</button>
                        </span>
                        <input type="text" id="username" name="username" class="form-control" placeholder="您的电子邮箱" required="">
                    </div>
                    <div class="input-group" style="margin-bottom:15px;">
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-default">密码</button>
                        </span>
                        <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="<?= Url::to(['pwd?type=1']) ?>">
                        <small>忘记密码?</small>
                    </a>
                    <a href="<?= Url::to(['open']) ?>" class="pull-right">
                        <small>没有账户?</small>
                    </a>
                </form>
            </div>
            <hr/>
        </div>
        <div class="col-md-3"></div>
    </div>
    <div class="row">
        <div class="col-md-3"></div>
        <div class="col-md-6 text-right">
            <small>©2016-2018 handz-fx</small>
        </div>
        <div class="col-md-3"></div>
    </div>
</div>
<?php $this->endBody() ?>
<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: "<?= Url::to(['login-post']) ?>",
            data: $('#form').serialize(),
            dataType: "json",
            beforeSend: function () {
            },
            success: function (data) {
                if (data.isSuccess) {
                    var url = "<?= Url::to(['/user/dashboard']) ?>";
                    window.location.href = url;
                } else {
                    toastr.error("用户名或密码错误", "提示");
                }
            },
            complete: function (XMLHttpRequest, textStatus) {
            },
            error: function () {
            }
        });
    });
</script>
</body>
</html>
<?php $this->endPage() ?>
