policyList.js 5.9 KB

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