// 倒計時
var intDiff = parseInt(${countTime!0});// 倒计时总秒数量
timer(intDiff);
function timer(intDiff) {
window.setInterval(function () {
var day = 0,
hour = 0,
minute = 0,
second = 0;//时间默认值
if (intDiff > 0) {
day = Math.floor(intDiff / (60 * 60 * 24));
hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
}
if(day < 10 && day > 1){
day = "0" + day;
}
if(minute < 10){
minute = "0" + minute;
}
if(hour < 10){
hour = "0" + hour;
}
if(second < 10){
second = "0" + second;
}
if (day == 0) {
$(".remaining_time>span").html("<span>" + hour + "时</span><span>" + minute + "分</span><span>" + second + "秒</span>")
} else {
$(".remaining_time>span").html(day + "天" + "<span>" + hour + "时</span><span>" + minute + "分</span><span>" + second + "秒</span>");
}
$('.day_show').html(day + "天");
$('.hour_show').html('<s id="h"></s>' + hour + '时');
$('.minute_show').html('<s></s>' + minute + '分');
$('.second_show').html('<s></s>' + second + '秒');
intDiff--;
//当倒计时=0时,刷新整个页面
if(intDiff==0){
$.ajax({
type : "POST",
url : domain+"/product/presell.html",
data : {productId:$("#productId").val()},
dataType : "json",
success : function(data) {
if(data.success){
location.reload();
}
},
error : function() {
location.reload();
//$.dialog('alert','提示','数据加载失败!',2000);
}
});
//location.reload();
}
}, 1000);
}