patentList.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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. $('.onSelect .preFirst').css('display', 'block').html(`
  49. <span>不限</span>
  50. `)
  51. }
  52. })
  53. }
  54. if (item.indexOf('secondId') > -1) {
  55. let secondIds = item.split('=')
  56. dataList.secondId = decodeURIComponent(secondIds[1])
  57. (dataList.data).map((item,index)=>{
  58. if((item.children).length){
  59. (item.children).map((atem,indexT)=>{
  60. if(dataList.secondId==atem.id){
  61. if(indexT>=7){
  62. heigFun(index)
  63. };
  64. $('.onSelect .preFirst').css('display', 'block').html(`
  65. <span>${atem.name}</span>
  66. `)
  67. $('.serviceList .industry').eq(index).find('.industryList ul li').eq(indexT+1).addClass('active');
  68. }
  69. })
  70. }
  71. })
  72. }
  73. })
  74. } else {
  75. if (newHash.indexOf('name') > -1) {
  76. let names = newHash.split('=')
  77. dataList.name = decodeURIComponent(names[1])
  78. $('.demandSearch').val(dataList.name);
  79. }
  80. if (newHash.indexOf('topId') > -1) {
  81. let topIds = newHash.split('=')
  82. dataList.topId = decodeURIComponent(topIds[1])
  83. dataList.data.map((item,index)=>{
  84. if(dataList.topId==item.topLevelId){
  85. $('.serviceList .industry').eq(index).find('.industryList ul li:eq(0)').addClass('active');
  86. }
  87. $('.onSelect .preFirst').css('display', 'block').html(`
  88. <span>不限</span>
  89. `)
  90. })
  91. }
  92. if (newHash.indexOf('secondId') > -1) {
  93. let secondIds = newHash.split('=')
  94. dataList.secondId = decodeURIComponent(secondIds[1]);
  95. (dataList.data).map((item,index)=>{
  96. if((item.children).length){
  97. (item.children).map((atem,indexT)=>{
  98. if(dataList.secondId==atem.id){
  99. if(indexT>=7){
  100. heigFun(index)
  101. };
  102. $('.onSelect .preFirst').css('display', 'block').html(`
  103. <span>${atem.name}</span>
  104. `)
  105. $('.serviceList .industry').eq(index).find('.industryList ul li').eq(indexT+1).addClass('active');
  106. }
  107. })
  108. }
  109. })
  110. }
  111. }
  112. loadDate()
  113. }
  114. } else {
  115. dataList.name = "",
  116. dataList.topId = "", //行业
  117. dataList.secondId = "" //类型
  118. dataList.ordetType=0;
  119. dataList.orderSort='';
  120. loadDate();
  121. }
  122. }
  123. function summary() {
  124. $.ajax({
  125. method: "get",
  126. dataType: "json",
  127. url: globalConfig.context + "/portal/service/jtBusiness/getCategoryList",
  128. data: {
  129. module: 1
  130. },
  131. success: function (data) {
  132. var theArrs = [];
  133. if (data.data && data.data.length) {
  134. let thisdata = data.data;
  135. dataList.data=thisdata;
  136. thisdata.map((item) => {
  137. theArrs.push(`
  138. <div class="industry" data="${item.topLevelId}"><p>${item.topLevel}</p><div class="industryList"><ul><li data-id=''>不限</li>
  139. `)
  140. if (item.children) {
  141. item.children.map(atem => {
  142. theArrs.push(`
  143. <li data-id=${atem.id}>${atem.name}</li>
  144. `)
  145. })
  146. theArrs.push(`
  147. </ul>
  148. </div>
  149. </div>
  150. `)
  151. }
  152. })
  153. $('.serviceList').html(theArrs.join(''));
  154. let ind = $('.serviceList .industry'),
  155. ulW = $('.industryList ul').width();
  156. for(let i=0;i<ind.length;i++){
  157. let thisUl=ind[i],totalW=0,
  158. othLis = $(thisUl).find('.industryList ul li');
  159. for(let j =0;j<othLis.length;j++){
  160. totalW+=othLis[j].offsetWidth;
  161. }
  162. if(totalW>ulW){
  163. $(thisUl).find('.industryList').append(`<a href="javascript:void(0);" class="more">更多+</a>`)
  164. }
  165. }
  166. onSelect(thisdata);
  167. jump();
  168. $('footer').show();
  169. };
  170. }
  171. })
  172. }
  173. function loadDate(pageNo) {
  174. $('.loading').show();
  175. $.ajax({
  176. method: "get",
  177. dataType: "json",
  178. url: globalConfig.context + "/portal/service/jtProject/list",
  179. data: {
  180. pageNo: pageNo || 1,
  181. pageSize: 15,
  182. name: dataList.name,
  183. topId: dataList.topId, //行业
  184. secondId: dataList.secondId, //类型
  185. privateProject: 1,
  186. auditStatus: 2,
  187. module: 1,
  188. orderType:dataList.ordetType,
  189. orderSort:dataList.orderSort
  190. },
  191. success: function (data) {
  192. var theArrs = [];
  193. if (data && data.error.length) {
  194. msg(data.error[0].message)
  195. };
  196. let times = new Date().getTime();
  197. if (data.data && data.data.list.length) {
  198. let nub = data.data.list.length;
  199. for (let i = 0; i < nub; i++) {
  200. let thisdata = data.data.list[i];
  201. theArrs.push(`
  202. <li>
  203. <a href="${globalConfig.context}/portal/service/patentDetail?id=${thisdata.id}">
  204. <div class="img serviceImg">
  205. ${thisdata.maxImgUrl&&thisdata.maxImgUrl!=null?'<img src="'+globalConfig.avatarHost+'/upload'+thisdata.maxImgUrl+'"/>':''}
  206. </div>
  207. <div class="txtIntroduce">
  208. <div class="txts">
  209. <h5>${thisdata.name}</h5>
  210. </div>
  211. <div class="btnTxt">
  212. <p>
  213. <span class="companyImg"></span>
  214. <a href="javascript:(0)" class="companyName">${thisdata.companyName}</a>
  215. <span class="number">销量 : ${thisdata.dealCount?thisdata.dealCount:0}</span>
  216. </p>
  217. </div>
  218. </div>
  219. </a>
  220. </li>
  221. `);
  222. };
  223. };
  224. $('.loading').hide().stop(true, true);
  225. $('.achievementHot .hotList').empty();
  226. $('.achievementHot .hotList').append(theArrs.join(''));
  227. $('.pagination_box').css('display', 'block');
  228. $('.inp').css('display', 'block');
  229. if (data.data.list.length === 0) {
  230. $('.achievementHot .hotList').html("<div class='list_none'></div>");
  231. $('.pagination_box').css('display', 'none');
  232. $('.inp').css('display', 'none');
  233. };
  234. thePageLength = data.data.totalCount ? Math.ceil(data.data.totalCount / pageSize) : 1;
  235. $('.totalCount').html(`共${data.data.totalCount}条数据 ${thePageLength}页`)
  236. var pageArr = [],
  237. firstNo = 1,
  238. thePageNo=pageNo||1,
  239. endNo = 5;
  240. if (thePageNo > 3) {
  241. firstNo = thePageNo - 2;
  242. endNo = Math.min((Number(thePageNo) + 2), thePageLength);
  243. } else {
  244. endNo = Math.min(thePageLength, 5);
  245. };
  246. for (let i = firstNo; i <= endNo; i++) {
  247. if (i == thePageNo) {
  248. pageArr.push(
  249. '<li class="pageNumber active"><a href="#" value=' + i + ' >' + i + '</a></li>'
  250. );
  251. } else {
  252. pageArr.push(
  253. '<li class="pageNumber"><a href="#" value=' + i + ' >' + i + '</a></li>'
  254. );
  255. }
  256. };
  257. $('.pageNumber').remove();
  258. $('.pagePre').after(pageArr.join(''));
  259. }
  260. });
  261. }
  262. //时间转换
  263. function formatDuring(mss) {
  264. var days = parseInt(mss / (1000 * 60 * 60 * 24));
  265. var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  266. var minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60));
  267. var seconds = (mss % (1000 * 60)) / 1000;
  268. return days;
  269. }
  270. //f分页
  271. function pages() {
  272. $('.pagination').on('click', 'li', function (e) {
  273. e.preventDefault();
  274. if (this.className === 'pagePre') {
  275. if (thePageNo > 1) {
  276. thePageNo = 1;
  277. loadDate(thePageNo);
  278. }
  279. } else if (this.className === 'pageNext') {
  280. if (thePageNo < thePageLength) {
  281. thePageNo = thePageLength;
  282. loadDate(thePageNo);
  283. }
  284. } else {
  285. var nextPageNo = $(this).children()[0].text;
  286. if (thePageNo != nextPageNo) {
  287. $(this).siblings("li").removeClass("active");
  288. $(this).addClass("active");
  289. thePageNo = nextPageNo;
  290. loadDate(thePageNo);
  291. };
  292. };
  293. });
  294. }
  295. //输入跳转
  296. function inpFun() {
  297. $('.inp .btn').on('click', function () {
  298. let val = $(this).siblings().val();
  299. if (!isNaN(val) && val <= thePageLength && val > 0) {
  300. thePageNo = val;
  301. loadDate(thePageNo);
  302. } else {
  303. msg('请输入正确页码')
  304. }
  305. })
  306. }
  307. //已选类型
  308. function onSelect(data) {
  309. $('.industryList ul li').on('click', function () {
  310. $('.industryList ul li').removeClass('active')
  311. $(this).addClass('active');
  312. dataList.secondId = $(this).attr('data-id');
  313. dataList.topId = $(this).parents('.industry').attr('data');
  314. dataList.name = '';
  315. let txt = $(this).text();
  316. $('.onSelect .preFirst').css('display', 'block').html(`
  317. <span>${txt}</span>
  318. `)
  319. loadDate();
  320. });
  321. //更多
  322. $('.industryList .more').click(function () {
  323. let index = $(this).parents('.industry').index();
  324. heigFun(index);
  325. })
  326. }
  327. function heigFun(index){
  328. let ulH = $('.serviceList .industry').eq(index).find('.industryList ').height();
  329. if ($('.industry').eq(index).hasClass('activeH')) {
  330. $('.industry').eq(index).removeClass('activeH');
  331. $('.industry').eq(index).height(52);
  332. $('.industry').eq(index).find('.more').text('更多+')
  333. $('.industry').eq(index).find('p').css({'height':'52px','line-height':'52px'})
  334. }else{
  335. $('.industry').eq(index).find('.more').text('收起')
  336. $('.industry').eq(index).addClass('activeH');
  337. $('.industry').eq(index).height(ulH);
  338. $('.industry').eq(index).find('p').css({'height':ulH+'px','line-height':ulH+'px'})
  339. }
  340. }
  341. //搜索
  342. function search() {
  343. $('.hot ul li span').click(function(){
  344. $(this).parents('ul').find('.sort span').removeClass('active');
  345. $(this).addClass('active');
  346. })
  347. $('.hot ul li:eq(0) span').click(function (e) {
  348. if((e.target.className).indexOf('up')>-1){
  349. dataList.ordetType=2;
  350. dataList.orderSort=1;
  351. }else{
  352. dataList.ordetType=2;
  353. dataList.orderSort=0
  354. }
  355. loadDate();
  356. });
  357. $('.hot ul li:eq(1) span').click(function (e) {
  358. if((e.target.className).indexOf('up')>-1){
  359. dataList.ordetType=1;
  360. dataList.orderSort=1;
  361. }else{
  362. dataList.ordetType=1;
  363. dataList.orderSort=0
  364. }
  365. loadDate();
  366. });
  367. $('.searchBtn').click(function () {
  368. let val = $('.demandSearch').val();
  369. $('.industry ul li').removeClass('active');
  370. $('.hot ul li .sort span').removeClass('active')
  371. $('.preFirst').hide();
  372. dataList.name = val;
  373. dataList.topId = '';
  374. dataList.secondId = '';
  375. dataList.ordetType=0;
  376. dataList.orderSort=0;
  377. loadDate();
  378. })
  379. }
  380. /* 提示 */
  381. //提示框渐隐函数
  382. function msg(txt) {
  383. if ($('.smg').hasClass('active')) {
  384. return;
  385. }
  386. $('.smg').addClass('active');
  387. var lit = $('#msg').val(txt);
  388. setTimeout(function () {
  389. $('.smg').removeClass('active')
  390. $('#msg').val('');
  391. }, 2000)
  392. }
  393. })