policyList.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import '../../css/bootstrap.less';
  2. import 'bootstrap/dist/js/bootstrap.js';
  3. import '../../css/public.css';
  4. import '../../css/main_banner.css';
  5. import '../../js/public.js';
  6. import '../../js/main_banner.js';
  7. import '../../css/thinkTank/policyList.css';
  8. import {
  9. provinceList
  10. } from '../../js/NewDicProvinceList';
  11. $(function(){
  12. //数据处理
  13. var theKeyword,pageSize,Province;
  14. var thePageNo = 1,
  15. thePageLength = 1,
  16. pageSize = 6;
  17. function loadDate(pageNo) {
  18. $.ajax({
  19. method: "get",
  20. dataType: "json",
  21. url: globalConfig.context + "/portal/news/list",
  22. data: {
  23. pageNo: pageNo || 1,
  24. pageSize: pageSize,
  25. keyword: theKeyword,
  26. provinceId: Province != 999 ? Province : undefined
  27. },
  28. success: function (data) {
  29. var theArr = [];
  30. thePageLength = data.data.totalCount ? Math.ceil(data.data.totalCount / pageSize) : 1;
  31. if (data.data && data.data.list) {
  32. for (let i = 0; i < data.data.list.length; i++) {
  33. let thisdata = data.data.list[i];
  34. var id=thisdata.id;
  35. var title = thisdata.title; //标题
  36. var time = thisdata.createTimeFormattedDate; //日期
  37. var day=time.substr(8,2);//号
  38. var month=time.substr(0,7) //年、月
  39. var summary = thisdata.summary;//简介
  40. var sol='';
  41. var srctt=globalConfig.context + '/portal/news/newsDetail.html?id=' + id;
  42. theArr.push([
  43. '<li value="'+id+'">',
  44. '<div class="policy_time">',
  45. '<p>'+day+'</p>',
  46. '<time>'+month+'</time>',
  47. '</div>',
  48. '<div class="policy_details">',
  49. '<h4><a href="'+srctt+'">'+title+'</a></h4>',
  50. '<p>'+summary+'</p>',
  51. '<a href="'+srctt+'">MORE+</a>',
  52. '</div>',
  53. '</li>',
  54. ].join(''));
  55. };
  56. };
  57. $('.policy ul').empty();
  58. $('.policy ul').append(theArr.join(''));
  59. if(data.data.list.length===0){
  60. $('.policy ul').html('<div class="imgbg"></div>')
  61. };
  62. $('.totalCount').html("共 "+ thePageLength +" 页 " + data.data.totalCount + " 条数据");
  63. var pageArr = [],
  64. firstNo = 1,
  65. endNo = 5;
  66. if (thePageNo > 3) {
  67. firstNo = thePageNo - 2;
  68. endNo = Math.min((Number(thePageNo) + 2), thePageLength);
  69. } else {
  70. endNo = Math.min(thePageLength, 5);
  71. };
  72. for (let i = firstNo; i <= endNo; i++) {
  73. if (i == thePageNo) {
  74. pageArr.push(
  75. '<li class="pageNumber active"><a href="#" value=' + i + ' >' + i + '</a></li>'
  76. );
  77. } else {
  78. pageArr.push(
  79. '<li class="pageNumber"><a href="#" value=' + i + ' >' + i + '</a></li>'
  80. );
  81. }
  82. };
  83. $('.pageNumber').remove();
  84. $('.pagePre').after(pageArr.join(''));
  85. },
  86. });
  87. }
  88. if (window.location.search) {
  89. let theUrl = window.location.search
  90. theKeyword = theUrl.substring(1, theUrl.length);
  91. theKeyword = decodeURIComponent(theKeyword);
  92. $('#search_on input').val(theKeyword);
  93. var search_city=$('#selt').value;
  94. Province=search_city
  95. };
  96. loadDate();
  97. //点击分页
  98. $('.pagination').on('click', 'li', function (e) {
  99. e.preventDefault();
  100. console.log(thePageNo);
  101. if (this.className === 'pagePre') {
  102. if (thePageNo > 1) {
  103. thePageNo = 1;
  104. loadDate(thePageNo);
  105. }
  106. } else if (this.className === 'pageNext') {
  107. if (thePageNo < thePageLength) {
  108. thePageNo = thePageLength;
  109. loadDate(thePageNo);
  110. }
  111. } else {
  112. var nextPageNo = $(this).children()[0].text;
  113. if (thePageNo != nextPageNo) {
  114. $(this).siblings("li").removeClass("active");
  115. $(this).addClass("active");
  116. thePageNo = nextPageNo;
  117. loadDate(thePageNo);
  118. };
  119. };
  120. });
  121. //链接详情
  122. $('.invest_imglist ul').on('click', 'li', function () {
  123. var theId = $(this).attr('value');
  124. window.open(globalConfig.context + '/portal/thinkTank/thinkerDetail.html?id=' + theId );
  125. })
  126. //导航城市添加
  127. var industryListArr = [],
  128. industryChildrenArr = [];
  129. industryListArr.push(['<li value="999" class="active">',
  130. '<span>',
  131. '不限',
  132. '</span>',
  133. '</li>',
  134. ].join(''));
  135. provinceList.map(function (item) {
  136. industryListArr.push(['<li value="' +item.id + '">',
  137. '<span>',
  138. item.name,
  139. '</span>',
  140. '</li>',
  141. ].join(''));
  142. });
  143. if (industryListArr && industryListArr.length) {
  144. $('#industryList').append(industryListArr.join(''));
  145. };
  146. //点击城市时
  147. $('#industryList li').click(function () {
  148. var theValue = this.value;
  149. $(this).siblings("li").removeClass("active");
  150. $(this).addClass("active");
  151. Province=theValue;
  152. loadDate();
  153. })
  154. //搜索时
  155. $('#btn_search').click(function(e){
  156. e.preventDefault();
  157. var citys=$('#industryList .active').attr('value');
  158. var val_inp=$('#search_on input').val();
  159. Province=citys;
  160. theKeyword=val_inp;
  161. loadDate();
  162. })
  163. })