policyList.js 5.3 KB

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