diff --git a/static/js/common/tools.js b/static/js/common/tools.js index 076ddbf..64d99cf 100644 --- a/static/js/common/tools.js +++ b/static/js/common/tools.js @@ -468,6 +468,38 @@ define(['jquery', 'dialog','jsencrypt'], function ($, dialog,JSEncrypt) { console.log(currentdate) return currentdate; }, + /** + * getNowFormatDateNew 获取时间 + * @param + */ + getNowFormatDateNew: function (data) { + var date = data; + var seperator1 = "-"; + var seperator2 = ":"; + var month = date.getMonth() + 1; + var day = date.getDate(); + var hours = date.getHours(); + var minutes = date.getMinutes(); + var seconds = date.getSeconds(); + if (month >= 1 && month <= 9) { + month = "0" + month; + } + if (day >= 0 && day <= 9) { + day = "0" + day; + } + if (hours >= 0 && hours <= 9) { + hours = "0" + hours; + } + if (minutes >= 0 && minutes <= 9) { + minutes = "0" + minutes; + } + if (seconds >= 0 && seconds <= 9) { + seconds = "0" + seconds; + } + var currentdate = date.getFullYear() + seperator1 + month + seperator1 + day + " " + hours + seperator2 + minutes + seperator2 + seconds; + console.log(currentdate) + return currentdate; + }, /** * getWebConfig 网站配置信息 * @param diff --git a/static/js/project/listingItems/items2.js b/static/js/project/listingItems/items2.js index 7174335..f3afbfb 100644 --- a/static/js/project/listingItems/items2.js +++ b/static/js/project/listingItems/items2.js @@ -120,14 +120,13 @@ define(['jquery', "template", "Tools", 'swiper', 'itemsApi', 'swiper'], function } } module.dataCompare = function(signupStartTime,signupStopTime,biddingStartTime,biddingStopTime){ - console.log('aaaaaaaaaaa') + // console.log('aaaaaaaaaaa') var signupStartTime = signupStartTime; var signupStopTime = signupStopTime; var biddingStartTime = biddingStartTime; var biddingStopTime = biddingStopTime; - var nowTime = Date.parse(new Date()); - - + var nowTime = Date.parse(new Date($.ajax({type:'HEAD',async:false,data:{i: Date.parse(new Date())}}).getResponseHeader("Date"))); + // console.log(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('-'); @@ -148,8 +147,10 @@ define(['jquery', "template", "Tools", 'swiper', 'itemsApi', 'swiper'], function var signDownLeftTime = Date.parse(signupStopTime)-nowTime; //定义变量 d,h,m,s保存倒计时的时间 var d,h,m,s; + if(Date.parse(biddingStartTime)距竞价结束还有:'+d+'天'+h+''+m+''+s+'秒') $('#countType').html('竞价中') $('#countDown').html('距竞价结束还有:'+d+''+h+''+m+''+s+'秒') }else if (nowTime>Date.parse(biddingStopTime)){ @@ -278,7 +280,7 @@ define(['jquery', "template", "Tools", 'swiper', 'itemsApi', 'swiper'], function var t = 10; module.data.timeDown = setInterval(function(){ - console.log($('#countType').html()) + // console.log($('#countType').html()) if ($('#countType').html()!='竞价中'){ clearInterval(module.data.timeDown) document.getElementById('timeDown').style.display = 'none'; @@ -345,9 +347,6 @@ define(['jquery', "template", "Tools", 'swiper', 'itemsApi', 'swiper'], function tools.doGet(biddinglist, {projectId:getQueryVariable('id')}, module.biddinglistInformation,true); - - - //倒计时 module.data.timer = setInterval(function(){ // '2023-05-17 14:56:00' @@ -356,13 +355,14 @@ define(['jquery', "template", "Tools", 'swiper', 'itemsApi', 'swiper'], function let biddingStartTime = module.data.outProjectInformationDetail.biddingStartTime; let biddingStopTime = module.data.outProjectInformationDetail.biddingStopTime; - var nowTime = Date.parse(new Date()); + 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 centerTime = module.data.timeConfig * 60 * 1000 var centerTime = content.delayPeriod * 1000 - if ( 0 < difference&&difference <= centerTime){ - console.log("竞价最后两分钟") + if ( 0 <= difference&&difference <= centerTime){ + // console.log("竞价最后两分钟") //正在竞价 var m,s; if(module.data.outProjectInformationDetail.biddingType == '自由竞价'){ @@ -376,7 +376,33 @@ define(['jquery', "template", "Tools", 'swiper', 'itemsApi', 'swiper'], function s = Math.floor(difference/1000%60); $('#countType').html('竞价中') $('#countDown').html('距竞价结束还有:00'+m+''+s+'秒') - tools.doGet(getBiddingStopTime+getQueryVariable('id'), {}, module.getBiddingStopTime,true); + console.log(s+'-------------'+m) + if (s < 1 && m < 1){ + console.log("竞价结束22222222222") + tools.doGet(getBiddingStopTime+getQueryVariable('id'), {}, function(data){ + if (data.code == 200) { + var nowDate = Date.parse(new Date($.ajax({type:'HEAD',async:false,data:{i: Date.parse(new Date())}}).getResponseHeader("Date"))); + module.data.outProjectInformationDetail.biddingStopTime = data.data + + let timeNew = Date.parse(data.data) + 0 - nowDate; + if (timeNew > 0) { + module.data.outProjectInformationDetail.biddingStopTime = data.data; + // module.dataCompare(signupStartTime,signupStopTime,biddingStartTime,data.data); + }else{ + $('#countType').html('') + $('#countDown').html('竞价结束') + document.getElementById('swiperType').style.display = 'none'; + document.getElementById('biddingTable').style.display = 'table-block'; + document.getElementById('biddingTitle').style.display = 'none'; + module.data.biddingTimeType = 2; + return; + } + } + },true); + + }else{ + tools.doGet(getBiddingStopTime+getQueryVariable('id'), {}, module.getBiddingStopTime,true); + } }else{ if (!signupStartTime){console.log('缺失报名开始时间');return;} if (!signupStopTime){console.log('缺失报名结束时间');return;} @@ -408,6 +434,7 @@ define(['jquery', "template", "Tools", 'swiper', 'itemsApi', 'swiper'], function module.getBiddingStopTime = function(data){ if (data.code == 200) { + $('#stopTime').html(data.data) module.data.outProjectInformationDetail.biddingStopTime = data.data } } @@ -638,6 +665,28 @@ define(['jquery', "template", "Tools", 'swiper', 'itemsApi', 'swiper'], function } module.biddingSubmitOpen = function(){ + tools.doGet(getBiddingStopTime+getQueryVariable('id'), {}, function(data){ + if (data.code == 200) { + var nowDate = Date.parse(new Date($.ajax({type:'HEAD',async:false,data:{i: Date.parse(new Date())}}).getResponseHeader("Date"))); + module.data.outProjectInformationDetail.biddingStopTime = data.data + let timeNew = Date.parse(data.data) + 0 - nowDate; + if (timeNew > 0) { + module.data.outProjectInformationDetail.biddingStopTime = data.data; + module.dataCompare( + module.data.outProjectInformationDetail.signupStartTime, + module.data.outProjectInformationDetail.signupStopTime, + module.data.outProjectInformationDetail.biddingStartTime,data.data); + }else{ + $('#countType').html('') + $('#countDown').html('竞价结束') + document.getElementById('swiperType').style.display = 'none'; + document.getElementById('biddingTable').style.display = 'table-block'; + document.getElementById('biddingTitle').style.display = 'none'; + module.data.biddingTimeType = 2; + return; + } + } + },true); tools.initError('出价成功'); // $('#money').val(0) } diff --git a/view/listingItems/itemsDetail.html b/view/listingItems/itemsDetail.html index 7dea406..e0814a0 100644 --- a/view/listingItems/itemsDetail.html +++ b/view/listingItems/itemsDetail.html @@ -315,7 +315,7 @@ 竞价开始时间:{{outProjectInformationDetail.biddingStartTime}} - 竞价截止时间(含延期):{{outProjectInformationDetail.biddingStopTime}} + 竞价截止时间(含延期):{{outProjectInformationDetail.biddingStopTime}} 竞价方式:{{outProjectInformationDetail.biddingType}}?