var point = Math.floor(Math.random()*1000);
function TimeDown(id, endDateStr,mainid,p) {
//结束时间
var endDate = new Date(endDateStr);
//当前时间
var nowDate = new Date();
if(p != point){
return ;
}
if(nowDate >= endDate){
var disid1 = 'main'+mainid;
var disid2 = 'hr'+mainid;
$("#"+disid1).css('display','none');
$("#"+disid2).css('display','none');
var tnum = $('#index_m_head_num').html();
var tanum = Number(tnum) - 1;
$('#index_m_head_num').html(tanum);
return;
}
//相差的总秒数
var totalSeconds = parseInt((endDate - nowDate) / 1000);
//天数
var days = Math.floor(totalSeconds / (60 * 60 * 24));
//取模(余数)
var modulo = totalSeconds % (60 * 60 * 24);
//小时数
var hours = Math.floor(modulo / (60 * 60));
modulo = modulo % (60 * 60);
//分钟
var minutes = Math.floor(modulo / 60);
//秒
var seconds = modulo % 60;
//输出到页面
document.getElementById(id).innerHTML = "过期:" + minutes + "分钟" + seconds + "秒";
//延迟一秒执行自己
setTimeout(function () {
TimeDown(id, endDateStr,mainid,p);
}, 1000)
}
function loadTask(){
mui.ajax(__api_url+'/Index/tasklist', {
data:{
},
dataType: 'json',
type: 'post',
async: false,
headers: {'Content-Type': 'application/json'},
success: function (jsondata) {
if(jsondata.code == '1'){
$('#index_m_head_num').html(jsondata.data.count);
var ihtml = "";
var datalist = jsondata.data.list;
for(var i=0;i<datalist.length;i++){
var outid = 'out'+datalist[i].id;
var disid1 = 'main'+datalist[i].id;
var disid2 = 'hr'+datalist[i].id;
ihtml+='<div class="index_m_con_list" id="';
ihtml+=disid1;
ihtml+='">';
ihtml+='<div class="index_m_con_list_1">单号:';
ihtml+=datalist[i].order_no;
ihtml+='</div>';
ihtml+='<div class="index_m_con_list_2">手机号:';
ihtml+=datalist[i].tel;
ihtml+='</div>';
ihtml+='<div class="index_m_con_list_3" id="';
ihtml+=outid;
ihtml+='">过期:';
ihtml+='</div>';
ihtml+='<div class="index_m_con_list_4">¥';
ihtml+=datalist[i].money;
ihtml+='</div>';
ihtml+='<div class="index_m_con_list_5">';
ihtml+='<button type="button" class="mui-btn mui-btn-success" onclick="taptask('+datalist[i].id+')">点击接单</button>';
ihtml+='</div>';
ihtml+='</div>';
ihtml+='<hr id="';
ihtml+=disid2;
ihtml+='">';
}
$('#index_m_con_id').html(ihtml);
point = Math.floor(Math.random()*1000);
for(var i=0;i<datalist.length;i++){
var outid = 'out'+datalist[i].id;
TimeDown(outid, datalist[i].endpoint,datalist[i].id,point);
}
}
},
});
}