<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
    <title>oss-console 登录</title>
    <link rel="stylesheet" type="text/css" th:href="@{/css/login.css}">
</head>
<body class="layui-layout-login">
<div class="login-bg">
    <div class="cover"></div>
</div>
<div class="login-content" th:th:classappend="${isCaptcha} ? 'captcha'">
    <h1 class="login-box-title"><i class="fa fa-fw fa-user"></i>登录</h1>
    <form class="layui-form" th:action="@{/login}" method="post">
        <div class="layui-form-item">
            <label class="layui-icon layui-icon-username" for="username"></label>
            <input class="layui-input" type="text" name="principal" id="username" placeholder="用户名">
        </div>
        <div class="layui-form-item">
            <label class="layui-icon layui-icon-password" for="password"></label>
            <input class="layui-input" type="password" name="credential" id="password" placeholder="密码">
        </div>
        <!--<div class="layui-form-item captcha-item">
            <label class="layui-icon layui-icon-vercode"></label>
            <input class="layui-input" type="text" name="captchaCode" autocomplete="off" placeholder="验证码">
            <img id="captchaImg" class="captcha-img" onclick="getCaptcha()" src="" alt="user image" />
        </div>-->
        <div class="layui-form-item">
            <input type="checkbox" name="rememberMe" title="记住我" lay-skin="primary">
            <a class="layui-layout-right forget-password" href="javascript:alert('请联系管理员')">没有帐号/忘记密码?</a>
        </div>
        <button type="submit" class="layui-btn layui-btn-fluid ajax-login">
            <i class="fa fa-sign-in fa-lg fa-fw"></i> 登录</button>
    </form>
    <div class="layui-layer-loading login-page-loading">
        <div class="layui-layer-content"></div>
    </div>
</div>

<script type="text/javascript" th:src="@{/js/plugins/jquery-2.2.4.min.js}"></script>
<script th:replace="/common/template :: script"></script>
<script th:src="@{/js/login.js}" charset="utf-8"></script>
<script type="text/javascript">
    /*function getCaptcha(){
        var captchaImg = document.getElementById("captchaImg");
        $.get('/api/account/code/captcha', function (json) {
            if (json.code === 0) {
                captchaImg.setAttribute("src", json.data);
            } else {
                layer.alert(json.msg, function(){
                });
            }
        })
    }*/
    function getPubkey(){
        $.get('/api/account/code/pubkey', function (json) {
            if (json.code === 0) {
                localStorage.setItem("pubkey", json.data.pubkey)
                localStorage.setItem("pubkeyR", json.data.r)
                //getCaptcha()
            } else {
                layer.alert(json.msg, function(){
                });
            }
        })
    }
    getPubkey();
</script>
</body>
</html>
