<!DOCTYPE html>
<html lang="zh-CN" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title></title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />

    <link rel="stylesheet" type="text/css" th:href="@{/vendor/bootstrap/css/bootstrap.min.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/fonts/font-awesome-4.7.0/css/font-awesome.min.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/fonts/iconic/css/material-design-iconic-font.min.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/css/util.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/css/main.css}">
</head>

<body>

<div class="limiter">
    <div class="container-login100" th:style="'background-image:url(/images/bg.jpg);'">
        <div class="wrap-login100 p-l-40 p-r-40 p-t-30 p-b-25">
            <form th:action="@{/page/mobile/dologin}" method="post" class="login100-form validate-form">
                <div id="login-logo" style="text-align: center;">
                    <img style="width: 80px;" class="logoImage">
                </div>

                <span class="login100-form-title p-b-30"></span>

                <div class="wrap-input100 validate-input m-b-23" data-validate="请输入手机号">
                    <span class="label-input100">手机号</span>
                    <input id="mobile" class="input100" type="text" name="mobile" placeholder="请输入手机号" required="手机号不可为空">
                    <span class="focus-input100" data-symbol="&#xf2c8;"></span>
                </div>

                <div class="wrap-input100 validate-input" data-validate="请输入验证码">
                    <span class="label-input100">验证码</span>
                    <input class="input100" type="text" name="verifyCode" placeholder="请输入验证码" required="验证码不可为空">
                    <span class="focus-input100" data-symbol="&#xf190;"></span>
                </div>

                <div p-t-8 p-b-20>
                    <div class="text-left">
                        <a href="/page/login">账号登录</a>
                    </div>
                    <!--<div class="text-right" style="float: right;">-->
                        <!--<span>&nbsp;&nbsp;</span>-->
                    <!--</div>-->
                </div>
                <div class="text-center p-t-6 p-b-6">
                    <span id="info" style="color: red" th:text="${result==null}?'&nbsp;':${result.msg}"></span>
                </div>
                <div class="container-login100-form-btn" style="width: 50%; float: left;">
                    <div class="wrap-login100-form-btn">
                        <div class="login100-form-bgbtn"></div>
                        <button type="button"  id="sendVerify" class="login100-form-btn" onclick="sendVerifyCode(this)" >获取验证码</button>
                    </div>
                </div>
                <div class="container-login100-form-btn">
                    <div class="wrap-login100-form-btn">
                        <div class="login100-form-bgbtn"></div>
                        <button class="login100-form-btn">登 录</button>
                    </div>
                </div>

                <div class="txt1 text-center p-t-15 p-b-5">
                    <span>第三方登录</span>
                </div>

                <div class="flex-c-m">
                    <a href="https://open.weixin.qq.com/connect/qrconnect?appid=wx60f06d61f21804be&redirect_uri=http://www.mooctest.net/api/wechat/login&response_type=code&scope=snsapi_login&state=STATE#wechat_redirect" target="_blank" class="login100-social-item bg1">
                        <i class="fa fa-wechat"></i>
                    </a>

                    <a href="https://github.com/login/oauth/authorize?client_id=4e8e65b7e3bdeee9229b" class="login100-social-item bg2">
                        <i class="fa fa-github"></i>
                    </a>

                    <!--<a href="#" class="login100-social-item bg3">-->
                        <!--<i class="fa fa-weibo"></i>-->
                    <!--</a>-->
                </div>

                <div class="flex-col-c p-t-10">
                    <a href="/page/register" class="txt2">立即注册</a>
                </div>
            </form>
        </div>
    </div>
</div>

<script th:src="@{/vendor/jquery/jquery-3.2.1.min.js}"></script>
<script th:src="@{/js/main.js}"></script>
<script th:src="@{/js/common.js}"></script>
<script type="text/javascript">
    function sendVerifyCode(obj) {
        var mobile = $("#mobile").val();
        if (mobile == null || mobile.trim() == "") {
            document.getElementById("info").innerText = "手机号不能为空";
            return;
        }
        if (!mobile.match(/^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$/)){
            document.getElementById("info").innerText = "手机号格式不正确，请重新输入";
            return
        }

        var data = {"mobile":mobile};
        $.ajax({
            url:"/api/verify/mobile",
            type:"PUT",
            data:data,
            timeout: 3000,
            success:function (result) {
                console.log(result);
                if (result.status != 2000) {
                    alert("发送失败, 原因:"+result.msg);
                    document.getElementById("info").innerText = result.msg;
                }else{
                    alert("发送成功，请尽快查收！");
                    document.getElementById("info").innerHTML = "&nbsp;";
                    settime(obj);
                }
            }
        })
    }
</script>
</body>
</html>