patentList.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. /*
  2. * @author:liting
  3. * @update:2018/07/23
  4. *
  5. */
  6. import 'css/bootstrap.less';
  7. import 'bootstrap/dist/js/bootstrap.js';
  8. import 'css/newMenu/public.css';
  9. import 'css/newMenu/header.css'
  10. import 'css/newMenu/patentList.css';
  11. import 'js/public.js';
  12. "use strict";
  13. $(function () {
  14. var thePageNo = 1,
  15. thePageLength = 1,
  16. dataList = {},
  17. pageSize = 15;
  18. init();
  19. function init() {
  20. pages();
  21. inpFun();
  22. summary();
  23. search();
  24. $('.onSelect .preFirst').css('display', 'none');
  25. $('.onSelect .next').css('display', 'none');
  26. $('.hot ul li').removeClass('active');
  27. };
  28. //一级界面跳转此页面
  29. function jump() {
  30. let hash = window.location.search;
  31. if (hash) {
  32. if (hash.indexOf('name') > -1 || hash.indexOf('topId') > -1 || hash.indexOf('secondId') > -1) {
  33. let newHash = hash.substr(1, hash.length)
  34. if (newHash.indexOf('&') > -1) {
  35. let hashArr = newHash.split('&');
  36. hashArr.map(item => {
  37. if (item.indexOf('name') > -1) {
  38. let names = item.split('=')
  39. dataList.name = decodeURIComponent(names[1])
  40. $('.demandSearch').val(dataList.name);
  41. }
  42. if (item.indexOf('topId') > -1) {
  43. let topIds = item.split('=')
  44. dataList.topId = decodeURIComponent(topIds[1]);
  45. dataList.data.map((item,index)=>{
  46. if(dataList.topId==item.topLevelId){
  47. $('.serviceList .industry').eq(index).find('.industryList ul li:eq(0)').addClass('active');
  48. }
  49. })
  50. }
  51. if (item.indexOf('secondId') > -1) {
  52. let secondIds = item.split('=')
  53. dataList.secondId = decodeURIComponent(secondIds[1])
  54. }
  55. })
  56. } else {
  57. if (newHash.indexOf('name') > -1) {
  58. let names = newHash.split('=')
  59. dataList.name = decodeURIComponent(names[1])
  60. $('.demandSearch').val(dataList.name);
  61. }
  62. if (newHash.indexOf('topId') > -1) {
  63. let topIds = newHash.split('=')
  64. dataList.topId = decodeURIComponent(topIds[1])
  65. dataList.data.map((item,index)=>{
  66. if(dataList.topId==item.topLevelId){
  67. $('.serviceList .industry').eq(index).find('.industryList ul li:eq(0)').addClass('active');
  68. }
  69. })
  70. }
  71. if (newHash.indexOf('secondId') > -1) {
  72. let secondIds = newHash.split('=')
  73. dataList.secondId = decodeURIComponent(secondIds[1])
  74. }
  75. }
  76. loadDate()
  77. }
  78. } else {
  79. dataList.name = "",
  80. dataList.topId = "", //行业
  81. dataList.secondId = "" //类型
  82. dataList.ordetType=0;
  83. dataList.orderSort='';
  84. loadDate();
  85. }
  86. }
  87. function summary() {
  88. $.ajax({
  89. method: "get",
  90. dataType: "json",
  91. url: globalConfig.context + "/portal/service/jtBusiness/getCategoryList",
  92. data: {
  93. module: 1
  94. },
  95. success: function (data) {
  96. console.log(data)
  97. var theArrs = [];
  98. if (data.data && data.data.length) {
  99. let thisdata = data.data;
  100. dataList.data=thisdata;
  101. thisdata.map((item) => {
  102. theArrs.push(`
  103. <div class="industry" data="${item.topLevelId}"><p>${item.topLevel}</p><div class="industryList"><ul><li data-id=''>不限</li>
  104. `)
  105. if (item.children) {
  106. item.children.map(atem => {
  107. theArrs.push(`
  108. <li data-id=${atem.id}>${atem.name}</li>
  109. `)
  110. })
  111. theArrs.push(`
  112. </ul>
  113. ${item.children.length>7?'<a href="javascript:void(0);" class="more">更多+</a>':''}
  114. </div>
  115. </div>
  116. `)
  117. }
  118. })
  119. $('.serviceList').html(theArrs.join(''));
  120. onSelect(thisdata);
  121. jump()
  122. };
  123. }
  124. })
  125. }
  126. function loadDate(pageNo) {
  127. $('.loading').show();
  128. $.ajax({
  129. method: "get",
  130. dataType: "json",
  131. url: globalConfig.context + "/portal/service/jtProject/list",
  132. data: {
  133. pageNo: pageNo || 1,
  134. pageSize: 15,
  135. name: dataList.name,
  136. topId: dataList.topId, //行业
  137. secondId: dataList.secondId, //类型
  138. privateProject: 1,
  139. auditStatus: 2,
  140. module: 1,
  141. ordetType:dataList.ordetType,
  142. orderSort:dataList.orderSort
  143. },
  144. success: function (data) {
  145. var theArrs = [];
  146. if (data && data.error.length) {
  147. msg(data.error[0].message)
  148. };
  149. let times = new Date().getTime();
  150. if (data.data && data.data.list.length) {
  151. let nub = data.data.list.length;
  152. for (let i = 0; i < nub; i++) {
  153. let thisdata = data.data.list[i],
  154. news = formatDuring(times) - formatDuring(thisdata.releaseDate);
  155. theArrs.push(`
  156. <li>
  157. <a href="${globalConfig.context}/portal/service/serviceDetail?id=${thisdata.id?thisdata.id:''}">
  158. <div class="img serviceImg">
  159. ${thisdata.maxImgUrl&&thisdata.maxImgUrl!=null?'<img src="'+globalConfig.avatarHost+'/upload'+thisdata.maxImgUrl+'"/>':''}
  160. </div>
  161. <div class="txtIntroduce">
  162. <div class="txts">
  163. <h5>${thisdata.name}</h5>
  164. </div>
  165. <div class="btnTxt">
  166. <p><span class="companyImg"></span><span class="companyName">${thisdata.companyName}</span><span class="number">销量 : ${thisdata.dealCount?thisdata.dealCount:0}</span></p>
  167. </div>
  168. </div>
  169. </a>
  170. </li>
  171. `);
  172. };
  173. };
  174. $('.loading').hide().stop(true, true);
  175. $('.achievementHot .hotList').empty();
  176. $('.achievementHot .hotList').append(theArrs.join(''));
  177. $('.pagination_box').css('display', 'block');
  178. $('.inp').css('display', 'block');
  179. if (data.data.list.length === 0) {
  180. $('.achievementHot .hotList').html("<div class='list_none'></div>");
  181. $('.pagination_box').css('display', 'none')
  182. $('.inp').css('display', 'none');
  183. };
  184. thePageLength = data.data.totalCount ? Math.ceil(data.data.totalCount / pageSize) : 1;
  185. $('.totalCount').html(`共${data.data.totalCount}条数据 ${thePageLength}页`)
  186. var pageArr = [],
  187. firstNo = 1,
  188. endNo = 5;
  189. if (thePageNo > 3) {
  190. firstNo = thePageNo - 2;
  191. endNo = Math.min((Number(thePageNo) + 2), thePageLength);
  192. } else {
  193. endNo = Math.min(thePageLength, 5);
  194. };
  195. for (let i = firstNo; i <= endNo; i++) {
  196. if (i == thePageNo) {
  197. pageArr.push(
  198. '<li class="pageNumber active"><a href="#" value=' + i + ' >' + i + '</a></li>'
  199. );
  200. } else {
  201. pageArr.push(
  202. '<li class="pageNumber"><a href="#" value=' + i + ' >' + i + '</a></li>'
  203. );
  204. }
  205. };
  206. $('.pageNumber').remove();
  207. $('.pagePre').after(pageArr.join(''));
  208. }
  209. });
  210. }
  211. //时间转换
  212. function formatDuring(mss) {
  213. var days = parseInt(mss / (1000 * 60 * 60 * 24));
  214. var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  215. var minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60));
  216. var seconds = (mss % (1000 * 60)) / 1000;
  217. return days;
  218. }
  219. //f分页
  220. function pages() {
  221. $('.pagination').on('click', 'li', function (e) {
  222. e.preventDefault();
  223. if (this.className === 'pagePre') {
  224. if (thePageNo > 1) {
  225. thePageNo = 1;
  226. loadDate(thePageNo);
  227. }
  228. } else if (this.className === 'pageNext') {
  229. if (thePageNo < thePageLength) {
  230. thePageNo = thePageLength;
  231. loadDate(thePageNo);
  232. }
  233. } else {
  234. var nextPageNo = $(this).children()[0].text;
  235. if (thePageNo != nextPageNo) {
  236. $(this).siblings("li").removeClass("active");
  237. $(this).addClass("active");
  238. thePageNo = nextPageNo;
  239. loadDate(thePageNo);
  240. };
  241. };
  242. });
  243. }
  244. //输入跳转
  245. function inpFun() {
  246. $('.inp .btn').on('click', function () {
  247. let val = $(this).siblings().val();
  248. if (!isNaN(val) && val <= thePageLength && val > 0) {
  249. thePageNo = val;
  250. loadDate(thePageNo);
  251. } else {
  252. msg('请输入正确页码')
  253. }
  254. })
  255. }
  256. //已选类型
  257. function onSelect(data) {
  258. $('.industryList ul li').on('click', function () {
  259. $('.industryList ul li').removeClass('active')
  260. $(this).addClass('active');
  261. dataList.secondId = $(this).attr('data-id');
  262. dataList.topId = $(this).parents('.industry').attr('data');
  263. dataList.name = '';
  264. let txt = $(this).text();
  265. $('.onSelect .preFirst').css('display', 'block').html(`
  266. <span>${txt}</span>
  267. `)
  268. loadDate();
  269. });
  270. //更多
  271. $('.industryList .more').click(function () {
  272. let ulH = $('.industryList ul').height();
  273. if ($(this).parents('.industry').hasClass('activeH')) {
  274. $(this).parents('.industry').removeClass('activeH');
  275. $(this).parents('.industry').height(52);
  276. $(this).text('更多+')
  277. $(this).parents('.industry').find('p').css({'height':'52px','line-height':'52px'})
  278. }else{
  279. $(this).text('收起')
  280. $(this).parents('.industry').addClass('activeH');
  281. $(this).parents('.industry').height(ulH);
  282. $(this).parents('.industry').find('p').css({'height':ulH+'px','line-height':ulH+'px'})
  283. }
  284. })
  285. }
  286. //搜索
  287. function search() {
  288. $('.hot ul li span').click(function(){
  289. $(this).parents('ul').find('.sort span').removeClass('active');
  290. $(this).addClass('active');
  291. })
  292. $('.hot ul li:eq(0) span').click(function (e) {
  293. if((e.target.className).indexOf('up')>-1){
  294. dataList.ordetType=1;
  295. dataList.orderSort=1;
  296. }else{
  297. dataList.ordetType=1;
  298. dataList.orderSort=0
  299. }
  300. loadDate();
  301. });
  302. $('.hot ul li:eq(1) span').click(function (e) {
  303. if((e.target.className).indexOf('up')>-1){
  304. dataList.ordetType=2;
  305. dataList.orderSort=1;
  306. }else{
  307. dataList.ordetType=2;
  308. dataList.orderSort=0
  309. }
  310. loadDate();
  311. });
  312. $('.searchBtn').click(function () {
  313. let val = $('.demandSearch').val();
  314. $('.industry ul li').removeClass('active');
  315. $('.hot ul li .sort span').removeClass('active')
  316. $('.preFirst').hide();
  317. dataList.name = val;
  318. dataList.topId = '';
  319. dataList.secondId = '';
  320. dataList.ordetType=0;
  321. dataList.orderSort=0;
  322. loadDate();
  323. })
  324. }
  325. /* 提示 */
  326. //提示框渐隐函数
  327. function msg(txt) {
  328. if ($('.smg').hasClass('active')) {
  329. return;
  330. }
  331. $('.smg').addClass('active');
  332. var lit = $('#msg').val(txt);
  333. setTimeout(function () {
  334. $('.smg').removeClass('active')
  335. $('#msg').val('');
  336. }, 2000)
  337. }
  338. })