policyList.js 5.8 KB

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