login.html 4.8 KB
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no" />
    <title>注册</title>
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <link rel="stylesheet" href="./style/base.css">
    <link rel="stylesheet" href="./style/common.css">
    <script src="./js/base.js"></script>
    <style>
        body {
            background: #fff
        }
    </style>
</head>

<body>
<!-- 吐司 -->
<div class="toast">
    <div class="toast_title">1234</div>
</div>
<!-- 顶部 -->
<div class="register_top">
    <div class="register_img"></div>
</div>
<div class="register_box">
    <div class="register_contant">
        <div class="register_title">登录</div>
        <div class="register_one layer_star register_one_padding">
            <div class="register_one_left layer_star">
                <div class="register_one_icon">
                    <img src="./image/sun_46.png" alt="">
                </div>
                <div class="register_one_title">
                    手机号
                </div>
            </div>
            <div class="register_one_right">
                <input type="text" placeholder="请输入手机号码" id="phone" maxlength="11">
            </div>
        </div>
        <div class="register_one layer_star">
            <div class="register_one_padding layer_star">
                <div class="register_one_left layer_star">
                    <div class="register_one_icon">
                        <img src="./image/sun_47.png" alt="">
                    </div>
                    <div class="register_one_title">
&nbsp;&nbsp;&nbsp;
                    </div>
                </div>
                <div class="register_one_right">
                    <input type="text" placeholder="请输入密码" id="password">
                </div>
            </div>
            <div class="register_one_code" onclick="codeButton()" id="code">发送验证码</div>
        </div>

        <div class="register_btn">确认注册</div>
        <div class="register_word">
            注册即表示你已阅读并同意<a href="">《XX协议》</a>
        </div>
    </div>
</div>
<script src="js/jquery.js"></script>
<script type="text/javascript">
    // 验证码
    function codeButton() {
        var phone = $("#phone").val();
        var toast;
        if (phone == "") {
            toast = "手机号不能为空";
            $(".toast").show();
            $(".toast_title").text(toast)
            setTimeout(function() {
                hide()
            }, 1500)
        } else if (!(/^1[3456789]\d{9}$/.test(phone))) {
            toast = "请输入正确的手机号码";
            $(".toast").show();
            $(".toast_title").text(toast)
            setTimeout(function() {
                hide()
            }, 1500)
        } else {
            var code = $("#code");
            code.attr("disabled", "disabled");
            setTimeout(function() {
                code.css("opacity", "0.8");
            }, 1000);
            var time = 60;
            var set = setInterval(function() {
                code.text("" + --time + "s");
            }, 1000);
            setTimeout(function() {
                code.attr("disabled", false).text("重新获取");
                clearInterval(set);
            }, 60000);
        }
    };
    // 确认注册
    $(".register_btn").click(function() {
        var phone = $("#phone").val();
        var password = $("#password").val();
        var toast;
        if (phone == "") {
            toast = "手机号不能为空";
            $(".toast").show();
            $(".toast_title").text(toast)
            setTimeout(function() {
                hide()
            }, 1500)
        } else if (!(/^1[3456789]\d{9}$/.test(phone))) {
            toast = "请输入正确的手机号码";
            $(".toast").show();
            $(".toast_title").text(toast)
            setTimeout(function() {
                hide()
            }, 1500)
        } else if (password == '') {
            toast = "密码不能为空";
            $(".toast").show();
            $(".toast_title").text(toast)
            setTimeout(function() {
                hide()
            }, 1500)
        } else if (password != '1234') {
            toast = "密码不正确";
            $(".toast").show();
            $(".toast_title").text(toast)
            setTimeout(function() {
                hide()
            }, 1500)
        } else {
            console.log("注册成功")
        }
    })

    function hide() {
        $(".toast").hide()
    }
</script>
</body>

</html>