password_manager.html 6.7 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="https://at.alicdn.com/t/font_834805_0ml90wdq5hzm.css">
    <link rel="stylesheet" href="__INDEX__/css/base.css">
    <link rel="stylesheet" href="__INDEX__/css/swiper.min.css">
    <script type="text/javascript" src="__INDEX__/js/base.js"></script>
    <title>密码管理</title>
    <style>
        body,html{
            width:100%;
            height:100%;
            background: RGBA(245, 246, 250, 1);
        }
        .phone{
            width:6.96rem;
            margin: 0 auto;
            height:1rem;
            background: #fff;
            border-radius: 0.5rem;
            font-size: 0.28rem;
            color: RGBA(151, 160, 168, 1);
            /*padding: 0.37rem 0.52rem;*/
            margin-top: 0.32rem;

        }
        .enterphone{
            width:6.96rem;
            margin: 0 auto;
            height:1rem;
            background: #fff;
            border-radius: 0.5rem;
            font-size: 0.28rem;
            color: RGBA(151, 160, 168, 1);
            padding: 0.37rem 0.52rem;

            border:none;
            outline:none;
        }
        .code{
            font-size: 0;
            display:flex;
            justify-content: space-between;
            align-content: center;
            width:6.96rem;
            margin: 0 auto;
            height:1rem;
            background: #fff;
            border-radius: 0.5rem;

            color: RGBA(151, 160, 168, 1);

            margin-top: 0.32rem;
        }
        .code_num{
            height:1rem;
            line-height: 1rem;
            font-size: 0.28rem;
            margin-left: 0.52rem;
        }
        .entercode{
            height:1rem;
            line-height: 1rem;
            font-size: 0.28rem;
            outline:none;
            border:none;
            border-radius: 0.5rem;
            color: RGBA(151, 160, 168, 1);
        }
        .sendcode{
            width:2.44rem;
            font-size: 0.28rem;
            height:0.72rem;
            background: RGBA(254, 10, 1, 1);
            color:#fff;
            border-radius: 0.36rem;
            line-height: 0.72rem;
            text-align: center;
            margin-top: 0.15rem;
            margin-right: 0.37rem;
            border:none;
            outline:none;
        }
        .nextstep{
            display:block;
            width:6.86rem;
            height:0.88rem;
            text-align: center;
            line-height: 0.88rem;
            background:RGBA(254, 10, 1, 1);
            font-size: 0.32rem;
            color:#fff;
            border-radius: 0.44rem;
            position:fixed;
            bottom:0.55rem;
            left:0;
            right:0;
            margin: 0 auto;
            box-shadow:0px 15px 30px 0px rgba(254,10,1,0.24);
            border:none;
            outline:none;

        }
    </style>
</head>
<body>
<div class="container">
    <div class="phone">
        <input type="text" class="enterphone" placeholder="手机号">
    </div>
</div>
<div class="code">
    <p class="code_num">
        <input type="text" class="entercode" placeholder="验证码">
    </p>
    <button class="sendcode"></button>
</div>
<button class="nextstep">
    下一步
</button>
</body>
<script src="__INDEX__/js/jquery.min.js"></script>
<script>
    $(".sendcode").click(function () {
        var mobile = $(".enterphone").val();
        var pattern = /^1[34578]\d{9}$/;
        if(pattern.test(mobile)) {
            $.ajax({
                url: "{:url('sms/Sms/sendSms')}",
                data: {
                    mobile: mobile
                },
                type: "POST",
                dataType: "JSON",
            })
        } else {
            alert('请输入正确的手机号');
        }
    })

    $(".nextstep").click(function(){
        var mobile = $(".enterphone").val();
        var code = $(".entercode").val();
        if(mobile == '') {
            alert('请输入手机号');
        }else {
            if(code == '') {
                alert('请输入验证码');
            }else {
                $.ajax({
                    url:"{:url('sms/Sms/checkCodeS')}",
                    data:{
                        mobile:mobile,
                        code:code
                    },
                    type:"POST",
                    dataType:"JSON",

                    success: function (data) {
                        if(data.data === true) {
                            localStorage.clear();
                            window.location.href="{:url('friendship/Friend/enterPassword')}"
                        }else {
                            alert(data.msg);
                        }
                    }
                })
            }
        }
    })

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

    var t=localStorage.getItem("time");
    InterValObj = window.setInterval(SetRemainTime,1000);

    if(t!=null){
        curCount=t;
        //$(".nextstep").attr("disabled",true);
        $(".sendcode").attr("disabled",true)
        var phone=localStorage.getItem("mobile");
        $(".enterphone").val(phone)

    }else{
        curCount=60;
        window.clearInterval(InterValObj);
        $(".sendcode").html("获取验证码");
    }
    $(".sendcode").click(function(){
        curCount = count;
        var tel = $(".enterphone").val();
        if(tel==""){
            return false;
        }
        var reg= /^1[34578]\d{9}$/;
        if(!reg.test(tel)){
            return false;
        }
        localStorage.setItem("mobile",tel)
        //设置button效果,开始计时
        $(".sendcode").attr("disabled",true);
        //$(".nextstep").attr("disabled",true);
        // $(".sendcode").unbind()
        $(".sendcode").html( curCount + "秒");
        $(".sendcode").css("color","#fff");
        InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器,1秒执行一次
    });

    //timer处理函数
    function SetRemainTime() {
        if (curCount == 0) {
            window.clearInterval(InterValObj);//停止计时器
            $(".sendcode").removeAttr("disabled");//启用按钮
            //$(".nextstep").removeAttr("disabled");
            $(".sendcode").html("重新发送验证码");
            $(".sendcode").css("color","#fff");
            localStorage.clear();
        }
        else {
            curCount--;
            localStorage.setItem("time",curCount);
            $(".sendcode").html(curCount + "秒");
            $(".sendcode").css("color","#fff");
        }
    }
</script>
</html>