|
@ -52,14 +52,8 @@ layui.use(['element', 'layer', 'util', 'table'], function(){ |
|
|
,table = layui.table |
|
|
,table = layui.table |
|
|
,$ = layui.$; |
|
|
,$ = layui.$; |
|
|
|
|
|
|
|
|
//示例 |
|
|
//清除翻页后上一页遗漏的定时器 |
|
|
var endTime = new Date(2099,1,1).getTime() //假设为结束日期 |
|
|
var intervalsMap = new Map(); |
|
|
,serverTime = new Date().getTime(); //假设为当前服务器时间,这里采用的是本地时间,实际使用一般是取服务端的 |
|
|
|
|
|
|
|
|
|
|
|
util.countdown(endTime, serverTime, function(date, serverTime, timer){ |
|
|
|
|
|
var str = (date[0]*24 + date[1]) + ':' + date[2] + ':' + date[3]; |
|
|
|
|
|
layui.$('#test').html('倒计时:'+ str); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
util.event('lay-header-event', { |
|
|
util.event('lay-header-event', { |
|
|
menuLeft: function(othis){ |
|
|
menuLeft: function(othis){ |
|
@ -104,7 +98,7 @@ layui.use(['element', 'layer', 'util', 'table'], function(){ |
|
|
,title: '用户数据表' |
|
|
,title: '用户数据表' |
|
|
,totalRow: false |
|
|
,totalRow: false |
|
|
,className:'deliver_remind_list_table_class' |
|
|
,className:'deliver_remind_list_table_class' |
|
|
,limit:20 |
|
|
,limit:5 |
|
|
,cols: [[ |
|
|
,cols: [[ |
|
|
{field:'goods_name', title:'商品名称', |
|
|
{field:'goods_name', title:'商品名称', |
|
|
templet: function(d){ |
|
|
templet: function(d){ |
|
@ -116,7 +110,7 @@ layui.use(['element', 'layer', 'util', 'table'], function(){ |
|
|
}} |
|
|
}} |
|
|
,{field:'pay_time', title:'销售时间/倒计时' |
|
|
,{field:'pay_time', title:'销售时间/倒计时' |
|
|
,templet: function(d){ |
|
|
,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">倒计时:'+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>|'+d.count_down+'</label>'; |
|
|
return '<span>'+d.pay_time+'</span>'; |
|
|
return '<span>'+d.pay_time+'</span>'; |
|
|
}} |
|
|
}} |
|
|
,{field:'pay_amount', title:'支付金额(元)'} |
|
|
,{field:'pay_amount', title:'支付金额(元)'} |
|
@ -139,6 +133,12 @@ layui.use(['element', 'layer', 'util', 'table'], function(){ |
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
done: function(res, curr, count){ |
|
|
done: function(res, curr, count){ |
|
|
|
|
|
//删除翻页遗漏的定时器,避免内存泄露 |
|
|
|
|
|
for(let key of intervalsMap.keys()){ |
|
|
|
|
|
clearInterval(intervalsMap.get(key)); |
|
|
|
|
|
intervalsMap.delete(key) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var data = res.data; |
|
|
var data = res.data; |
|
|
try { |
|
|
try { |
|
|
if(data == undefined || data.length<=0){ |
|
|
if(data == undefined || data.length<=0){ |
|
@ -153,6 +153,13 @@ layui.use(['element', 'layer', 'util', 'table'], function(){ |
|
|
$('.admin-blank-table').show(); |
|
|
$('.admin-blank-table').show(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var countDownList = new Array(); |
|
|
|
|
|
for(var i=0; i<data.length; i++){ |
|
|
|
|
|
if(data[i].is_show_count_down == true){ |
|
|
|
|
|
countDownList.push(data[i]); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
for(var i=0; i<data.length; i++){ |
|
|
for(var i=0; i<data.length; i++){ |
|
|
var tid = data[i].order_sn; |
|
|
var tid = data[i].order_sn; |
|
|
var clipboard = new ClipboardJS('.admin-table-td-outter-'+tid); |
|
|
var clipboard = new ClipboardJS('.admin-table-td-outter-'+tid); |
|
@ -200,6 +207,37 @@ layui.use(['element', 'layer', 'util', 'table'], function(){ |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var orderSnObjec = new Object(); |
|
|
|
|
|
orderSnObjec.order_sn = data[i].order_sn; |
|
|
|
|
|
if(data[i].is_show_count_down == true){ |
|
|
|
|
|
var coumtTimeList = data[i].count_down.split(':'); |
|
|
|
|
|
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){ |
|
|
|
|
|
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; |
|
|
|
|
|
} |
|
|
|
|
|
layui.$(countDownId).html('倒计时:'+ remainTimeStr); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|