<body contenteditable="true" spellcheck="false" style="height: 400px;">
<div class="timespan" style="background:#F5EEF9;width: 100%;padding: 5px;height:30px;"></div>
</body>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
//当前时间
var timestamp = new Date().getTime()/1000;
//秒杀开始时间
var startTime=${seckillDate.result[0].start_time};
//秒杀结束时间
var endTime=${seckillDate.result[0].end_time};
//秒杀当前数量
var secnum=${seckillDate.result[0].seckill_number};
var intDiff = parseInt(startTime-timestamp);//倒计时总秒数量
var endDiff = parseInt(endTime-timestamp);//结束倒计时总秒数量
function timer(intDiff){
if(intDiff>=0&&intDiff<=60){
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 (minute <= 9) minute = '0' + minute;
if (second <= 9) second = '0' + second;
$('.timespan').html("倒计时:"+ second + "秒");
intDiff--;
if(intDiff<0){
location.reload();
}
}, 1000);
}
if(intDiff > 60){
var st=$('#startTime').val();
$('.timespan').html("开始时间:"+st);
}
if(intDiff<0&&endDiff>0){
if(secnum>0){
$('.timespan').hide();
}else{
$('.timespan').html("商品已售完");
}
}
if(endDiff<0){
$('.timespan').html("秒杀已结束");
}
}
$(function(){
timer(intDiff);
});
</script>