多状态下 支付倒计时
<div class="headBox" id="headBox">
<div class="status" id="unfilled_orders">
<div class="sta">
<span class="staName">待发货</span>
</div>
<p>买家已付款,卖家未发货</p>
</div>
<div class="status" id="canceled">
<div class="sta">
<span class="staName">已取消</span>
</div>
<p>该订单已取消</p>
</div>
<div class="status" id="unpaid">
<div class="sta">
<span class="staName">待付款</span>
<span class="peice">¥780.00元</span>
</div>
<p id="timer">等待买家付款,剩余15分00秒 </p>
</div>
</div>
$(document).ready(function(){
if($('#timer').length>0){
console.log('存在执行')
timer()
}else {
console.log('不存在')
}
});
var maxtime = 15 * 60;
function CountDown() {
if (maxtime >= 0) {
minutes = Math.floor(maxtime / 60);
seconds = Math.floor(maxtime % 60);
msg = "等待买家付款,剩余" + minutes + "分" + seconds + "秒";
$('#timer').text(msg)
--maxtime;
} else {
clearInterval(timer);
$('#unpaid div').replaceWith('<span class="staName">交易关闭</span>')
$('#timer').text('订单超时,交易已关闭')
$('.newFoot').hide()
}
}
function timer(){
setInterval("CountDown()", 1000);
}