1、根据后端的返回的总秒数据,然后把秒转成时分秒倒计时
setClock:function(time){
var that=this, sec= parseInt(time) , clockCount={}, strTimer="";
clockCount=setInterval(function(){
if(sec==0){
$(".js-count-down").html("活动已经结束");
clearInterval(clockCount);
return false;
}
strTimer = that.secondToDate(sec);
$(".js-count-down").html(strTimer);
sec--;
},1000)
},
secondToDate:function(result){
var h = Math.floor(result / 3600) < 10 ? '0'+Math.floor(result / 3600) : Math.floor(result / 3600);
var m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60));
var s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60));
if(h==0){
result = m + ":" + s;
}else{
result = h+':'+m + ":" + s
}
return result;
},