index.js 5.3 KB

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