当前位置 博文首页 > 文章内容

    vue 移动端手写手机验证码登录

    作者: 栏目:未分类 时间:2020-07-28 14:02:17

    本站于2023年9月4日。收到“大连君*****咨询有限公司”通知
    说我们IIS7站长博客,有一篇博文用了他们的图片。
    要求我们给他们一张图片6000元。要不然法院告我们

    为避免不必要的麻烦,IIS7站长博客,全站内容图片下架、并积极应诉
    博文内容全部不再显示,请需要相关资讯的站长朋友到必应搜索。谢谢!

    另祝:版权碰瓷诈骗团伙,早日弃暗投明。

    相关新闻:借版权之名、行诈骗之实,周某因犯诈骗罪被判处有期徒刑十一年六个月

    叹!百花齐放的时代,渐行渐远!



    <template>
        <div class="contentLogin">
            <!-- <div class="login">登录</div> -->
            <div class="contrain">
                <form class="form" action="">
                    <div class="formItem">
                        <div class="label">姓名</div>
                        <div class="import">
                            <input class="name" ref="name" type="text" placeholder="请输入...">
                        </div>
                    </div>
                    <div class="formItem">
                        <div class="label">手机</div>
                        <div class="import">
                            <input class="phone" ref="phone" type="text" placeholder="请输入...">
                        </div>
                    </div>
                    <div class="formItem">
                        <div class="label">验证码</div>
                        <div class="import">
                            <input class="code" ref="code" type="text" placeholder="请输入...">
                            <button type="button" v-if="btnTitle" class="send" @click='getCode' :disabled='disabled'>{{btnTitle}}</button>
                        </div>
                    </div>
                    <input class="simulation" @click='present'  type="button" value="开始模拟" >
                    <img class="logo" src="./../assets/img/logo.png" alt="">
                </form>
            </div>
        </div>
    </template>
    

      

    export default {
            data(){
                return{
                    name:'',
                    phone:'',
                    code:'',
                    btnTitle:'获取验证码',
                    disabled:false,
                }
            },
            methods:{
                // 开始模拟
                present(){
                    if(this.$refs.name.value ==''){
                        this.$toast('请输入用户名');
                        return false
                    }
                    if(!/^1[345678]\d{9}$/.test(this.$refs.phone.value)){
                        this.$toast('请输入正确的手机号')
                        return false
                    }
                    if(this.$refs.code.value == ''){
                        this.$toast('请输入验证码')
                        return false
                    }
                    this.$http.post('https://hfmtool.staff.xdf.cn/hl/free/recruit/saveUserInfo',{
                        studentName:this.$refs.name.value,
                        phone:this.$refs.phone.value,
                        smsCode:this.$refs.code.value
                    }).then(res =>{
                        if(res.data.code == '1'){
                            // this.$store.state.studentName = res.data.data.studentName
                            this.$router.push({ name:'StepOne'})
                        }else{
                           this.$toast(res.data.message);
                        }
                    })
                },
                // 获取验证码
                getCode(){
                    if(!/^1[345678]\d{9}$/.test(this.$refs.phone.value)){
                        this.$toast('手机号码错误');
                    }else{
                        this.validateBtn()
                        this.$http.post('https://hfmtool.staff.xdf.cn/hl/free/recruit/sendPhoneVerifyCode',{
                            phone:this.$refs.phone.value
                        }).then(res =>{
                            // console.log(res)
                            if(res.data.code == '1'){
                                this.$toast("验证码已发送,请注意查收。");
                            }else{
                                this.$toast(res.data.message);
                            }
                        })
                    }  
                },
                validateBtn(){
                    //倒计时
                    let time = 60;
                    let timer = setInterval(() => {
                    if(time == 0) {
                        clearInterval(timer);
                        this.disabled = false;
                        this.btnTitle = "获取验证码";
                    } else {
                        this.btnTitle =time + '秒后重试';
                        this.disabled = true;
                        time--
                    }
                    },1000)
                },
    
            },
            created(){
            }
        }
    

      

    .contentLogin{
        width:100%;
        height:100%;
        background: url('./../img/loginBg.png') no-repeat center center;
        background-size: 100% 100%;
        position: relative;
        box-sizing: border-box;
        padding-bottom: 30px;
    }
    .login{
        width: 100%;
        line-height: 70px;
        text-align: center;
        color: #fff;
        font-size: 36px;
        /* font-weight: 600; */
        position: absolute;
        left: 0;
        top: 2%;
    }
    .contrain{
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        top: 50%;
        width: 100%;
        background: #fff;
        border-top-left-radius: 40px;
        border-top-right-radius: 40px;
    }
    .form{
        width:690px;
        overflow: hidden;
        margin: 0 auto;
        box-sizing: border-box;
        /* padding-top: 75px; */
        /* background: #c00; */
    }
    .formItem{
        width: 100%;
        height: 85px;
        border: 1px solid #ccc;
        border-radius: 10px;
        box-sizing: border-box;
        padding:0 15px;
        margin-bottom: 32px;
        display: flex;
        overflow: hidden;
    }
    .form .formItem:nth-child(1){
        margin-top: 75px;
    }
    .form .formItem:nth-child(3){
        margin-bottom: 100px;
    }
    .label{
        width: 110px;
        height: 85px;
        line-height: 85px;
        font-size: 26px;
        color: #313952;
        font-weight: 600;
    }
    input:focus{outline:none;}
    .import{
        display: flex;
        width:calc(100% - 110px);
        box-sizing: border-box;
        align-items: center;
        /* padding-top: 4px 0; */
        /* height: 85px; */
        /* align-items: center; */
    }
    .import input{
        display: block;
        width: 100%;
        /* margin-top: 4px; */
        height: 76px;
        line-height: 76px;
        background-color: #fff;
        /* border: none; */
        font-size: 26px;
    }
    /* .name,
    .phone{
        
    } */
    .import .code{
        display: block;
        width: 350px !important;
        margin-top: 2px;
        height: 74px;
        line-height: 74px;
        /* border: none; */
        font-size: 26px;
        background-color: #fff;
    }
    .send{
        width: 200px !important;
        height: 76px;
        line-height: 76px;
        text-align: center;
        font-size: 26px;
        color: #e54b5b;
        background: none;
    }
    .simulation{
        display: block;
        width: 610px;
        font-size: 34px;
        height: 85px;
        color: #fff;
        border-radius:15px;
        background: #ee4657;
        margin: 0 auto;
        /* margin-top: 100px; */
    }
    .logo{
        display: block;
        border: none !important;
        margin: 50px auto 30px;
        width: 142px;
        height: 56px;
    }