enter_password.html 4.6 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:#F5F6FA;
        }
        .passwordnum{
            color:#1A1A1A;
            font-size: 0.36rem;
            font-weight: bold;
            margin: 2.16rem 3.02rem;
        }
        .nextstep{
            width:2.4rem;
            height:0.88rem;
            background:#FE0A01;
            color:#fff;
            font-size: 0.32rem;
            text-align: center;
            line-height: 0.88rem;
            border-radius: 0.44rem;
            box-shadow:0px 15px 30px 0px rgba(254,10,1,0.24);
            margin: 0.66rem 2.55rem 0 2.55rem;
        }
        .enterpassword{
            width:4.8rem;
            margin: 0 auto;
            display:flex;
            justify-content: space-between;
            align-items: center;
            font-size: 0;
            margin-top: 0.48rem;
        }
        .enterpassword li{
            width:0.8rem;
            height:0.8rem;
            list-style: none;
            border:1px solid rgba(153,153,153,1);
            text-align: center;
            border-right:0;
            background: #fff;
        }
        .enterpassword li:last-child{
            border-right:1px solid rgba(153,153,153,1) ;
        }
        .enterpassword li input{
            width:0.67rem;
            height:0.76rem;
            list-style: none;
            text-align: center;
            border:none;

        }

    </style>


</head>
<body>
<div class="container">
    <p class="passwordnum">输入密码</p>
    <ul class="enterpassword" id="wrap">
        <li>
            <input type="number" class="entercode">
        </li>
        <li>
            <input type="number" class="entercode">
        </li>
        <li>
            <input type="number" class="entercode">
        </li>
        <li>
            <input type="number" class="entercode">
        </li>
        <li>
            <input type="number" class="entercode">
        </li>
        <li>
            <input type="number" class="entercode">
        </li>
    </ul>
    <p class="nextstep">下一步</p>
</div>
</body>
<script src="__INDEX__/js/jquery.min.js"></script>
<script>

    var str=""
    var arr=[];
    var txts = wrap.getElementsByClassName("entercode");
    for(var i=0;i<txts.length;i++){
        $(txts[i]).val("")
    }
    var t = '';
    //输入的密码自动输入到下一个
    onload = function(){
        console.log(txts);


        for(var i = 0; i<txts.length;i++){
            t = txts[i];
            t.index = i;
            if(t.index>0){
                t.setAttribute("readonly", true);
            }
            t.onkeyup=function(){

                var regular = /\s+/g;
                if(regular.test(this.value)){
                    $(this).focus();
                }else if($(this).val()==""){
                    $(this).focus();
                }else{
                    console.log($(this).val());
                    arr.push($(this).val());
                    var next = this.index + 1;
                    if(next > txts.length - 1) return;
                    txts[next].removeAttribute("readonly");
                    txts[next].focus();
                }
            }
            if(t.index==5){
                t.onkeyup=function(){
                    arr.push($(this).val())
                    console.log(arr);
                    str=arr[0]+arr[1]+arr[2]+arr[3]+arr[4]+arr[5];
                    console.log(str)
                }
            }

        }
        txts[0].removeAttribute("readonly");
    }

    $(".nextstep").click(function(){
        if(arr.length == 6) {
            $.ajax({
                url: "{:url('friendship/Friend/pwd')}",
                data: {
                    integral_pwd: str,
                    step: 'enter'
                },
                type: "POST",
                dataType: "JSON",

                success: function (data) {
                    if (data.data === true) {
                        window.location.href = data.url
                    }
                }
            })
        }
    })

</script>
</html>