policyList.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. import 'css/bootstrap.less';
  2. import 'bootstrap/dist/js/bootstrap.js';
  3. import 'css/thinkTank/policyList.css';
  4. import 'css/newMenu/public.css';
  5. import 'css/newMenu/header.css'
  6. import 'js/public';
  7. import {
  8. provinceList
  9. } from 'js/NewDicProvinceList';
  10. let globalConfig={
  11. context:''}
  12. $(function () {
  13. //数据处理
  14. var pageSize, Province,theKeyword;
  15. var thePageNo = 1,
  16. thePageLength = 1,
  17. dataList={type:''},
  18. pageSize =6;
  19. jump();
  20. //一级界面跳转此页面
  21. function jump() {
  22. let hash = window.location.search;
  23. if (hash) {
  24. if (hash.indexOf('name') > -1||hash.indexOf('type')>-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. dataList.title=theKeyword;
  33. $('.demandSearch').val(theKeyword);
  34. $('.policyContent .type ol li').eq(0).addClass('active').siblings().removeClass('active')
  35. }
  36. })
  37. } else {
  38. if (newHash.indexOf('name') > -1) {
  39. let names = newHash.split('=')
  40. theKeyword = decodeURIComponent(names[1]);
  41. dataList.title=theKeyword;
  42. $('.demandSearch').val(theKeyword);
  43. $('.policyContent .type ol li').eq(0).addClass('active').siblings().removeClass('active')
  44. }
  45. if (newHash.indexOf('type') > -1) {
  46. let types = newHash.split('=');
  47. dataList.type = decodeURIComponent(types[1]);
  48. switch(dataList.type){
  49. case '':
  50. $('.type ol li').eq(0).addClass('active').siblings().removeClass('active');
  51. break;
  52. case '1':
  53. $('.type ol li').eq(1).addClass('active').siblings().removeClass('active');
  54. break;
  55. case '0':
  56. $('.type ol li').eq(2).addClass('active').siblings().removeClass('active');
  57. break;
  58. case '99':
  59. $('.type ol li').eq(3).addClass('active').siblings().removeClass('active');
  60. break;
  61. case '98':
  62. $('.type ol li').eq(4).addClass('active').siblings().removeClass('active');
  63. break;
  64. default:
  65. $('.type ol li').eq(0).addClass('active').siblings().removeClass('active');
  66. break;
  67. }
  68. }
  69. }
  70. loadDate();
  71. }
  72. } else {
  73. dataList.title='';
  74. $('.type ol li').eq(0).addClass('active');
  75. loadDate();
  76. }
  77. }
  78. function loadDate(pageNo) {
  79. $('.loading').show();
  80. $('.pagination_box').css('display', 'block');
  81. $.ajax({
  82. method: "get",
  83. dataType: "json",
  84. url: globalConfig.context + "/portal/policyAndNewsList",
  85. data: {
  86. pageNo: pageNo || 1,
  87. pageSize: pageSize,
  88. type:dataList.type,
  89. title: dataList.title,
  90. province: dataList.province?dataList.province:''
  91. },
  92. success: function (data) {
  93. var theArr = [];
  94. thePageLength = data.data.totalCount ? Math.ceil(data.data.totalCount / pageSize) : 1;
  95. if (data.data && data.data.list) {
  96. for (let i = 0; i < data.data.list.length; i++) {
  97. let thisdata = data.data.list[i],
  98. id = thisdata.id,
  99. title = thisdata.title, //标题
  100. timeAll =new Date(thisdata.releaseDate),
  101. day = timeAll.getDate()>9?timeAll.getDate():'0'+timeAll.getDate(), //号
  102. month =timeAll.getMonth()+1>9?timeAll.getMonth()+1:'0'+(timeAll.getMonth()+1), //年、月
  103. year =timeAll.getFullYear(),
  104. summary = (thisdata.summary).length>90?(thisdata.summary).substr(0,90)+'...':thisdata.summary; //简介
  105. if (summary == null) {
  106. summary == '暂无内容'
  107. }
  108. var srctt = globalConfig.context + '/portal/news/newsDetail.html?id=' + id+'&type='+thisdata.type;
  109. theArr.push([
  110. '<li>',
  111. '<a href="'+srctt+'">',
  112. '<div class="yearTime">',
  113. '<p>'+month+'-'+day+'</p>',
  114. '<p>'+year+'</p>',
  115. '</div>',
  116. '<div class="txt">',
  117. '<h4>'+title+'</h4>',
  118. '<p>'+summary+'</p>',
  119. '</div>',
  120. '</a>',
  121. '</li>',
  122. ].join(''));
  123. };
  124. };
  125. $('.loading').hide().stop(true,true);
  126. $('.newLsit>ul').empty();
  127. $('.newLsit>ul').append(theArr.join(''));
  128. if (data.data&&data.data.list.length< 1) {
  129. $('.pagination_box').css('display', 'none')
  130. };
  131. if (data.data.list.length == 0) {
  132. $('.newLsit>ul').html('<div class="imgbg"></div>')
  133. };
  134. $('.totalCount').html("共 " + thePageLength + " 页 " + data.data.totalCount + " 条数据");
  135. var pageArr = [],
  136. firstNo = 1,
  137. endNo = 5;
  138. if (thePageNo > 3) {
  139. firstNo = thePageNo - 2;
  140. endNo = Math.min((Number(thePageNo) + 2), thePageLength);
  141. } else {
  142. endNo = Math.min(thePageLength, 5);
  143. };
  144. for (let i = firstNo; i <= endNo; i++) {
  145. if (i == thePageNo) {
  146. pageArr.push(
  147. '<li class="pageNumber active"><a href="#" value=' + i + ' >' + i + '</a></li>'
  148. );
  149. } else {
  150. pageArr.push(
  151. '<li class="pageNumber"><a href="#" value=' + i + ' >' + i + '</a></li>'
  152. );
  153. }
  154. };
  155. $('.pageNumber').remove();
  156. $('.pagePre').after(pageArr.join(''));
  157. },
  158. });
  159. }
  160. //点击分页
  161. $('.pagination').on('click', 'li', function (e) {
  162. e.preventDefault();
  163. if (this.className === 'pagePre') {
  164. if (thePageNo > 1) {
  165. thePageNo = 1;
  166. loadDate(thePageNo);
  167. }
  168. } else if (this.className === 'pageNext') {
  169. if (thePageNo < thePageLength) {
  170. thePageNo = thePageLength;
  171. loadDate(thePageNo);
  172. }
  173. } else {
  174. var nextPageNo = $(this).children()[0].text;
  175. if (thePageNo != nextPageNo) {
  176. $(this).siblings("li").removeClass("active");
  177. $(this).addClass("active");
  178. thePageNo = nextPageNo;
  179. loadDate(thePageNo);
  180. };
  181. };
  182. });
  183. //导航城市添加
  184. var industryListArr = [];
  185. provinceList.map(function (item) {
  186. industryListArr.push(['<li value="' + item.id + '">',
  187. '<span>',
  188. item.name,
  189. '</span>',
  190. '</li>',
  191. ].join(''));
  192. });
  193. if (industryListArr && industryListArr.length) {
  194. $('.area ol').append(industryListArr.join(''));
  195. $('.area ol li').eq(0).addClass('active');
  196. };
  197. //点击城市时
  198. $('.area ol li').click(function () {
  199. dataList.title = $('.demandSearch').val();
  200. var theValue = this.value;
  201. $(this).addClass("active").siblings("li").removeClass("active");
  202. dataList.province = theValue;
  203. loadDate();
  204. })
  205. //搜索时
  206. $('.searchBtn').click(function (e) {
  207. e.preventDefault();
  208. var citys = $('.area ol li.active').attr('value');
  209. var val_inp = $('.demandSearch').val();
  210. console.log(citys)
  211. dataList.province = citys;
  212. dataList.title = val_inp;
  213. loadDate();
  214. })
  215. //点击跟多展开地区
  216. moreFun();
  217. function moreFun(){
  218. $('.more').click(function(){
  219. if($('.area').hasClass('active')){
  220. $('.area').removeClass('active');
  221. $(this).text('更多+');
  222. }else{
  223. $('.area').addClass('active');
  224. $(this).text('更多 -');
  225. }
  226. })
  227. }
  228. typeFun();
  229. //点击分类
  230. function typeFun(){
  231. $('.type ol li').click(function(){
  232. let val = $(this).attr('value');
  233. dataList.type=val;
  234. $(this).addClass('active').siblings().removeClass('active');
  235. dataList.title='';
  236. $('.demandSearch').val('');
  237. loadDate();
  238. })
  239. }
  240. })