policyList.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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/financial/investmentDetail",
  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('<li>敬请期待…</li>')
  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. $(this).addClass('active').siblings().removeClass('active')
  99. e.preventDefault();
  100. thePageNo=$(this).val();
  101. if (this.className === 'pagePre') {
  102. if (thePageNo > 1) {
  103. thePageNo = 1;
  104. loadDate(thePageNo);
  105. }
  106. } else if (this.className === 'pageNext') {
  107. if (thePageNo < thePageLength) {
  108. thePageNo = thePageLength;
  109. loadDate(thePageNo);
  110. }
  111. } else {
  112. var nextPageNo = $(this).children()[0].text;
  113. if (thePageNo != nextPageNo) {
  114. $(this).siblings("li").removeClass("active");
  115. $(this).addClass("active");
  116. thePageNo = nextPageNo;
  117. loadDate(thePageNo);
  118. };
  119. };
  120. });
  121. //链接详情
  122. $('.invest_imglist ul').on('click', 'li', function () {
  123. var theId = $(this).attr('value');
  124. window.open(globalConfig.context + '/portal/thinkTank/thinkerDetail.html?id=' + theId );
  125. })
  126. //搜索城市下拉
  127. var addlength=provinceList.length;
  128. var soption='';
  129. for(var i=0;i<addlength;i++){
  130. soption+="<option value='"+provinceList[i].id+"'>"+provinceList[i].name+"</option>";
  131. };
  132. $('#selt').html(soption);
  133. //导航城市添加
  134. var industryListArr = [],
  135. industryChildrenArr = [];
  136. industryListArr.push(['<li value="999" class="active">',
  137. '<span>',
  138. '不限',
  139. '</span>',
  140. '</li>',
  141. ].join(''));
  142. provinceList.map(function (item) {
  143. industryListArr.push(['<li value="' +item.id + '">',
  144. '<span>',
  145. item.name,
  146. '</span>',
  147. '</li>',
  148. ].join(''));
  149. });
  150. if (industryListArr && industryListArr.length) {
  151. $('#industryList').append(industryListArr.join(''));
  152. };
  153. //点击城市时
  154. $('#industryList li').click(function () {
  155. var theValue = this.value;
  156. $(this).siblings("li").removeClass("active");
  157. $(this).addClass("active");
  158. Province=theValue;
  159. loadDate();
  160. })
  161. //搜索时
  162. $('#btn_search').click(function(e){
  163. e.preventDefault();
  164. var sel= $('.select select').val();
  165. var val_inp=$('#search_on input').val();
  166. Province=sel;
  167. theKeyword=val_inp;
  168. loadDate();
  169. })
  170. })