forget_password_view.html 12.7 KB
<!DOCTYPE html>
<html lang="zh">
{include file="public/head"/}
<style>
    .content{
        width: 100%;
        height: 807px;
        background-image: url(__CDN__/assets/store/images/background.png);
        font-size: 0;
    }
    .content .contentMain{
        width: 1200px;
        height: 807px;
        margin: 0 auto;
        overflow: hidden;
    }
    form .form-group .btn{
        padding: 0;
    }
    form .form-group .tipsInfo{
        position: absolute;
        width: 100%;
        height: 20px;
        font-size: 10px;
        color: red;
        top: 55px;
        left: 0;
    }
    /*信息验证框区域样式*/
    .content .contentMain .verificationBox{
        width: 511px;
        height: 456px;
        margin: 232px auto;
        background: rgba(255,255,255,1);
        box-shadow: 0 8px 16px rgba(24,36,36,0.09);
        border-radius:8px;
        overflow: hidden;
    }
    .content .contentMain .verificationBox img{
        display: block;
        width: 119px;
        height: 59px;
        margin: 40px auto;
    }
    form .form-group{
        margin: 0 30px 20px 30px;
        position: relative;
    }
    .content .contentMain .loginBox .formBox form .form-group .btn{
        padding: 0;
    }
    .content .contentMain .verificationBox .formBox form .form-group input{
        display: inline-block;
        height: 54px;
        box-shadow: none;
    }
    .content .contentMain .verificationBox .formBox form .form-group:nth-child(2) input{
        width: 330px;
        margin-right: 10px;
    }
    .content .contentMain .verificationBox .formBox form .form-group:nth-child(2) img{
        float: right;
        width: 110px;
        height: 54px;
        cursor: pointer;
        margin: 0;
    }
    .content .contentMain .verificationBox .formBox form .form-group:nth-child(3){
        margin-bottom: 30px;
    }
    .content .contentMain .verificationBox .formBox form .form-group:nth-child(3) input{
        width: 330px;
        margin-right: 10px;
    }
    .content .contentMain .verificationBox .formBox form .form-group:nth-child(3) .input-group-btn{
        float: right;
        width: 110px;
        height: 54px;
    }
    .content .contentMain .verificationBox .formBox form .form-group:nth-child(3) .input-group-btn .btn{
        width: 110px;
        height: 54px;
        background: rgba(0,159,142,1);
        color: rgba(255,255,255,1);
        border: 0;
        border-radius: 4px;
    }
    .content .contentMain .verificationBox .formBox form .btn-submit{
        width: 451px;
        height: 54px;
        margin: 0 30px 12px 30px;
        border: 0;
        color: rgba(255,255,255,1);
        background:rgba(0,159,142,1);
        border-radius: 4px;
    }

    /*新密码框区域样式*/
    .content .contentMain .newPswBox{
        display: none;
        width: 511px;
        height: 382px;
        margin: 232px auto;
        background: rgba(255,255,255,1);
        box-shadow: 0 8px 16px rgba(24,36,36,0.09);
        border-radius:8px;
        overflow: hidden;
    }
    .content .contentMain .newPswBox img{
        display: block;
        width: 119px;
        height: 59px;
        margin: 40px auto;
    }
    .content .contentMain .newPswBox .formBox form .form-group{
        margin: 0 30px 20px 30px;
    }
    .content .contentMain .newPswBox .formBox form .form-group input{
        display: inline-block;
        height: 54px;
        box-shadow: none;
    }
    .content .contentMain .newPswBox .formBox form .btn-submit{
        width: 451px;
        height: 54px;
        margin: 10px 30px 12px 30px;
        border: 0;
        color: rgba(255,255,255,1);
        background:rgba(0,159,142,1);
        border-radius: 4px;
    }
</style>
<body>
<!--公共头部-->
{include file="public/header"/}
<!--登录框-->
<div class="content">
    <div class="contentMain">

        <!--信息验证框-->
        <div class="verificationBox">
            <img src="__CDN__/assets/store/images/logo.png" alt="loginLogo" style="width: 130px;">

            <div class="formBox formBox">
                <form>
                    <div class="form-group">
                        <input type="text" class="form-control" id="phoneNum" placeholder="手机号" onblur="testPhoneNum()">
                        <span id="phoneNumTips" class="tipsInfo"></span>
                    </div>

                    <div class="form-group">
                        <input type="text" class="form-control" id="verificationCode" placeholder="请输入图形验证码" onblur="testImgCode()">
                        <span id="imgCodeTips" class="tipsInfo"></span>
                        <img src="{:captcha_src()}" alt="captcha" id="codeImg" onclick="this.src='{:captcha_src()}'">
                    </div>

                    <div class="form-group">
                        <input type="text" class="form-control" id="msgCode" placeholder="请输入短信验证码" onblur="testCode()">
                        <span id="msgCodeTips" class="tipsInfo"></span>
                        <span class="input-group-btn">
                            <span class="input-group-btn">
                            <button class="btn" type="button" onclick="sendMsg()">
                                <span id="countDown" class="countDown">发送验证码</span>
                            </button>
                        </span>
                        </span>
                    </div>
                    <button type="button" class="btn btn-submit" onclick="next()">下一步</button>
                </form>
            </div>
        </div>
        <!--新密码框-->
        <div class="newPswBox">
            <img src="__CDN__/assets/store/images/loginLogo.png" alt="loginLogo">

            <div class="formBox">
                <form>
                    <div class="form-group">
                        <input type="password" class="form-control" id="newPsw" placeholder="请输入新密码" onblur="testNewPsw()">
                        <span id="newPswTips" class="tipsInfo"></span>
                    </div>
                    <div class="form-group">
                        <input type="password" class="form-control" id="repeatNewPsw" placeholder="重复新密码" onblur="testRepeatNewPsw()">
                        <span id="repeatNewPswTips" class="tipsInfo"></span>
                    </div>
                    <button type="button" class="btn btn-submit" onclick="confirm()">确认</button>
                </form>
            </div>
        </div>
    </div>
    {include file="public/footer"/}
