policyList.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. if(summary==null){
  41. summary=='暂无内容'
  42. };
  43. var sol='';
  44. var srctt=globalConfig.context + '/portal/news/newsDetail.html?id=' + id;
  45. theArr.push([
  46. '<li value="'+id+'">',
  47. '<div class="policy_time">',
  48. '<p>'+day+'</p>',
  49. '<time>'+month+'</time>',
  50. '</div>',
  51. '<div class="policy_details">',
  52. '<h4><a href="'+srctt+'">'+title+'</a></h4>',
  53. '<p>'+summary+'</p>',
  54. '<a href="'+srctt+'">MORE+</a>',
  55. '</div>',
  56. '</li>',
  57. ].join(''));
  58. };
  59. };
  60. $('.policy ul').empty();
  61. $('.policy ul').append(theArr.join(''));
  62. if(data.data.list.length===0){
  63. $('.policy ul').html('<div class="imgbg"></div>')
  64. };
  65. $('.totalCount').html("共 "+ thePageLength +" 页 " + data.data.totalCount + " 条数据");
  66. var pageArr = [],
  67. firstNo = 1,
  68. endNo = 5;
  69. if (thePageNo > 3) {
  70. firstNo = thePageNo - 2;
  71. endNo = Math.min((Number(thePageNo) + 2), thePageLength);
  72. } else {
  73. endNo = Math.min(thePageLength, 5);
  74. };
  75. for (let i = firstNo; i <= endNo; i++) {
  76. if (i == thePageNo) {
  77. pageArr.push(
  78. '<li class="pageNumber active"><a href="#" value=' + i + ' >' + i + '</a></li>'
  79. );
  80. } else {
  81. pageArr.push(
  82. '<li class="pageNumber"><a href="#" value=' + i + ' >' + i + '</a></li>'
  83. );
  84. }
  85. };
  86. $('.pageNumber').remove();
  87. $('.pagePre').after(pageArr.join(''));
  88. },
  89. });
  90. }
  91. if (window.location.search) {
  92. let theUrl = window.location.search
  93. theKeyword = theUrl.substring(1, theUrl.length);
  94. theKeyword = decodeURIComponent(theKeyword);
  95. $('#search_on input').val(theKeyword);
  96. var search_city=$('#selt').value;
  97. Province=search_city
  98. };
  99. loadDate();
  100. //点击分页
  101. $('.pagination').on('click', 'li', function (e) {
  102. e.preventDefault();
  103. console.log(thePageNo);
  104. if (this.className === 'pagePre') {
  105. if (thePageNo > 1) {
  106. thePageNo = 1;
  107. loadDate(thePageNo);
  108. }
  109. } else if (this.className === 'pageNext') {
  110. if (thePageNo < thePageLength) {
  111. thePageNo = thePageLength;
  112. loadDate(thePageNo);
  113. }
  114. } else {
  115. var nextPageNo = $(this).children()[0].text;
  116. if (thePageNo != nextPageNo) {
  117. $(this).siblings("li").removeClass("active");
  118. $(this).addClass("active");
  119. thePageNo = nextPageNo;
  120. loadDate(thePageNo);
  121. };
  122. };
  123. });
  124. //链接详情
  125. $('.invest_imglist ul').on('click', 'li', function () {
  126. var theId = $(this).attr('value');
  127. window.open(globalConfig.context + '/portal/thinkTank/thinkerDetail.html?id=' + theId );
  128. })
  129. //导航城市添加
  130. var industryListArr = [],
  131. industryChildrenArr = [];
  132. industryListArr.push(['<li value="999" class="active">',
  133. '<span>',
  134. '不限',
  135. '</span>',
  136. '</li>',
  137. ].join(''));
  138. provinceList.map(function (item) {
  139. industryListArr.push(['<li value="' +item.id + '">',
  140. '<span>',
  141. item.name,
  142. '</span>',
  143. '</li>',
  144. ].join(''));
  145. });
  146. if (industryListArr && industryListArr.length) {
  147. $('#industryList').append(industryListArr.join(''));
  148. };
  149. //点击城市时
  150. $('#industryList li').click(function () {
  151. var theValue = this.value;
  152. $(this).siblings("li").removeClass("active");
  153. $(this).addClass("active");
  154. Province=theValue;
  155. loadDate();
  156. })
  157. //搜索时
  158. $('#btn_search').click(function(e){
  159. e.preventDefault();
  160. var citys=$('#industryList .active').attr('value');
  161. var val_inp=$('#search_on input').val();
  162. Province=citys;
  163. theKeyword=val_inp;
  164. loadDate();
  165. })
  166. })