网站
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

258 line
14 KiB

  1. /**
  2. * Created by Administrator on 2021/4/5.
  3. */
  4. define(['jquery', "template", "Tools", "biddingApi", "itemsApi"], function ($, template, Tools ) {
  5. //数据存储
  6. var module = {
  7. data: {
  8. timeArray: {
  9. d: '',
  10. h: '',
  11. m: '',
  12. s: '',
  13. },
  14. outProjectInformationDetail:{}
  15. },
  16. };
  17. var tools = new Tools();
  18. module.init = function (page) {
  19. tools.doGet(outProject + '/id/'+getQueryVariable('id'), {}, module.outProjectInformation,true);
  20. tools.doGet(webConfig, {}, module.webConfigInformation, true)
  21. $("#nowDateNYR").html(new Date().getFullYear()+'.'+(new Date().getMonth()+1)+'.'+new Date().getDate())
  22. setInterval(function () {
  23. $("#nowDateSFM").html(new Date().toLocaleTimeString());
  24. $("#nowTime").html('服务器时间:'+new Date().getFullYear()+'.'+(new Date().getMonth()+1)+'.'+new Date().getDate()+' '+new Date().toLocaleTimeString());
  25. },1000)
  26. };
  27. //获取地址栏参数
  28. function getQueryVariable(variable){
  29. var query = window.location.search.substring(1);
  30. var vars = query.split("&");
  31. for (var i=0;i<vars.length;i++) {
  32. var pair = vars[i].split("=");
  33. if(pair[0] == variable){return pair[1];}
  34. }
  35. return(false);
  36. }
  37. //项目基本信息
  38. module.outProjectInformation = function (data) {
  39. if (data.code == 200) {
  40. var content = data.data;
  41. //倒计时
  42. var timer = setInterval(function(){
  43. module.dataCompare(content.signupStartTime,content.signupStopTime,content.biddingStartTime,content.biddingStopTime);
  44. },1000);
  45. module.data.outProjectInformationDetail = content;
  46. // var outProjectInformationData = template('outProjectInformationData', module.data);
  47. // $("#outProjectInformationContent").html(outProjectInformationData);
  48. //挂牌价格字典
  49. tools.doGet(Dictionaries+'/price_unit', {}, module.unitDictionaries,true);
  50. //竞价方式字典
  51. tools.doGet(Dictionaries+'/bidding_type', {}, module.biddingTypeDictionaries,true);
  52. //期满处理字典
  53. tools.doGet(Dictionaries+'/bidding_direct', {}, module.biddingDirectDictionaries,true);
  54. //挂牌项目竞价记录
  55. tools.doGet(biddinglist, {projectId:getQueryVariable('id')}, module.biddinglistInformation,true);
  56. }
  57. }
  58. //竞价记录
  59. module.biddinglistInformation = function (data) {
  60. if (data.code == 200) {
  61. console.log(data)
  62. var content = data.rows;
  63. for (var i = 0; i < content.length-1; i++) {
  64. for (var j = 0; j < content.length - 1 - i; j++) {
  65. // 相邻元素两两对比,元素交换,大的元素交换到后面
  66. if (content[j].money < content[j + 1].money) {
  67. var temp = content[j];
  68. content[j] = content[j+1];
  69. content[j+1] = temp;
  70. }
  71. }
  72. }
  73. console.log(content)
  74. module.data.outProjectInformationDetail.biddinglistInformationDetail = content;
  75. var outProjectInformationData = template('outProjectInformationData', module.data);
  76. $("#outProjectInformationContent").html(outProjectInformationData);
  77. }
  78. }
  79. module.dataCompare = function(signupStartTime,signupStopTime,biddingStartTime,biddingStopTime){
  80. var signupStartTime = signupStartTime;
  81. var signupStopTime = signupStopTime;
  82. var biddingStartTime = biddingStartTime;
  83. var biddingStopTime = biddingStopTime;
  84. var nowTime = Date.parse(new Date());
  85. var beginTimes=signupStartTime.substring(0,10).split('-');
  86. var endTimes=signupStopTime.substring(0,10).split('-');
  87. var biddingBeginTimes=biddingStartTime.substring(0,10).split('-');
  88. var biddingEndTimes=biddingStopTime.substring(0,10).split('-');
  89. signupStartTime=beginTimes[1]+'/'+beginTimes[2]+'/'+beginTimes[0]+' '+signupStartTime.substring(10,19);
  90. signupStopTime=endTimes[1]+'/'+endTimes[2]+'/'+endTimes[0]+' '+signupStopTime.substring(10,19);
  91. biddingStartTime=biddingBeginTimes[1]+'/'+biddingBeginTimes[2]+'/'+biddingBeginTimes[0]+' '+biddingStartTime.substring(10,19);
  92. biddingStopTime=biddingEndTimes[1]+'/'+biddingEndTimes[2]+'/'+biddingEndTimes[0]+' '+biddingStopTime.substring(10,19);
  93. //时间差
  94. var leftTime = Date.parse(biddingStopTime)-nowTime;
  95. //报名开始时间差
  96. var signupLeftTime = Date.parse(signupStartTime)-nowTime;
  97. //报名结束时间差
  98. var signDownLeftTime = Date.parse(signupStopTime)-nowTime;
  99. //定义变量 d,h,m,s保存倒计时的时间
  100. var d,h,m,s;
  101. if(Date.parse(biddingStartTime)<nowTime&&nowTime<Date.parse(biddingStopTime)){
  102. //正在竞价
  103. module.data.biddingTimeType = 1;
  104. // console.log(((Math.floor(leftTime / 1000 / 60 / 60 / 24) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 / 60 / 24) : Math.floor(leftTime / 1000 / 60 / 60 / 24) + '')[0])
  105. $('#d0').html(((Math.floor(leftTime / 1000 / 60 / 60 / 24) + '').length < 1 ? '00' + Math.floor(leftTime / 1000 / 60 / 60 / 24) : (Math.floor(leftTime / 1000 / 60 / 60 / 24) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 / 60 / 24) : Math.floor(leftTime / 1000 / 60 / 60 / 24) + '')[0]);
  106. $('#d1').html(((Math.floor(leftTime / 1000 / 60 / 60 / 24) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 / 60 / 24) : Math.floor(leftTime / 1000 / 60 / 60 / 24) + '')[1]);
  107. $('#d2').html(((Math.floor(leftTime / 1000 / 60 / 60 / 24) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 / 60 / 24) : Math.floor(leftTime / 1000 / 60 / 60 / 24) + '')[2]);
  108. $('#h0').html(((Math.floor(leftTime / 1000 / 60 / 60 % 24) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 / 60 % 24) : Math.floor(leftTime / 1000 / 60 / 60 % 24) + '')[0]);
  109. $('#h1').html(((Math.floor(leftTime / 1000 / 60 / 60 % 24) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 / 60 % 24) : Math.floor(leftTime / 1000 / 60 / 60 % 24) + '')[1]);
  110. $('#m0').html(((Math.floor(leftTime / 1000 / 60 % 60) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 % 60) : Math.floor(leftTime / 1000 / 60 % 60) + '')[0]);
  111. $('#m1').html(((Math.floor(leftTime / 1000 / 60 % 60) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 % 60) : Math.floor(leftTime / 1000 / 60 % 60) + '')[1]);
  112. $('#s0').html(((Math.floor(leftTime / 1000 % 60) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 % 60) : Math.floor(leftTime / 1000 % 60) + '')[0]);
  113. $('#s1').html(((Math.floor(leftTime / 1000 % 60) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 % 60) : Math.floor(leftTime / 1000 % 60) + '')[1]);
  114. $('#countType').html('距竞价结束还有')
  115. }else if (nowTime>Date.parse(biddingStopTime)){
  116. //竞价结束
  117. $('#d0').html('0')
  118. $('#d1').html('0')
  119. $('#d2').html('0')
  120. $('#h0').html('0')
  121. $('#h1').html('0')
  122. $('#m0').html('0')
  123. $('#m1').html('0')
  124. $('#s0').html('0')
  125. $('#s1').html('0')
  126. $('#countType').html('竞价结束')
  127. module.data.biddingTimeType = 2;
  128. }else if (nowTime<Date.parse(biddingStartTime)){
  129. //竞价暂未开始
  130. $('#d0').html('0')
  131. $('#d1').html('0')
  132. $('#d2').html('0')
  133. $('#h0').html('0')
  134. $('#h1').html('0')
  135. $('#m0').html('0')
  136. $('#m1').html('0')
  137. $('#s0').html('0')
  138. $('#s1').html('0')
  139. $('#countType').html('暂未开始')
  140. module.data.biddingTimeType = 3;
  141. }
  142. if(Date.parse(signupStartTime)<nowTime&&nowTime<Date.parse(signupStopTime)){
  143. //正在报名
  144. module.data.signupTimeType = 1;
  145. $('#d0').html(((Math.floor(signDownLeftTime / 1000 / 60 / 60 / 24) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 / 60 / 24) : Math.floor(leftTime / 1000 / 60 / 60 / 24) + '')[0]);
  146. $('#d1').html(((Math.floor(signDownLeftTime / 1000 / 60 / 60 / 24) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 / 60 / 24) : Math.floor(leftTime / 1000 / 60 / 60 / 24) + '')[1]);
  147. $('#d2').html(((Math.floor(signDownLeftTime / 1000 / 60 / 60 / 24) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 / 60 / 24) : Math.floor(leftTime / 1000 / 60 / 60 / 24) + '')[2]);
  148. $('#h0').html(((Math.floor(signDownLeftTime / 1000 / 60 / 60 % 24) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 / 60 % 24) : Math.floor(leftTime / 1000 / 60 / 60 % 24) + '')[0]);
  149. $('#h1').html(((Math.floor(signDownLeftTime / 1000 / 60 / 60 % 24) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 / 60 % 24) : Math.floor(leftTime / 1000 / 60 / 60 % 24) + '')[1]);
  150. $('#m0').html(((Math.floor(signDownLeftTime / 1000 / 60 % 60) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 % 60) : Math.floor(leftTime / 1000 / 60 % 60) + '')[0]);
  151. $('#m1').html(((Math.floor(signDownLeftTime / 1000 / 60 % 60) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 % 60) : Math.floor(leftTime / 1000 / 60 % 60) + '')[1]);
  152. $('#s0').html(((Math.floor(signDownLeftTime / 1000 % 60) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 % 60) : Math.floor(leftTime / 1000 % 60) + '')[0]);
  153. $('#s1').html(((Math.floor(signDownLeftTime / 1000 % 60) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 % 60) : Math.floor(leftTime / 1000 % 60) + '')[1]);
  154. $('#countType').html('距报名结束还有')
  155. }else if (nowTime>Date.parse(signupStopTime)){
  156. //报名结束
  157. module.data.signupTimeType = 2;
  158. }else if (nowTime<Date.parse(signupStartTime)){
  159. //报名暂未开始
  160. module.data.signupTimeType = 3;
  161. $('#d0').html(((Math.floor(signupLeftTime / 1000 / 60 / 60 / 24) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 / 60 / 24) : Math.floor(leftTime / 1000 / 60 / 60 / 24) + '')[0]);
  162. $('#d1').html(((Math.floor(signupLeftTime / 1000 / 60 / 60 / 24) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 / 60 / 24) : Math.floor(leftTime / 1000 / 60 / 60 / 24) + '')[1]);
  163. $('#d2').html(((Math.floor(signupLeftTime / 1000 / 60 / 60 / 24) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 / 60 / 24) : Math.floor(leftTime / 1000 / 60 / 60 / 24) + '')[2]);
  164. $('#h0').html(((Math.floor(signupLeftTime / 1000 / 60 / 60 % 24) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 / 60 % 24) : Math.floor(leftTime / 1000 / 60 / 60 % 24) + '')[0]);
  165. $('#h1').html(((Math.floor(signupLeftTime / 1000 / 60 / 60 % 24) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 / 60 % 24) : Math.floor(leftTime / 1000 / 60 / 60 % 24) + '')[1]);
  166. $('#m0').html(((Math.floor(signupLeftTime / 1000 / 60 % 60) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 % 60) : Math.floor(leftTime / 1000 / 60 % 60) + '')[0]);
  167. $('#m1').html(((Math.floor(signupLeftTime / 1000 / 60 % 60) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 / 60 % 60) : Math.floor(leftTime / 1000 / 60 % 60) + '')[1]);
  168. $('#s0').html(((Math.floor(signupLeftTime / 1000 % 60) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 % 60) : Math.floor(leftTime / 1000 % 60) + '')[0]);
  169. $('#s1').html(((Math.floor(signupLeftTime / 1000 % 60) + '').length < 2 ? '0' + Math.floor(leftTime / 1000 % 60) : Math.floor(leftTime / 1000 % 60) + '')[1]);
  170. $('#countType').html('距报名开始还有')
  171. }
  172. // if(module.data.outProjectInformationDetail.biddingType != '拍卖' && module.data.biddingTimeType != 2){
  173. // document.getElementById('biddingTable').style.display = 'none';
  174. // document.getElementById('biddingTitle').style.display = 'block';
  175. // }
  176. }
  177. //网站配置信息
  178. module.webConfigInformation = function (data) {
  179. if (data.code == 200) {
  180. var content = data.data;
  181. console.log(content)
  182. //document.getElementById('time').innerHTML = '延时周期:'+content[8].configValue+content[8].remark+'<i class="wh">?</i>'
  183. module.data.timeConfig = content[8].configValue;
  184. module.data.titleConfig = content[9].configValue;
  185. module.data.importantTitle = content[7].configName+':'+ content[7].configValue.substr(3).substr(0,(content[7].configValue.substr(3).length-4));
  186. module.data.know = content[6].configValue;
  187. $("#know").html(content[6].configValue + '<span style="margin-left: 10px;"></span>' + content[6].configValue);
  188. }
  189. }
  190. module.biddingDirectDictionaries = function (data) {
  191. if (data.code == 200 && module.data.outProjectInformationDetail.biddingDirect!='') {
  192. var content = data.data;
  193. var biddingDirect = content[(module.data.outProjectInformationDetail.biddingDirect-1)].dictLabel;
  194. module.data.outProjectInformationDetail.biddingDirect = biddingDirect;
  195. var outProjectInformationData = template('outProjectInformationData', module.data);
  196. $("#outProjectInformationContent").html(outProjectInformationData);
  197. }
  198. }
  199. module.unitDictionaries = function (data) {
  200. if (data.code == 200) {
  201. var content = data.data;
  202. var unit = content[(module.data.outProjectInformationDetail.unit-1)].dictLabel;
  203. module.data.outProjectInformationDetail.unit = unit;
  204. var outProjectInformationData = template('outProjectInformationData', module.data);
  205. $("#outProjectInformationContent").html(outProjectInformationData);
  206. }
  207. }
  208. module.biddingTypeDictionaries = function (data) {
  209. if (data.code == 200 && module.data.outProjectInformationDetail.biddingType!='') {
  210. var content = data.data;
  211. var biddingType = content[(module.data.outProjectInformationDetail.biddingType-1)].dictLabel;
  212. module.data.outProjectInformationDetail.biddingType = biddingType;
  213. var outProjectInformationData = template('outProjectInformationData', module.data);
  214. $("#outProjectInformationContent").html(outProjectInformationData);
  215. }
  216. }
  217. return module;
  218. });