login.html 4.2 KB
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="yes" name="apple-touch-fullscreen">
    <meta name="viewport"
          content="width=device-width, initial-scale=1,maximum-scale=1,maximum-scale=1, minimum-scale=1, user-scalable=no">
    <title>登录</title>
    <link rel="stylesheet" href="/static/css/common.css">
    <link rel="stylesheet" href="/static/css/style.css">
</head>
<body>
<div class="box">
    <h1 class="login_title">欢迎登录</h1>
    <div class="login_list">
        <b>手机号</b>
        <input type="tel" class="login_phone">
    </div>
    <div class="login_list">
        <b>验证码</b>
        <input type="number" class="login_code">
        <u class="get_code">获取验证码</u>
    </div>
    <div class="login_tab">
        <b></b>
        <i>抱歉,此手机号没有权限登录</i>
    </div>
    <div class="btn_login">
        <img src="/static/image/btn_login.png"/>
    </div>
</div>


<script type="text/javascript" src="/static/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="/static/js/layer/layer.js"></script>
<script type="text/javascript" src="/static/js/common.js"></script>
<script>
    $(function () {
        //获取短信验证码
        var times = 1;
        var validCode = true;
        $(".get_code").click(function () {
            if (validCode) {
                var user_phone = $(".login_phone").val();
                if (!user_phone) {
                    layer.msg("手机号码格式不正确")
                } else {
                    if (times == 1) {
                        times++;
                        $.ajax({
                            type: "post",
                            url: "{:url('portal/tool/get_sms_code')}",
                            data: {
                                mobile: user_phone
                            },
                            success: function () {
                                var time = 60;
                                var code = $(".get_code");
                                if (validCode) {
                                    code.html("60秒");
                                    validCode = false;
                                    code.addClass("msgs1");
                                    var t = setInterval(function () {
                                        if (time >= 0) {
                                            time--;
                                            code.html(time + "秒");
                                            validCode = false;
                                        } else {
                                            code.html("重新获取");
                                            clearInterval(t);
                                            validCode = true;
                                        }
                                    }, 1000)
                                }
                            }
                        })
                    }
                }
            }
        });

        $('.btn_login').click(function () {
            var user_phone = $(".login_phone").val();
            var user_code = $('.login_code').val();
            if (!user_code) {
                layer.msg("验证码不能为空")
            } else {
                $.ajax({
                    type: "post",
                    url: "{:url('user/login/do_login')}",
                    data: {
                        mobile: user_phone,
                        sms_code: user_code
                    },
                    success: function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg);
                        } else {
                            window.location.href = "{:url('user/profile/percenter')}"
                        }
                    },
                    error: function () {

                    }
                })
            }

        });
    })
</script>
</body>
</html>