</div>
{include file="public/js"/}
<script>
    var interval;
    //校验手机号
    function testPhoneNum() {
        var reg = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/;
        var phoneNum = $('#phoneNum').val();
        if(!reg.test(phoneNum)){
            $('#phoneNumTips').html('请输入正确的手机号码');
            return false;
        }
        $('#phoneNumTips').html('');
        return true;
    }

    //校验图形验证码
    function testImgCode() {
        if($('#verificationCode').val().trim() == ''){
            $('#imgCodeTips').html('请输入图形验证码');
            return false;
        }
        $('#imgCodeTips').html('');
        return  true;
    }

    //校验短信验证码
    function testCode() {
        if($('#msgCode').val().trim() == ''){
            $('#msgCodeTips').html('请输入短信验证码');
            return false;
        }
        $('#msgCodeTips').html('');
        return  true;
    }

    //发送短信验证码
    function sendMsg() {
        testPhoneNum();
        testImgCode();
        var mobile = $('#phoneNum').val();
        var reg = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/;
        var verificationCode = $('#verificationCode').val();
        if(mobile == ''){
            toast('请输入手机号');
            return false;
        } else if(!reg.test(mobile)){
            toast('请输入正确手机号');
            return false;
        } else if(verificationCode == ''){
            toast('请输入图形验证码');
            return false;
        }
        if(!interval){
            $.ajax({
                url:"{:url('user/get_code2')}",
                type:"POST",
                data:{"mobile":mobile,"image_code":verificationCode},
                success:function(res){
                    console.log(res);
                    if(res.code == 1){
                        toast('验证码已发送请注意查看~');
                        var time = 60;
                        interval = setInterval(function () {
                            time--;
                            $("#countDown").html(time + '秒后重新发送');
                            if (time <= 0) {
                                clearInterval(interval);
                                $("#countDown").html('重新发送');
                                interval = undefined;
                            }
                        }, 1000);
                    }else{
                        toast(res.msg);
                    }
                },
                error:function(res){
                    toast('与服务器断开连接');
                }
            })
        }
    }

    //下一步
    function next() {
        testPhoneNum();
        testCode();
        var mobile = $('#phoneNum').val();
        var reg = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/;
        var code = $('#msgCode').val();
        if(mobile == ''){
            toast('请输入手机号');
            return false;
        } else if(!reg.test(mobile)){
            toast('请输入正确手机号');
            return false;
        } else if(code == ''){
            toast('请输入验证码');
            return false;
        }
        $.ajax({
            url:"{:url('user/next')}",
            type:"POST",
            data:{"mobile":mobile,"code":code},
            success:function(res){
                console.log(res);
                if(res.code == 1){
                    $('.verificationBox').hide();
                    $('.newPswBox').show();
                }else{
                    toast(res.msg);
                }
            },
            error:function(res){
                toast('与服务器断开连接');
            }
        });
    }

    //校验新密码
    function testNewPsw() {
        var psw_test = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$/;
        var psw = $('#newPsw').val();
        if(psw.trim() == ''){
            $('#newPswTips').html('请输入新密码');
            return false;
        }else if(!psw_test.test(psw)){
            $('#newPswTips').html('至少8个字符,包括1个大写字母,1个小写字母和1个数字');
            return false;
        }
        $('#newPswTips').html('');
        return true;
    }

    //校验重复新密码
    function testRepeatNewPsw() {
        if($('#repeatNewPsw').val().trim() == ''){
            $('#repeatNewPswTips').html('请重复输入新密码');
            return false;
        }
        if($('#newPsw').val() != $('#repeatNewPsw').val()){
            $('#repeatNewPswTips').html('两次密码不一致');
            return false;
        }
        var psw_test = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$/;
        if(!psw_test.test($('#repeatNewPsw').val().trim())){
            $('#newPswTips').html('至少8个字符,包括1个大写字母,1个小写字母和1个数字');
            return false;
        }
        $('#repeatNewPswTips').html('');
        return  true;
    }
    //确认修改新密码
    function confirm() {
        testPhoneNum();
        testCode();
        testNewPsw();
        testRepeatNewPsw();
        if(!testPhoneNum() || !testCode() || !testNewPsw() || !testRepeatNewPsw()){
            return false;
        }
        var mobile = $('#phoneNum').val();
        var newPsw = $('#newPsw').val();
        var repeatNewPsw = $('#repeatNewPsw').val();
        if(newPsw == ''){
            toast('请输入新密码~');
            return false;
        } else if(repeatNewPsw == ''){
            toast('请输入确认密码~');
            return false;
        } else if(repeatNewPsw != newPsw){
            toast('两次密码不一致~');
            return false;
        }
        $.ajax({
            url:"{:url('user/setting_password')}",
            type:"POST",
            data:{"mobile":mobile,"password":newPsw,"affirm_password":repeatNewPsw},
            success:function(res){
                console.log(res);
                if(res.code == 1){
                    toast('修改成功');
                    setTimeout(function(){
                        window.location.href = res.url;
                    },3000);
                }else{
                    toast(res.msg);
                }
            },
            error:function(res){
                toast('与服务器断开连接');
            }
        });
    }
</script>
</body>
</html>