<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>案例管理系统 - 登录</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" th:href="@{/libs/bootstrap/bootstrap.min.css}"/>
    <link rel="stylesheet" th:href="@{/libs/font-awesome/font-awesome.min.css}"/>
    <link rel="stylesheet" th:href="@{/libs/iCheck/square/blue.css}"/>
    <link rel="stylesheet" th:href="@{/libs/validate/validate.css}"/>
    <link rel="stylesheet" th:href="@{/css/common.css}"/>
    <link rel="stylesheet" th:href="@{/css/login.css}"/>
</head>
<body>
<!--<div th:replace="home/fragments/top :: top"></div>-->
<div class="login-content">
    <div class="login-bg"></div>
    <div class="login-box">
        <form id="loginForm" class="login-form">
            <div class="login-title">用户登录</div>
            <div class="form-group has-feedback">
                <input type="text" name="username" class="form-control" placeholder="Username" max="14" min="3" maxlength="30" require="必填项">
                <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input name="password" type="password" class="form-control" placeholder="Password" maxlength="50" require="必填项">
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <!-- 
            <div class="form-group has-feedback vcode">
                <div class="vcode-content">
                    <input type="text" name="verification" class="form-control vcode-input" placeholder="Verification code" require="必填项" data-position="position-a">
                    <span class="fa fa-key vcode-icon form-control-feedback"></span>
                </div>
                <img id="img_verifycode" th:src="@{/verificationCode}" class="pointer vcode-img">
            </div>
             -->
            <div class="row">
                <div class="col-xs-5">
                    <!-- 
                    <div class="checkbox icheck">
                        <label style="padding: 0">
                            <input type="checkbox" id="rememberMe" name="rememberMe" value="0"> 记住我
                        </label>
                    </div>
                     -->
					<button type="button" id="btn_qywxlogin" class="btn btn-primary btn-block btn-flat">扫码登录</button>
                </div>
                <div class="col-xs-5" style="float:right;">
                    <button type="button" id="loginBtn" class="btn btn-primary btn-block btn-flat">账密登录</button>
                    <!-- <button type="submit" th:text="#{login.submitbtn}">[[#{login.submitbtn}]]</button> -->
                </div>
            </div>
        </form>
    </div>

</div>
<!--<div th:replace="home/fragments/footer :: copyrightLight"></div>-->

<script th:src="@{/libs/jquery/jquery.min.js}"></script>
<script th:src="@{/libs/bootstrap/bootstrap.min.js}"></script>
<script th:src="@{/libs/layer/layer.js}"></script>
<script th:src="@{/libs/iCheck/icheck.min.js}"></script>
<script th:src="@{/libs/validate/validate.js}"></script>
<script>
    $(function () {
        $('input').iCheck({
            checkboxClass: 'icheckbox_square-blue',
            radioClass: 'iradio_square-blue',
            increaseArea: '20%' // optional
        });

    });
</script>
<script>
    $(function () {
        $(".vcode-img").on('click', function () {
       		$(this).attr('src', '[[@{/verificationCode?}]]' + Math.floor(Math.random() * 100));
        });
        
 		// 使用企业微信扫码登录
		$("#btn_qywxlogin").click(function () {
			window.location.href = "[[@{/qywx/qrLogin}]]";
		});
        
        // 账号密码登录
        $("#loginBtn").on('click', function () {
            if (!doValidForm(loginForm)) {
           		return;
            }
            $.ajax({
                type: "POST",
                url: "[[@{/login}]]",
                data: $(".login-form").serialize(),
                dataType: "json",
                success: function (data) {
                    if (data.ret==0) {
                        layer.msg(data.msg, {
                            offset: '30%',
                            time: 500
                        }, function () {
                            window.location.href = "[[@{/admin}]]";
                        });
                    }else{
                        layer.msg(data.msg, {
                            icon: 2,
                            offset: '30%',
                            time: 2000
                        });
                        $("#img_verifycode").click();
                    }
                }
            });
        });

        $(document).keyup(function (event) {
            if (event.keyCode == 13) {
                $("#loginBtn").click();
            }
        });
    })
</script>
</body>
</html>