时间戳换成一个一个跳() 0 1 : 1 5时 : 2 2分 : 1 5跳动秒)

    注意: 1.手机锁屏后定时器会停止, 直至开屏才继续,结果会错误, 所以需要在百度找解决方法( vux的倒计时不存在这个问题 )

    例子 1(单个时间) :
        var c = Date .parse(new Date() ) ;
        var e = Date .parse(new Date(_this.produce.fddDateE.replace(/-/g, "/") )) ;
        if ((e > c) && (_this.produce.fdbStop == 0) ) {//可用
             _this.s = e - c ;
             _this .cutDown() ;
             _this.timer = setInterval(function () {
                 _this .s -= 1000 ;
                if (_this.s <= 0) {
                     _this.s = 0 ;
                     _this .cutDown() ;
                    clearInterval(_this.timer) ;
                 }
             }, 1000 ) ;
         }

        cutDown() {
            var demp = parseInt(this.s/1000/60/60/24) ;
            this .cutDownArray[0] = Math .floor(demp/10) ; //0
            this .cutDownArray[1] = demp % 10 ;         //1天
             demp = parseInt(this.s/1000/60/60%24) ;
            this .cutDownArray[2] = Math .floor(demp/10) ; //1
            this .cutDownArray[3] = demp % 10 ;         //5时
             demp = parseInt(this.s/1000/60%60) ;
            this .cutDownArray[4] = Math .floor(demp/10) ; //2
            this .cutDownArray[5] = demp % 10 ;         //2分
             demp = parseInt(this.s/1000%60) ;
            this .cutDownArray[6] = Math .floor(demp/10) ; //1
            this .cutDownArray[7] = demp % 10 ;         //5秒
         }

    例子 2(循环数据都有各自的时间) :
         this.VoucherList = res .data ;
        for(var i=0;i<res.data.length;i++) {

            if(res.data[i].mvouchermovieOverDate) {
                 this.time1 = res .data[i] .mvouchermovieOverDate
                var c = Date .parse(new Date() ) ;
                var e = Date .parse(new Date(res.data[i].mvouchermovieOverDate.replace(/-/g, "/") )) ;
                if ((e > c) && (res.data[i].fdiImportant == 1) ) {//可用
                     this.s = e - c ;
                    this .cutDown(res.data[i]['ID']) ;
                    var _i=i
                    res .data[i] .time = setInterval( () => { //开始定时器
                        this .s -= 1000 ;
                        this .cutDown(res.data[_i]['ID']) ;
                        if (this.s <= 0) {
                             this.s = 0 ;
                            clearInterval(res.data[_i]['ID']) ;
                         }
                     }, 1000 ) ;
                 }
             }
         }

        cutDown(voucherID) {
            var demp = parseInt(this.s/1000/60/60/24) ;
            this .cutDownArray[0] = Math .floor(demp/10) ; //0
            this .cutDownArray[1] = demp % 10 ;         //1天
             demp = parseInt(this.s/1000/60/60%24) ;
            this .cutDownArray[2] = Math .floor(demp/10) ; //1
            this .cutDownArray[3] = demp % 10 ;         //5时
             demp = parseInt(this.s/1000/60%60) ;
            this .cutDownArray[4] = Math .floor(demp/10) ; //2
            this .cutDownArray[5] = demp % 10 ;         //2分
             demp = parseInt(this.s/1000%60) ;
            this .cutDownArray[6] = Math .floor(demp/10) ; //1
            this .cutDownArray[7] = demp % 10 ;         //5秒
            for(var i=0;i<this.VoucherList.length;i++) {
                if(this.VoucherList[i]['ID'] == voucherID) {
                    this .VoucherList[i] .intervalTime = ""
                    this .VoucherList[i] .intervalTime = this .cutDownArray
                 }
             }
         },
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值