HTML5(多条未支付订单倒计时将自动删除)

it2022-12-30  59

多条未支付订单倒计时将自动删除

<script type="text/javascript" src="WAP_IMG/stact/js/jquery-1.7.2.min.js"></script> <div class="order_hao" data-type="order_expire_time" style="width: 100%" > <block class="time" style="float: left;" left_time_int="{$vo.huodonday}"><block class="pngfix">&nbsp;</block>-</block> <div class="order_tz" >待付款</div> </div> `` ```javascript <script> $(function() { //启用过期时钟 order_expire_time(); }); //倒计时 function counterClock(left_time) { var left_time = parseInt(left_time); var days_second = 86400; //每天时间 var hours_second = days_second / 24; var minute_second = hours_second / 60; var str = ''; if(left_time > 0) { var days = parseInt(left_time / days_second); str += (days > 0) ? days + '天' : ''; var hours = parseInt((left_time - days * days_second) / hours_second); str += hours > 0 ? hours + '小时' : ''; var minutes = parseInt((left_time - days * days_second - hours_second * hours) / minute_second); str += minutes > 0 ? minutes + '分钟' : ''; second = left_time - days * days_second - hours_second * hours - minutes * minute_second; str += second + '秒后未支付订单将自动删除'; } return str; } //订单过期时间 function order_expire_time() { $('#transaction [data-type="order_expire_time"],#order_status_show').each(function() { var time_obj = $(this).find('.time'); var left_time_int = time_obj.attr('left_time_int'); var timestamp4 = new Date(left_time_int); if(left_time_int) { var time_string = counterClock(left_time_int); if(time_string == '') time_obj.html('<block class="pngfix">&nbsp;</block>已关闭'); else { time_obj.html('<block class="pngfix">&nbsp;</block>' + time_string); time_obj.attr('left_time_int', left_time_int - 1); } } }); window.setTimeout(function() { order_expire_time(); }, 1000); } </script>
最新回复(0)