首页 > 其他 > 详细

60秒倒计时

时间:2020-05-18 16:36:17      阅读:38      评论:0      收藏:0      [点我收藏+]
{
      var re = /^(0|86|17951)?(13[0-9]|15[0123456789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
      if (re.test(this.ruleForm.phone)) {
        // 填写正确后,开始发送信息,倒计时
        const TIME_COUNT = 60;
        // 判断时间计时是否存在,不存在则赋值60,不显示发送验证码按钮,计时器启动循环
        if (!this.timer) {
          this.count = TIME_COUNT;
          this.show = false;
          this.Tim = setTimeout(() => {
            this.show = true;
          }, 60000);
          this.timer = setInterval(() => {
            if (this.count > 0 && this.count <= TIME_COUNT) {
              if (this.count == 60) {
                // 点击发送验证码(自己的函数)
                this.cms_fs();
              }
              this.count--;
            } else {
              // 计时器为0的时候显示发送验证码按钮,清空计时器
              this.show = true;
              clearInterval(this.timer);
              this.timer = null;
              return false;
            }
          }, 1000);
        }
      } else {
        // 手机存在,或者手机没有正确填写
        this.show = true;
        this.$message.error("请填写正确手机号!");
      }
    }

60秒倒计时

原文:https://www.cnblogs.com/wulicute-TS/p/12911013.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!