美文网首页
发送验证码

发送验证码

作者: 程序媛_ | 来源:发表于2020-08-25 10:09 被阅读0次

    // 验证码

    countDown () {

    this.hqyzm = this.totalTime + 's后重新发送' //这里解决60秒不见了的问题

    let clock = window.setInterval(() => {

      this.totalTime--

      this.hqyzm = this.totalTime + 's后重新发送'

      if (this.totalTime < 0) {    //当倒计时小于0时清除定时器

        window.clearInterval(clock)

        this.hqyzm = '重新发送验证码'

        this.totalTime = 60

        }

    },1000)

    },

    // 发送验证码

    sendCode:function(){

    var that=this;

    var setTime=0;

    if(!that.isSend){

    that.isSend=true;

    setTime=setInterval(function(){

    that.wait--;

    that.sendColor="color:#999";

    that.codeFont=that.wait+"重新发送";

    if(that.wait==0){

    clearInterval(setTime);

    that.codeFont="获取验证码";

    that.isSend=false;

    that.wait=60;

    that.sendColor="color:#ff5b01";

    }

    },1000)

    }

    }

    相关文章

      网友评论

          本文标题:发送验证码

          本文链接:https://www.haomeiwen.com/subject/keuajktx.html