importsc
onmessage = function(e) {
console.log(e.data);
fnAjaxPostCheckTraveler(e.data['idcard'], e.data['startdate'], e.data['day'])
}
function fnAjaxPostCheckTraveler(idcard, startdate, day) {
$.ajax({
type: 'POST',
url: "__URL__{:U('InfoInsert/ajaxCheckTraveler')}",
data: { 'idcard': idcard, 'startdate': startdate },
async: false,
success: function(result) {
try {
if (result[0]['max(enddate)'] == null) {
postMessage(true);
return;
}
if (result[0]['max(enddate)'] != 'null') {
var d1 = new Date(startdate.replace(/\-/g, "\/"));
var d2 = new Date(result[0]['max(startdate)'].replace(/\-/g, "\/"));
var d3 = new Date(result[0]['max(enddate)'].replace(/\-/g, "\/"));
if (d1 > d3 || day <= ((d2 - d1) / 86400000)) {
postMessage(true);
return;
}
tipsDate = result[0]['max(startdate)'] + "-" + result[0]['max(enddate)'];
postMessage(tipsDate);
}
} catch (e) {}
},
dataType: 'json'
});
}
//主线程JS
function fnAjaxPostCheckTraveler(idcard,startdate,day) {
var worker = new Worker("__D__/js/AjaxCheckTraveler.js"); //将第2步新建的空的worker.js定义成工作线程(※1)
worker.postMessage({idcard,startdate,day}); //主线程向工作线程发送消息(※2)
worker.onmessage = function(event) { //工作线程成功完成工作后的回调函数(※3)
console.log(event);
}
}
//config文件内容:
<?php
return array(
//'配置项'=>'配置值'
'TMPL_PARSE_STRING'=> array(
'__WEBNAME__'=>'采集系统',//ti
'__B__'=>SITE_URL.'/Public/bower_components',
'__D__'=>SITE_URL.'/Public/dist',
'__P__'=>SITE_URL.'/Public/plugins',
'__Public__'=>SITE_URL.'/Public',
'__URL__'=>SITE_URL,
'SESSION_AUTO_START'=>true,
'SESSION_OPTIONS'=>array('expire'=>3600),
'DEFAULT_MODULE'=>'Home',
'URL_CASE_INSENSITIVE'=>true,//URL不区分大小写
'URL_MODEL'=>1,//INFOPATH模式
'URL_HTML_SUFFIX'=>'html'
)
);
最佳答案