policyListCopy.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. import '../../css/bootstrap.less';
  2. import 'bootstrap/dist/js/bootstrap.js';
  3. import 'css/newMenu/public.css';
  4. import 'css/newMenu/header.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. theKeyword = localStorage.getItem("indexKeyWord");
  18. localStorage.removeItem("indexKeyWord");
  19. jump();
  20. //一级界面跳转此页面
  21. function jump() {
  22. let hash = window.location.search;
  23. if (hash) {
  24. if (hash.indexOf('name') > -1) {
  25. let newHash = hash.substr(1, hash.length)
  26. if (newHash.indexOf('&') > -1) {
  27. let hashArr = newHash.split('&');
  28. hashArr.map(item => {
  29. if (item.indexOf('name') > -1) {
  30. let names = item.split('=')
  31. theKeyword = decodeURIComponent(names[1]);
  32. $('#search_on input').val(theKeyword);
  33. }
  34. })
  35. } else {
  36. if (newHash.indexOf('name') > -1) {
  37. let names = newHash.split('=')
  38. theKeyword = decodeURIComponent(names[1]);
  39. $('#search_on input').val(theKeyword);
  40. }
  41. }
  42. loadDate()
  43. }
  44. } else {
  45. theKeyword = "",
  46. loadDate();
  47. }
  48. }
  49. function loadDate(pageNo) {
  50. $('.loading').show();
  51. $('.pagination_box').css('display', 'block')
  52. $.ajax({
  53. method: "get",
  54. dataType: "json",
  55. url: globalConfig.context + "/portal/policy/list",
  56. data: {
  57. pageNo: pageNo || 1,
  58. pageSize: pageSize,
  59. keyword: theKeyword,
  60. provinceId: Province != 999 ? Province : undefined
  61. },
  62. success: function (data) {
  63. console.log(data)
  64. var theArr = [];
  65. thePageLength = data.data.totalCount ? Math.ceil(data.data.totalCount / pageSize) : 1;
  66. console.log(thePageLength)
  67. if (data.data && data.data.list) {
  68. for (let i = 0; i < data.data.list.length; i++) {
  69. let thisdata = data.data.list[i];
  70. var id = thisdata.id;
  71. var title = thisdata.title; //标题
  72. var timeAll =new Date(thisdata.releaseDate)
  73. var time = timeAll.toLocaleDateString();
  74. var day = timeAll.getDate()>9?timeAll.getDate():'0'+timeAll.getDate() //号
  75. var month =timeAll.getFullYear()+'-'+ timeAll.getMonth(); //年、月
  76. var summary = thisdata.summary; //简介
  77. if (summary == null) {
  78. summary == '暂无内容'
  79. };
  80. var sol = '';
  81. var srctt = globalConfig.context + '/portal/news/newsDetail.html?id=' + id+'&type=0';
  82. theArr.push([
  83. '<li value="' + id + '">',
  84. '<div class="policy_time">',
  85. '<p>' + day + '</p>',
  86. '<time>' + month + '</time>',
  87. '</div>',
  88. '<div class="policy_details">',
  89. '<h4><a href="' + srctt + '">' + title + '</a></h4>',
  90. '<p>' + summary + '</p>',
  91. '<a href="' + srctt + '">MORE+</a>',
  92. '</div>',
  93. '</li>',
  94. ].join(''));
  95. };
  96. };
  97. $('.loading').hide().stop(true,true);
  98. $('.policy ul').empty();
  99. $('.policy ul').append(theArr.join(''));
  100. if (data.data&&data.data.list.length< 1) {
  101. $('.pagination_box').css('display', 'none')
  102. };
  103. if (data.data.list.length == 0) {
  104. $('.policy ul').html('<div class="imgbg"></div>')
  105. };
  106. $('.totalCount').html("共 " + thePageLength + " 页 " + data.data.totalCount + " 条数据");
  107. var pageArr = [],
  108. firstNo = 1,
  109. endNo = 5;
  110. if (thePageNo > 3) {
  111. firstNo = thePageNo - 2;
  112. endNo = Math.min((Number(thePageNo) + 2), thePageLength);
  113. } else {
  114. endNo = Math.min(thePageLength, 5);
  115. };
  116. for (let i = firstNo; i <= endNo; i++) {
  117. if (i == thePageNo) {
  118. pageArr.push(
  119. '<li class="pageNumber active"><a href="#" value=' + i + ' >' + i + '</a></li>'
  120. );
  121. } else {
  122. pageArr.push(
  123. '<li class="pageNumber"><a href="#" value=' + i + ' >' + i + '</a></li>'
  124. );
  125. }
  126. };
  127. $('.pageNumber').remove();
  128. $('.pagePre').after(pageArr.join(''));
  129. },
  130. });
  131. }
  132. //点击分页
  133. $('.pagination').on('click', 'li', function (e) {
  134. e.preventDefault();
  135. if (this.className === 'pagePre') {
  136. if (thePageNo > 1) {
  137. thePageNo = 1;
  138. loadDate(thePageNo);
  139. }
  140. } else if (this.className === 'pageNext') {
  141. if (thePageNo < thePageLength) {
  142. thePageNo = thePageLength;
  143. loadDate(thePageNo);
  144. }
  145. } else {
  146. var nextPageNo = $(this).children()[0].text;
  147. if (thePageNo != nextPageNo) {
  148. $(this).siblings("li").removeClass("active");
  149. $(this).addClass("active");
  150. thePageNo = nextPageNo;
  151. loadDate(thePageNo);
  152. };
  153. };
  154. });
  155. //链接详情
  156. $('.invest_imglist ul').on('click', 'li', function () {
  157. var theId = $(this).attr('value');
  158. window.open(globalConfig.context + '/portal/thinkTank/thinkerDetail.html?id=' + theId);
  159. })
  160. //导航城市添加
  161. var industryListArr = [],
  162. industryChildrenArr = [];
  163. industryListArr.push(['<li value="999" class="active">',
  164. '<span>',
  165. '不限',
  166. '</span>',
  167. '</li>',
  168. ].join(''));
  169. provinceList.map(function (item) {
  170. industryListArr.push(['<li value="' + item.id + '">',
  171. '<span>',
  172. item.name,
  173. '</span>',
  174. '</li>',
  175. ].join(''));
  176. });
  177. if (industryListArr && industryListArr.length) {
  178. $('#industryList').append(industryListArr.join(''));
  179. };
  180. //点击城市时
  181. $('#industryList li').click(function () {
  182. window.location.hash='';
  183. theKeyword = $('#search_on input').val();
  184. var theValue = this.value;
  185. $(this).siblings("li").removeClass("active");
  186. $(this).addClass("active");
  187. Province = theValue;
  188. loadDate();
  189. })
  190. //搜索时
  191. $('#btn_search').click(function (e) {
  192. e.preventDefault();
  193. var citys = $('#industryList .active').attr('value');
  194. var val_inp = $('#search_on input').val();
  195. Province = citys;
  196. theKeyword = val_inp;
  197. loadDate();
  198. })
  199. })