如果有天的存在,就是天,时,分,如果没有天的存在,就是时,分,秒
据开抢: { {el.days0}}{ {el.days}}天 { {el.hours1}}{ {el.hours2}}时 { {el.minutes1}}{ {el.minutes2}}分 { {el.seconds1}}{ {el.seconds2}}秒
下面是js代码:
setInterval(function() { vmi.tryGoodspRreviewList.forEach(function(val, index) { val.startleft--; var gettime = vmi.daojishiHandle(val.startleft); val.days0 = gettime.days0 val.days = gettime.days val.hours1 = gettime.hours1; val.hours2 = gettime.hours2; val.minutes1 = gettime.minutes1; val.minutes2 = gettime.minutes2; val.seconds1 = gettime.seconds1; val.seconds2 = gettime.seconds2; }) }, 1000)
daojishiHandle:function(val) { var allday = parseInt(val / 24 / 60 / 60) var time = val % (24 * 3600) var hour = parseInt(time / 60 / 60); var minutes = parseInt(time / 60 - hour * 60); var seconds = time - hour * 60 * 60 - minutes * 60; var day2 = parseInt(allday / 10) var day1 = allday % 10 var hour0 = parseInt(hour / 10); var hour1 = hour % 10; var minute0 = parseInt(minutes / 10); var minute1 = minutes % 10; var second0 = parseInt(seconds / 10); var second1 = seconds % 10; return { days0: day2, days: day1, hours1: hour0, hours2: hour1, minutes1: minute0, minutes2: minute1, seconds1: second0, seconds2: second1 } },
这个倒计时花了很多时间,请笑纳,如果有更好的,更简单的正确代码,欢迎分享~~~~