<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>erp</title>
    <meta name="description" content="管理系统"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" href="../../static/login/css/supersized.css">
    <link rel="stylesheet" href="../../static/login/css/style.css">
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <![endif]-->
</head>
<body>
<div class="page-container">
    <div class="container">
        <h1>GDSM</h1>
        <div>
            <form id="sign-in">
                <div id="login-msg"></div>
                <div class="form-group">
                    <label>用户名</label>
                    <input type="text"
                           data-validate="{required: true, messages:{required:'请输入用户名'}}" name="login_username"
                           id="login_username" autocomplete="off"/>
                </div>
                <div class="form-group">
                    <label>密码</label>
                    <input type="password"
                           data-validate="{required: true, messages:{required:'请输入密码'}}" name="login_password"
                           id="login_password" autocomplete="off"/>
                </div>
                <button type="submit" style="background-color: #651fff;border-color: #651fff">登录</button>
            </form>
        </div>
        <div style="margin-top: 100px">
            <p>
                <small class="text-muted">GDSM<br>&copy; 2019</small>
            </p>
        </div>
    </div>
</div>
<script src="../../static/js/app.min.js"></script>
<script src="../../static/login/js/supersized.3.2.7.min.js"></script>
<script src="../../static/login/js/supersized-init.js"></script>
<script src="../../lib/jquery/jquery/validate/jquery.validate.js"></script>
<script src="../../lib/jquery/jquery/jquery.form.js"></script>
<script>
    $(document).ready(function () {
        if (self != top) {
            top.location.href = "/login";
            return
        }
        function showResponse(resp) {
            if (resp.ret == "success") {
                window.location.href = "{{.redirectUrl}}";
                return;
            }
            var result = "登录失败: " + resp.result;
            $("#login-msg").text(result);
        }

        $("#guestLogin").on("click", function () {
            $.post("/login", {"login_username": "guest", "login_password": "abc"}, function (data) {
                window.location.href = "{{.redirectUrl}}";
            })
        });
        // validate
        $('#sign-in').validate({
            submitHandler: function (form) {
                $("#sign-in").ajaxSubmit({
                    type: "post",
                    url: "/login",
                    success: showResponse
                });
            }
        })
    })
</script>
</body>
</html>
