register.html 6.9 KB
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" href="__TMPL__/public/assets/css/base.css">
    <title>注册页面</title>
    <style>
        /*禁止iphone字体放大 */
        html { -webkit-text-size-adjust: none; }
        body { background:#fff; -webkit-text-size-adjust:100%;-ms-text-size-adjust:100%; }
        body,html{
            background: #fff;
        }
        .title{
            width:7.5rem;
            height:0.2rem;
            font-size: 0;
        }
        .title img{
            width:100%;
            height:100%;
        }
        .register_phone{
            width:6.86rem;
            height:0.88rem;
            margin: 0 auto;
            margin-top: 0.66rem;
            display: flex;
            border:1px solid #f5f5f5;

        }
        .register_code{
            width:6.86rem;
            height:0.88rem;
            margin: 0 auto;
            margin-top: 0.32rem;
            display: flex;
            border:1px solid #f5f5f5;

        }
        .phone_img{
            width:0.24rem;
            height:0.35rem;
            font-size: 0;
        }
        .code_img{
            width:0.32rem;
            height:0.36rem;
            font-size: 0;
        }
        .code_img img{
            width:100%;
            height:100%;
        }
        .phone_img img{
            width:100%;
            height:100%;
        }
        .register_num{
            width:0.96rem;
            height:0.88rem;
            display:flex;
            align-items: center;
            justify-content: center;
            border-right: 1px solid #f5f5f5;


        }
        .register_tel{
            width:5.9rem;
            height:0.88rem;
            font-size: 0;
            border-right: 1px solid #f5f5f5;
        }
        .register_codenum{
            width:4.3rem;
            height:0.88rem;
            font-size: 0;
            border-right: 1px solid #f5f5f5;
        }
        .register_tel input{
            width:5.9rem;
            height:0.83rem;
            border:none;
            outline:none;
            color:#97A0A8;
            font-size: 0.28rem;
            margin-top: 0.01rem;
            padding-left: 0.53rem;
            margin-left: 0.02rem;
        }
        .register_codenum input{
            width:4.3rem;
            height:0.83rem;
            border:none;
            outline:none;
            color:#97A0A8;
            font-size: 0.28rem;
            margin-top: 0.01rem;
            padding-left: 0.53rem;
            margin-left: 0.02rem;
        }
        .getcode{
            color:#CA277B;
            font-size: 0.24rem;
            height:0.8rem;
            line-height: 0.8rem;
            border:none;
            outline:none;
            background: #fff;
        }
        .sure{
            width:6.86rem;
            display:block;
            height:0.88rem;
            background:#CA277B ;
            color:#fff;
            font-size:0.32rem ;
            margin: 0 auto;
            margin-top: 0.72rem;
            border-radius: 0.1rem;
            text-align: center;
            line-height: 0.88rem;
            border: none;
            outline: none;
        }

    </style>
</head>
<body>
<div class="container">
    <div class="title">
        <img src="__TMPL__/public/assets/images/img/line.png" alt="">
    </div>
    <div class="register_phone">
        <div class="register_num">
            <p class="phone_img">
                <img src="__TMPL__/public/assets/images/img/phone.png" alt="">
            </p>
        </div>
        <div class="register_tel">
            <input type="text" placeholder="手机号" id="mobile">
        </div>

    </div>

    <div class="register_code">
        <div class="register_num">
            <p class="code_img">
                <img src="__TMPL__/public/assets/images/img/code.png" alt="">
            </p>
        </div>
        <div class="register_codenum">
            <input type="text" placeholder="验证码" id="code">
        </div>
        <button class="getcode">获取短信验证码</button>

    </div>

    <button class="sure">确定</button>
</div>
<script type="text/javascript" src="__TMPL__/public/assets/js/base.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/js/jquery.min.js"></script>

<script>
    var InterValObj; //timer变量,控制时间
    var count = 60; //间隔函数,1秒执行
    var curCount='';//当前剩余秒数


    //启动计时器,1秒执行一次
    $(".getcode").click(function(){
        var mobile=$("#mobile").val();
        var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
        //电话
        if (!phoneReg.test(mobile)) {
            alert('请输入有效的手机号码!');
            return false;
        }
        curCount = count;
        //设置button效果,开始计时
        $(".getcode").attr("disabled",true);
//        $(".sure").attr("disabled",true);
        // $(".sendcode").unbind()
        $(".getcode").html( curCount + "秒");
        InterValObj = window.setInterval(SetRemainTime,1000); //启动计时器,1秒执行一次
        $.ajax({
            url: "{:url('user/register/getCode')}",
            type: "post",
            data: {
                mobile:mobile,
            },
            success: function (data) {
                alert(data)
            }
        })


    });
    //timer处理函数
    function SetRemainTime() {
        if (curCount == 0) {
            window.clearInterval(InterValObj);//停止计时器
            $(".getcode").removeAttr("disabled");//启用按钮
//            $(".sure").removeAttr("disabled");
            $(".getcode").html("重新获取证码");

        }
        else {
            curCount--;
            localStorage.setItem("time",curCount);
            $(".getcode").html(curCount + "秒");
        }
    }

    $(".sure").click(function () {
        var mobile=$("#mobile").val();
        var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
        //电话
//        if (!phoneReg.test(mobile)) {
//            alert('请输入有效的手机号码!');
//            return false;
//        }
        var code=$("#code").val();
        if (code=="") {
            alert('请输入验证码');
            return false;
        }
        $.ajax({
            url: "{:url('user/register/doRegister')}",
            type: "post",
            data: {
                mobile:mobile,
                code:code,
            },
            success: function (data) {
                if (data==1){
                    alert('注册成功')
                    history.back()
//                    window.location.href="{:url('portal/index/index')}";
                }
                else {
                    alert(data)
                    return false
                }
            }
        })
    })
</script>
</body>
</html>