Browse Source

修复倒计时相关bug

pull/9/head
Jason 3 years ago
parent
commit
f4f2908422
  1. 2
      view/js/layui.js
  2. 11810
      view/js/layui_build.js
  3. 34
      view/templates/index/wait_deliver_list.html

2
view/js/layui.js

File diff suppressed because one or more lines are too long

11810
view/js/layui_build.js

File diff suppressed because it is too large

34
view/templates/index/wait_deliver_list.html

@ -98,7 +98,7 @@ layui.use(['element', 'layer', 'util', 'table'], function(){
,title: '用户数据表'
,totalRow: false
,className:'deliver_remind_list_table_class'
,limit:5
,limit:20
,cols: [[
{field:'goods_name', title:'商品名称',
templet: function(d){
@ -110,7 +110,7 @@ layui.use(['element', 'layer', 'util', 'table'], function(){
}}
,{field:'pay_time', title:'销售时间/倒计时'
,templet: function(d){
if(d.is_show_count_down == true) return '<label id="count_down_wait_'+d.order_sn+'" content="'+d.pay_time+'" class="count_down_wait"><span id="count-down-time-'+d.order_sn+'">倒计时:'+d.count_down+'</span>|'+d.count_down+'</label>';
if(d.is_show_count_down == true) return '<label id="count_down_wait_'+d.order_sn+'" content="'+d.pay_time+'" class="count_down_wait"><span id="count-down-time-'+d.order_sn+'">倒计时:'+d.count_down+'</span></label>';
return '<span>'+d.pay_time+'</span>';
}}
,{field:'pay_amount', title:'支付金额(元)'}
@ -136,7 +136,7 @@ layui.use(['element', 'layer', 'util', 'table'], function(){
//删除翻页遗漏的定时器,避免内存泄露
for(let key of intervalsMap.keys()){
clearInterval(intervalsMap.get(key));
intervalsMap.delete(key)
intervalsMap.delete(key);
}
var data = res.data;
@ -191,7 +191,6 @@ layui.use(['element', 'layer', 'util', 'table'], function(){
});
}
if(data[i].is_urge == true){
$('#remind_time_'+data[i].order_sn).hover(function(){
var hcontent = $(this).attr('content');
@ -214,26 +213,15 @@ layui.use(['element', 'layer', 'util', 'table'], function(){
var countDownTime = (parseInt(coumtTimeList[0]) * 3600 + parseInt(coumtTimeList[1]) * 60 + parseInt(coumtTimeList[2])) * 1000;
var startTime = new Date(2099,1,1).getTime();
var endTime = startTime+countDownTime;
var indexcount = -1;
var firstCallBackEnd = false;
util.countdown(endTime, startTime, function(date, st, timer){
util.countdown(endTime, startTime, data[i].order_sn, function(date, st, timer, order_sn){
var remainTimeStr = (date[0]*24 + date[1]) + ':' + date[2] + ':' + date[3];
++indexcount;
if(indexcount >= countDownList.length) indexcount = 0;
if(indexcount>0 || countDownList.length == 1) firstCallBackEnd = true;
if(indexcount>=0 && firstCallBackEnd){
var countDownIndx = indexcount-1;
if(indexcount == 0) countDownIndx = countDownList.length-1;
var countDownId = '#count-down-time-'+countDownList[countDownIndx].order_sn;
var remainTimeStr = (date[0]*24 + date[1]) + ':' + date[2] + ':' + date[3];
intervalsMap.set(countDownIndx, timer);
if(date[0]*24 == 0 && date[1] == 0 && date[2] == 0 && date[3] == 0) {
countDownList.splice(countDownIndx,1);
firstCallBackEnd = false;
}
var countDownId = '#count-down-time-'+order_sn;
intervalsMap.set(order_sn, timer);
if(remainTimeStr == '0:0:0'){
var order_pay_time = $('#count_down_wait_'+order_sn).attr('content');
$('#count_down_wait_'+order_sn).hide();
$('#count_down_wait_'+order_sn).after('<span>'+order_pay_time+'</span>');
}else{
layui.$(countDownId).html('倒计时:'+ remainTimeStr);
}
});

Loading…
Cancel
Save