/** * Created by Administrator on 2021/4/5. */ define(['jquery', "template", "Tools", "biddingApi", "itemsApi"], function ($, template, Tools ) { //数据存储 var module = { data: { timeArray: { d: '', h: '', m: '', s: '', }, timer:null, setimer:null, outProjectInformationDetail:{} }, }; var tools = new Tools(); module.init = function (page) { tools.doGet(outProject + '/id/'+getQueryVariable('id'), {}, module.outProjectInformation,true); tools.doGet(webConfig, {}, module.webConfigInformation, true) var nowTime = new Date($.ajax({type:'HEAD',async:false,data:{i: Date.parse(new Date())}}).getResponseHeader("Date")); $("#nowDateNYR").html(nowTime.getFullYear()+'.'+(nowTime.getMonth()+1)+'.'+nowTime.getDate()) setInterval(function () { var nowTime = new Date($.ajax({type:'HEAD',async:false,data:{i: Date.parse(new Date())}}).getResponseHeader("Date")); $("#nowDateSFM").html(nowTime.toLocaleTimeString()); $("#nowTime").html('服务器时间:'+nowTime.getFullYear()+'.'+(nowTime.getMonth()+1)+'.'+nowTime.getDate()+' '+nowTime.toLocaleTimeString()); },1000) tools.doGet(outProject + '/id/'+getQueryVariable('id'), {}, module.outProjectInformation,true); setInterval(function (){ tools.doGet(biddinglist, {projectId:getQueryVariable('id')}, module.biddinglistInformation,true); tools.doGet(outProject + '/id/'+getQueryVariable('id'), {}, module.outProjectInformation2,true); },5000) }; //获取地址栏参数 function getQueryVariable(variable){ var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i{ if (data.code == 200) { var unit = eval(data.data).filter(function (e) { return e.dictValue == content.unit;})[0].dictLabel; module.data.outProjectInformationDetail.unit = unit; var outProjectInformationData = template('outProjectInformationData', module.data); $("#outProjectInformationContent").html(outProjectInformationData); var outProjectInformationData2 = template('outProjectInformationData2', module.data); $("#outProjectInformationContent2").html(outProjectInformationData2); $('#unit').html('出价【'+unit+'】') } },true); //竞价方式字典 tools.doGet(Dictionaries+'/bidding_type', {}, (data)=>{ if (data.code == 200) { var biddingType = eval(data.data).filter(function (e) { return e.dictValue == content.biddingType;})[0].dictLabel; module.data.outProjectInformationDetail.biddingType = biddingType; var outProjectInformationData = template('outProjectInformationData', module.data); $("#outProjectInformationContent").html(outProjectInformationData); var outProjectInformationData2 = template('outProjectInformationData2', module.data); $("#outProjectInformationContent2").html(outProjectInformationData2); } },true); //期满处理字典 tools.doGet(Dictionaries+'/bidding_direct', {}, (data)=>{ if (data.code == 200) { var biddingDirect = eval(data.data).filter(function (e) { return e.dictValue == content.biddingDirect;})[0].dictLabel; module.data.outProjectInformationDetail.biddingDirect = biddingDirect; var outProjectInformationData = template('outProjectInformationData', module.data); $("#outProjectInformationContent").html(outProjectInformationData); var outProjectInformationData2 = template('outProjectInformationData2', module.data); $("#outProjectInformationContent2").html(outProjectInformationData2); } },true); //交易项目竞价记录 tools.doGet(biddinglist, {projectId:getQueryVariable('id')}, module.biddinglistInformation,true); //倒计时 module.data.timer = setInterval(function(){ let signupStartTime = module.data.outProjectInformationDetail.signupStartTime; let signupStopTime = module.data.outProjectInformationDetail.signupStopTime; let biddingStartTime = module.data.outProjectInformationDetail.biddingStartTime; let biddingStopTime = module.data.outProjectInformationDetail.biddingStopTime;//延时后结束时间 let biddingStopSetime = module.data.outProjectInformationDetail.biddingStopSetime;//原始结束时间 var nowTime = Date.parse(new Date($.ajax({type:'HEAD',async:false,data:{i: Date.parse(new Date())}}).getResponseHeader("Date"))); var difference = Date.parse(biddingStopTime)-nowTime;//延时后时间差 var differenceSetime = Date.parse(biddingStopSetime)-nowTime;//原始时间差 var centerTime = content.delayPeriod * 1000//延时周期 var m,s; m = Math.floor(difference/1000/60%60); s = Math.floor(difference/1000%60); if(s%2 == 0&¢erTime!=0){ tools.doGet(getBiddingStopTime+getQueryVariable('id'), {}, (data)=>{ if (data.code == 200) { module.data.outProjectInformationDetail.biddingStopTime = data.data } },true); } if ( differenceSetime <= 0 && difference >= 0 && difference <= centerTime){ module.dataCompare(signupStartTime,signupStopTime,biddingStartTime,biddingStopTime); if (s < 1 && m < 1){ console.log("竞价结束22222222222") tools.doGet(getBiddingStopTime+getQueryVariable('id'), {}, function(data){ if (data.code == 200) { module.data.outProjectInformationDetail.biddingStopTime = data.data let timeNew = Date.parse(data.data) + 0 - nowTime; if (timeNew > 0) { module.data.outProjectInformationDetail.biddingStopTime = data.data; }else{ $('#countDown').html('竞价结束') return; } } },true); }else if(s%2 == 0&¢erTime!=0){ tools.doGet(getBiddingStopTime+getQueryVariable('id'), {}, (data)=>{ if (data.code == 200) { module.data.outProjectInformationDetail.biddingStopTime = data.data } },true); } }else{ module.dataCompare(signupStartTime,signupStopTime,biddingStartTime,biddingStopSetime); } },1000); } } //项目基本信息 module.outProjectInformation2 = function (data) { if (data.code == 200) { var content = data.data; $("#bmrs").html(content.bidderNum); $("#cjcs").html(content.bidPriceNum); } } //竞价记录 module.biddinglistInformation = function (data) { if (data.code == 200) { //console.log(data) var content = data.rows; // for (var i = 0; i < content.length-1; i++) { // for (var j = 0; j < content.length - 1 - i; j++) { // // 相邻元素两两对比,元素交换,大的元素交换到后面 // if (content[j].money < content[j + 1].money) { // var temp = content[j]; // content[j] = content[j+1]; // content[j+1] = temp; // } // } // } //console.log(content) module.data.biddinglistInformationDetail = content; var biddingInformationData = template('biddingInformationData', module.data); $("#biddingInformationContent").html(biddingInformationData); if (content.length > 0){ $("#biddingPeople").html(content[0].memberId); if(module.data.outProjectInformationDetail.biddingType=='自由竞价'&&module.data.outProjectInformationDetail.projectShowStatus!='已经成交'){ $("#biddingMoney").html('*'); }else{ $("#biddingMoney").html(content[0].money+module.data.outProjectInformationDetail.unit); } }else{ $("#biddingPeople").html('无'); $("#biddingMoney").html('无'); } } } module.dataCompare = function(signupStartTime,signupStopTime,biddingStartTime,biddingStopTime){ var signupStartTime = signupStartTime; var signupStopTime = signupStopTime; var biddingStartTime = biddingStartTime; var biddingStopTime = biddingStopTime; var nowTime = Date.parse(new Date($.ajax({type:'HEAD',async:false,data:{i: Date.parse(new Date())}}).getResponseHeader("Date"))); var beginTimes=signupStartTime.substring(0,10).split('-'); var endTimes=signupStopTime.substring(0,10).split('-'); var biddingBeginTimes=biddingStartTime.substring(0,10).split('-'); var biddingEndTimes=biddingStopTime.substring(0,10).split('-'); signupStartTime=beginTimes[1]+'/'+beginTimes[2]+'/'+beginTimes[0]+' '+signupStartTime.substring(10,19); signupStopTime=endTimes[1]+'/'+endTimes[2]+'/'+endTimes[0]+' '+signupStopTime.substring(10,19); biddingStartTime=biddingBeginTimes[1]+'/'+biddingBeginTimes[2]+'/'+biddingBeginTimes[0]+' '+biddingStartTime.substring(10,19); biddingStopTime=biddingEndTimes[1]+'/'+biddingEndTimes[2]+'/'+biddingEndTimes[0]+' '+biddingStopTime.substring(10,19); //时间差 var leftTime = Date.parse(biddingStopTime)-nowTime; //报名开始时间差 var signupLeftTime = Date.parse(signupStartTime)-nowTime; //报名结束时间差 var signDownLeftTime = Date.parse(signupStopTime)-nowTime; var centerTime = module.data.delayPeriod * 1000//延时周期 //定义变量 d,h,m,s保存倒计时的时间 var d,h,m,s; if(Date.parse(biddingStartTime)Date.parse(biddingStopTime)){ //竞价结束 $('#d0').html('0') $('#d1').html('0') $('#d2').html('0') $('#h0').html('0') $('#h1').html('0') $('#m0').html('0') $('#m1').html('0') $('#s0').html('0') $('#s1').html('0') $('#countType').html('竞价结束') module.data.biddingTimeType = 2; }else if (nowTimeDate.parse(signupStopTime)){ //报名结束 module.data.signupTimeType = 2; }else if (nowTime{ if (data.code == 200) { module.data.outProjectInformationDetail.biddingStopTime = data.data } },true); var biddingStartTime = module.data.outProjectInformationDetail.biddingStartTime var biddingStopTime = module.data.outProjectInformationDetail.biddingStopTime; var nowTime = Date.parse(new Date($.ajax({type:'HEAD',async:false,data:{i: Date.parse(new Date())}}).getResponseHeader("Date"))); var biddingBeginTimes=biddingStartTime.substring(0,10).split('-'); var biddingEndTimes=biddingStopTime.substring(0,10).split('-'); biddingStartTime=biddingBeginTimes[1]+'/'+biddingBeginTimes[2]+'/'+biddingBeginTimes[0]+' '+biddingStartTime.substring(10,19); biddingStopTime=biddingEndTimes[1]+'/'+biddingEndTimes[2]+'/'+biddingEndTimes[0]+' '+biddingStopTime.substring(10,19); //时间差 var leftTime = Date.parse(biddingStopTime)-nowTime; //定义变量 d,h,m,s保存倒计时的时间 var d,h,m,s; if(Date.parse(biddingStartTime)?' module.data.timeConfig = content[8].configValue; module.data.titleConfig = content[9].configValue; module.data.importantTitle = content[7].configName+':'+ content[7].configValue.substr(3).substr(0,(content[7].configValue.substr(3).length-4)); module.data.know = content[6].configValue; $("#know").html(content[6].configValue + '' + content[6].configValue); } } module.biddingDirectDictionaries = function (data) { if (data.code == 200 && module.data.outProjectInformationDetail.biddingDirect!='') { var content = data.data; var biddingDirect = eval(content).filter(function (e) { return e.dictValue == module.data.outProjectInformationDetail.biddingDirect;})[0].dictLabel; module.data.outProjectInformationDetail.biddingDirect = biddingDirect; } } module.unitDictionaries = function (data) { if (data.code == 200 && module.data.outProjectInformationDetail.unit!='') { var content = data.data; var unit = eval(content).filter(function (e) { return e.dictValue == module.data.outProjectInformationDetail.unit;})[0].dictLabel; module.data.outProjectInformationDetail.unit = unit; } } module.biddingTypeDictionaries = function (data) { if (data.code == 200 && module.data.outProjectInformationDetail.biddingType!='') { var content = data.data; console.log(eval(content).filter(function (e) { return e.dictValue == module.data.outProjectInformationDetail.biddingType;})) var biddingType = eval(content).filter(function (e) { return e.dictValue == module.data.outProjectInformationDetail.biddingType;})[0].dictLabel; module.data.outProjectInformationDetail.biddingType = biddingType; } } return module; });