patentList.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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. ${item.children.length>7?'<a href="javascript:void(0);" class="more">更多+</a>':''}
  149. </div>
  150. </div>
  151. `)
  152. }
  153. })
  154. $('.serviceList').html(theArrs.join(''));
  155. onSelect(thisdata);
  156. jump();
  157. $('footer').show();
  158. };
  159. }
  160. })
  161. }
  162. function loadDate(pageNo) {
  163. $('.loading').show();
  164. $.ajax({
  165. method: "get",
  166. dataType: "json",
  167. url: globalConfig.context + "/portal/service/jtProject/list",
  168. data: {
  169. pageNo: pageNo || 1,
  170. pageSize: 15,
  171. name: dataList.name,
  172. topId: dataList.topId, //行业
  173. secondId: dataList.secondId, //类型
  174. privateProject: 1,
  175. auditStatus: 2,
  176. module: 1,
  177. orderType:dataList.ordetType,
  178. orderSort:dataList.orderSort
  179. },
  180. success: function (data) {
  181. var theArrs = [];
  182. if (data && data.error.length) {
  183. msg(data.error[0].message)
  184. };
  185. let times = new Date().getTime();
  186. if (data.data && data.data.list.length) {
  187. let nub = data.data.list.length;
  188. for (let i = 0; i < nub; i++) {
  189. let thisdata = data.data.list[i];
  190. theArrs.push(`
  191. <li>
  192. <a href="${globalConfig.context}/portal/service/patentDetail?id=${thisdata.id}">
  193. <div class="img serviceImg">
  194. ${thisdata.maxImgUrl&&thisdata.maxImgUrl!=null?'<img src="'+globalConfig.avatarHost+'/upload'+thisdata.maxImgUrl+'"/>':''}
  195. </div>
  196. <div class="txtIntroduce">
  197. <div class="txts">
  198. <h5>${thisdata.name}</h5>
  199. </div>
  200. <div class="btnTxt">
  201. <p>
  202. <span class="companyImg"></span>
  203. <a href="${globalConfig.context}/portal/companyProfile?uid=${thisdata.companyId}" class="companyName">${thisdata.companyName}</a>
  204. <span class="number">销量 : ${thisdata.dealCount?thisdata.dealCount:0}</span>
  205. </p>
  206. </div>
  207. </div>
  208. </a>
  209. </li>
  210. `);
  211. };
  212. };
  213. $('.loading').hide().stop(true, true);
  214. $('.achievementHot .hotList').empty();
  215. $('.achievementHot .hotList').append(theArrs.join(''));
  216. $('.pagination_box').css('display', 'block');
  217. $('.inp').css('display', 'block');
  218. if (data.data.list.length === 0) {
  219. $('.achievementHot .hotList').html("<div class='list_none'></div>");
  220. $('.pagination_box').css('display', 'none');
  221. $('.inp').css('display', 'none');
  222. };
  223. thePageLength = data.data.totalCount ? Math.ceil(data.data.totalCount / pageSize) : 1;
  224. $('.totalCount').html(`共${data.data.totalCount}条数据 ${thePageLength}页`)
  225. var pageArr = [],
  226. firstNo = 1,
  227. endNo = 5;
  228. if (thePageNo > 3) {
  229. firstNo = thePageNo - 2;
  230. endNo = Math.min((Number(thePageNo) + 2), thePageLength);
  231. } else {
  232. endNo = Math.min(thePageLength, 5);
  233. };
  234. for (let i = firstNo; i <= endNo; i++) {
  235. if (i == thePageNo) {
  236. pageArr.push(
  237. '<li class="pageNumber active"><a href="#" value=' + i + ' >' + i + '</a></li>'
  238. );
  239. } else {
  240. pageArr.push(
  241. '<li class="pageNumber"><a href="#" value=' + i + ' >' + i + '</a></li>'
  242. );
  243. }
  244. };
  245. $('.pageNumber').remove();
  246. $('.pagePre').after(pageArr.join(''));
  247. }
  248. });
  249. }
  250. //时间转换
  251. function formatDuring(mss) {
  252. var days = parseInt(mss / (1000 * 60 * 60 * 24));
  253. var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  254. var minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60));
  255. var seconds = (mss % (1000 * 60)) / 1000;
  256. return days;
  257. }
  258. //f分页
  259. function pages() {
  260. $('.pagination').on('click', 'li', function (e) {
  261. e.preventDefault();
  262. if (this.className === 'pagePre') {
  263. if (thePageNo > 1) {
  264. thePageNo = 1;
  265. loadDate(thePageNo);
  266. }
  267. } else if (this.className === 'pageNext') {
  268. if (thePageNo < thePageLength) {
  269. thePageNo = thePageLength;
  270. loadDate(thePageNo);
  271. }
  272. } else {
  273. var nextPageNo = $(this).children()[0].text;
  274. if (thePageNo != nextPageNo) {
  275. $(this).siblings("li").removeClass("active");
  276. $(this).addClass("active");
  277. thePageNo = nextPageNo;
  278. loadDate(thePageNo);
  279. };
  280. };
  281. });
  282. }
  283. //输入跳转
  284. function inpFun() {
  285. $('.inp .btn').on('click', function () {
  286. let val = $(this).siblings().val();
  287. if (!isNaN(val) && val <= thePageLength && val > 0) {
  288. thePageNo = val;
  289. loadDate(thePageNo);
  290. } else {
  291. msg('请输入正确页码')
  292. }
  293. })
  294. }
  295. //已选类型
  296. function onSelect(data) {
  297. $('.industryList ul li').on('click', function () {
  298. $('.industryList ul li').removeClass('active')
  299. $(this).addClass('active');
  300. dataList.secondId = $(this).attr('data-id');
  301. dataList.topId = $(this).parents('.industry').attr('data');
  302. dataList.name = '';
  303. let txt = $(this).text();
  304. $('.onSelect .preFirst').css('display', 'block').html(`
  305. <span>${txt}</span>
  306. `)
  307. loadDate();
  308. });
  309. //更多
  310. $('.industryList .more').click(function () {
  311. let index = $(this).parents('.industry').index();
  312. heigFun(index);
  313. })
  314. }
  315. function heigFun(index){
  316. let ulH = $('.serviceList .industry').eq(index).find('.industryList ').height();
  317. if ($('.industry').eq(index).hasClass('activeH')) {
  318. $('.industry').eq(index).removeClass('activeH');
  319. $('.industry').eq(index).height(52);
  320. $('.industry').eq(index).find('.more').text('更多+')
  321. $('.industry').eq(index).find('p').css({'height':'52px','line-height':'52px'})
  322. }else{
  323. $('.industry').eq(index).find('.more').text('收起')
  324. $('.industry').eq(index).addClass('activeH');
  325. $('.industry').eq(index).height(ulH);
  326. $('.industry').eq(index).find('p').css({'height':ulH+'px','line-height':ulH+'px'})
  327. }
  328. }
  329. //搜索
  330. function search() {
  331. $('.hot ul li span').click(function(){
  332. $(this).parents('ul').find('.sort span').removeClass('active');
  333. $(this).addClass('active');
  334. })
  335. $('.hot ul li:eq(0) span').click(function (e) {
  336. if((e.target.className).indexOf('up')>-1){
  337. dataList.ordetType=2;
  338. dataList.orderSort=1;
  339. }else{
  340. dataList.ordetType=2;
  341. dataList.orderSort=0
  342. }
  343. loadDate();
  344. });
  345. $('.hot ul li:eq(1) span').click(function (e) {
  346. if((e.target.className).indexOf('up')>-1){
  347. dataList.ordetType=1;
  348. dataList.orderSort=1;
  349. }else{
  350. dataList.ordetType=1;
  351. dataList.orderSort=0
  352. }
  353. loadDate();
  354. });
  355. $('.searchBtn').click(function () {
  356. let val = $('.demandSearch').val();
  357. $('.industry ul li').removeClass('active');
  358. $('.hot ul li .sort span').removeClass('active')
  359. $('.preFirst').hide();
  360. dataList.name = val;
  361. dataList.topId = '';
  362. dataList.secondId = '';
  363. dataList.ordetType=0;
  364. dataList.orderSort=0;
  365. loadDate();
  366. })
  367. }
  368. /* 提示 */
  369. //提示框渐隐函数
  370. function msg(txt) {
  371. if ($('.smg').hasClass('active')) {
  372. return;
  373. }
  374. $('.smg').addClass('active');
  375. var lit = $('#msg').val(txt);
  376. setTimeout(function () {
  377. $('.smg').removeClass('active')
  378. $('#msg').val('');
  379. }, 2000)
  380. }
  381. })