index.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. $(function() {
  2. var dataLength;
  3. var EndTime = new Date().getTime();
  4. var StartTime = EndTime - 31536000000;
  5. var NoticeType = '招标公告';
  6. var dataUrl = '/nx/n/list/notice';
  7. AjaxFan(1);
  8. function AjaxFan(pagenum) {
  9. $.ajax({
  10. url: getServerHttp() + dataUrl,
  11. type: 'post',
  12. cache: false,
  13. dataType: 'json',
  14. data: {
  15. p: pagenum,
  16. notice_type: NoticeType,
  17. start_time: StartTime,
  18. end_time: EndTime
  19. },
  20. success: function(data) {
  21. var data = ajaxDataParames(data);
  22. var doms = "";
  23. // dataLength = data.count;
  24. dataLength = data.pagePackage.page.totalRow;
  25. $('.result-content-title-right span i').html(dataLength);
  26. if (NoticeType == "招标公告") {
  27. var type = 1
  28. } else {
  29. var type = 2
  30. }
  31. var list = data.pagePackage.data;
  32. for (var i = 0; i < list.length; i++) {
  33. var iDom = "";
  34. var applyTime = list[i].apply_date_end;
  35. var noticeTime = list[i].notice_end_time;
  36. var nowDate = new Date();
  37. if (applyTime > noticeTime || applyTime === noticeTime) {
  38. var endDate = new Date(applyTime);
  39. } else if (applyTime < noticeTime) {
  40. var endDate = new Date(noticeTime);
  41. }
  42. var overDate = endDate - nowDate;
  43. var timeDay = Math.floor(overDate / 86400000);
  44. var timeHour = Math.floor((overDate % 86400000) / 3600000);
  45. var timeHtml = '<span class="countdowns">剩余<i class="day">' + timeDay + '</i>天<i class="hour">' + timeHour +
  46. '</i>小时</span>';
  47. var iconStyle = list[i].notice_nature;
  48. if (iconStyle === "正常公告" || iconStyle === "再次公告") {
  49. iDom = '<i class="icons greens">新</i>';
  50. } else if (iconStyle === "变更公告") {
  51. iDom = '<i class="icons blues">变更</i>';
  52. } else if (iconStyle === "延期公告") {
  53. iDom = '<i class="icons blues">延期</i>';
  54. } else if (iconStyle === "补充公告") {
  55. iDom = '<i class="icons blues">补充</i>';
  56. } else if (iconStyle === "控制价") {
  57. iDom = '<i class="icons blues">控价</i>';
  58. } else if (iconStyle === "撤销公告") {
  59. iDom = '<i class="icons reds">撤销</i>';
  60. }
  61. if (timeDay < 0 || iconStyle === "控制价" || iconStyle === "变更公告" || iconStyle === "延期公告" || iconStyle ===
  62. "补充公告" || iconStyle === "撤销公告") {
  63. timeHtml = '<span class="countdowns">无</span>';
  64. }
  65. // 判断用户现在使用的设备
  66. if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
  67. var porjectUrl = '../page_detailed/list_Phone.html?kid=' + list[i].kid + '&type=' + type;
  68. } else {
  69. var porjectUrl = '../page_detailed/list.html?kid=' + list[i].kid + '&type=' + type;
  70. }
  71. doms += '<li>' + iDom + '<a href="' + porjectUrl + '" class="names" target="_blank" title="' + list[i].project_name +
  72. '">' + list[i].project_name + '</a><span class="times">' + list[i].notice_release_time +
  73. '</span><a href="javascript:void(0)" class="sources" title="' + list[i].org_name + '">' + list[i].org_name +
  74. '</a><span class="areas">' + list[i].region_name + '</span>' + timeHtml + '</li>';
  75. }
  76. $('.result-content-line ul').html(doms);
  77. layui.laypage.render({
  78. elem: 'paging',
  79. count: dataLength,
  80. limit: 20,
  81. first: '首页',
  82. last: '尾页',
  83. curr: pagenum,
  84. groups: 5,
  85. jump: function(obj, first) {
  86. if (!first) {
  87. AjaxFan(obj.curr);
  88. }
  89. }
  90. });
  91. }
  92. })
  93. }
  94. //条件筛选
  95. $.fn.extend({
  96. Screen: function() {
  97. $(this).on('click', function() {
  98. if (!$(this).find('a').hasClass('all-btn')) {
  99. $(this).find('a').addClass('all-btn');
  100. $(this).siblings().find('a').removeClass('all-btn');
  101. } else {
  102. return
  103. }
  104. if ($(this).find('a').hasClass('notices')) {
  105. NoticeType = $(this).find('a').html();
  106. } else if ($(this).find('a').hasClass('releasetime')) {
  107. var ReleaseTime = $(this).find('a').attr('id');
  108. if (ReleaseTime == 'year') {
  109. StartTime = EndTime - 31536000000;
  110. } else if (ReleaseTime == 'month') {
  111. StartTime = EndTime - 2592000000;
  112. } else if (ReleaseTime == 'week') {
  113. StartTime = EndTime - 604800000;
  114. } else if (ReleaseTime == 'day') {
  115. StartTime = EndTime - 259200000;
  116. }
  117. }
  118. AjaxFan(1);
  119. })
  120. }
  121. });
  122. (function() {
  123. $('.screen-content-box div ul li').Screen();
  124. }())
  125. })