js实现签署倒计时功能

 <i-button type="primary" shape="circle" @click="againSign" :disabled="!timeFlag" style="width: 200px">{{btnText}}</i-button>



<script>
    new Vue({
        el: '#app',
        data: function() {
            return{
                btnText:'我同意并签署该合同(10s)',
                timeFlag:false,
                downTime:'2',
                timer:null,
            }
        },
        mounted:function() {
            var _this = this;
             _this.againSignNew()
        },
        methods: {
            countDown:function(){
                var _this = this;
                var sys_second = _this.downTime
                _this.timer = setInterval(function () {
                        if (sys_second > 1) {
                            sys_second -= 1;
                            var second = Math.floor(sys_second % 60);
                            if (second > 0) {
                                if (second < 10) {
                                    second = second;
                                }
                                _this.btnText = "我同意并签署该合同(" + second + "s)";
                            }
                        } else {
                            clearInterval(_this.timer);
                            _this.timeFlag = true;
                            _this.btnText = "我同意并签署该合同";
                        }
                    },
                    1000);
            },
            againSignNew:function(){
                var _this = this;
                _this.againSignModel = true
                _this.timeFlag = false
                clearInterval(_this.timer);
                _this.btnText="我同意并签署该合同(" + _this.downTime + "s)";
                _this.countDown()
                $.ajax({
                    type: 'post',
                    url: '../../data/companyNotice.json',
                    data: {
                        type:_this.contractType,
                    },
                    dataType: 'json',
                    success: function (data) {
                        console.log(111)
                    },
                    error: function () {
                        _this.$Message.error('请求失败,请稍后重试!')
                    }
                });
            },
        }
    })
</script>

图片示例:初始化:

 倒计时结束:

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值