/* * @author:liting * @update:2018/06/20 * */ import 'css/newMenu/public.css'; import 'css/newMenu/header.css' import 'css/newMenu/serviceList.css'; import 'js/public.js'; "use strict"; $(function () { var thePageNo = 1, thePageLength = 1, dataList = {}, pageSize = 15; init(); function init() { pages(); inpFun(); summary(); search(); // jump(); $('.onSelect .preFirst').css('display', 'none'); $('.onSelect .next').css('display', 'none'); $('.hot ul li').removeClass('active'); }; //一级界面跳转此页面 function jump(theData) { let hash = window.location.search; if (hash) { if (hash.indexOf('name') > -1 || hash.indexOf('topId') > -1 || hash.indexOf('secondId')|| hash.indexOf('module') > -1) { let newHash = hash.substr(1, hash.length) if (newHash.indexOf('&') > -1) { let hashArr = newHash.split('&'); hashArr.map(item => { if (item.indexOf('module') > -1) { let moduleT = item.split('=') dataList.module = decodeURIComponent(moduleT[1]) menuInit(theData,moduleT[1],true) } if (item.indexOf('name') > -1) { let names = item.split('=') dataList.name = decodeURIComponent(names[1]) $('.demandSearch').val(dataList.name); menuInit(theData) } if (item.indexOf('topId') > -1) { let topIds = item.split('=') dataList.topId = decodeURIComponent(topIds[1]) menuInit(theData,topIds) } if (item.indexOf('secondId') > -1) { let secondIds = item.split('=') dataList.secondId = decodeURIComponent(secondIds[1]) menuInit(theData,secondIds[1]) } }) } else { if (newHash.indexOf('name') > -1) { let names = newHash.split('=') dataList.name = decodeURIComponent(names[1]) $('.demandSearch').val(dataList.name); menuInit(theData) } if (newHash.indexOf('module') > -1) { let moduleT = newHash.split('=') dataList.module = decodeURIComponent(moduleT[1]) menuInit(theData,moduleT[1],true) } if (newHash.indexOf('topId') > -1) { let topIds = newHash.split('=') dataList.topId = decodeURIComponent(topIds[1]) menuInit(theData,topIds[1]) } if (newHash.indexOf('secondId') > -1) { let secondIds = newHash.split('=') dataList.secondId = decodeURIComponent(secondIds[1]) menuInit(theData,secondIds[1]) } } loadDate() } } else { dataList.name = "", dataList.topId = "", //行业 dataList.secondId = "" //类型 loadDate(); menuInit(theData); } } //跳转渲染菜单 function menuInit(data,id='',state){ var theArrs = '',htmls='',htmlSec=''; htmls+='
'; let thisdata=data,m,n,l; thisdata.unshift({ module: '', name: '不限', list:[{ topLevelId:'', topLevel:'不限' }] }) thisdata.map((item,index)=>{ htmls+='
'; if(item.module==id){ theArrs+=`
  • ${item.name}
  • `; }else{ theArrs+='
  • '+item.name+'
  • '; } if(item.list&&(item.list).length){ (item.list).map((atem,ind)=>{ if(atem.topLevelId==id){ m=index;n=ind; htmls+=''+atem.topLevel+'' return; }else{ atem.children&&(atem.children).map((otem,nub)=>{ if(otem.id==id){ m=index;n=ind,l=nub; } }) } htmls+=''+atem.topLevel+'' }) } htmls+='
    ' }) if(l>=0){ let listSec = thisdata[m].list[n].children; listSec.map(ttm=>{ htmlSec+=`
  • ${ttm.name}
  • ` }) }else{ l=0; htmlSec='
  • 不限
  • '; } htmls+='
    '; if(!id){ dataList.module=''; $('.industryList').append(htmls); $('.industryList ul').html(theArrs); $('.industryList ul li').eq(0).addClass('active'); $('.objList div').eq(0).addClass('active'); $('.objList div').eq(0).addClass('active'); $('.objList div').eq(0).find('span').addClass('active'); $('.productionType ol').html(`
  • 不限
  • `); }else{ $('.industryList').append(htmls); $('.industryList ul').html(theArrs); if(state){ $('.objList>div').eq((id-1)).addClass('active'); $('.objList>div').eq((id-1)).find('div').eq(0).addClass('active'); }else{ $('.objList>div').eq(m).addClass('active'); $('.objList>div').eq(m).find('span').eq(n).addClass('active'); } $('.industryList ul li').eq(m).addClass('active'); $('.productionType ol').html(htmlSec); $('.productionType ol li').eq(l).addClass('active'); } onSelect(thisdata); } function summary() { $.ajax({ method: "get", dataType: "json", url: globalConfig.context + "/portal/service/jtBusiness/makeMoneyCategoryList", data: {}, success: function (data) { if (data.data && data.data.length) { let thisdata = data.data; jump(thisdata) }; } }) } function loadDate(pageNo) { $('.loading').show(); $.ajax({ method: "get", dataType: "json", url: globalConfig.context + "/portal/service/jtProject/list", data: { pageNo: pageNo || 1, pageSize: 15, name: dataList.name, topId: dataList.topId, //行业 secondId: dataList.secondId, //类型 privateProject:1, auditStatus:2, module:dataList.module||'0' }, success: function (data) { var theArrs = []; if(data&&data.error.length){ msg(data.error[0].message) }; let times = new Date().getTime(); if (data.data && data.data.list.length) { let nub = data.data.list.length; for (let i = 0; i < nub; i++) { let thisdata = data.data.list[i], news = formatDuring(times)-formatDuring(thisdata.releaseDate); var introd=thisdata.introduce?(thisdata.introduce).replace(/<\/?.+?>/g,""):thisdata.introduce; theArrs.push(`
  • ${thisdata.maxImgUrl&&thisdata.maxImgUrl!=null?'':''}
    ${thisdata.name}
    ${thisdata.companyName?thisdata.companyName:''} 销量 : ${thisdata.dealCount?thisdata.dealCount:0}
  • `); }; }; $('.loading').hide().stop(true,true); $('.achievementHot .hotList').empty(); $('.achievementHot .hotList').append(theArrs.join('')); $('.pagination_box').css('display', 'block'); $('.inp').css('display', 'block'); if (data.data.list.length === 0) { $('.achievementHot .hotList').html("
    "); $('.pagination_box').css('display', 'none') $('.inp').css('display', 'none'); }; thePageLength = data.data.totalCount ? Math.ceil(data.data.totalCount / pageSize) : 1; $('.totalCount').html(`共${data.data.totalCount}条数据 ${thePageLength}页`) var pageArr = [], firstNo = 1, thePageNo=pageNo||1, endNo = 5; if (thePageNo > 3) { firstNo = thePageNo - 2; endNo = Math.min((Number(thePageNo) + 2), thePageLength); } else { endNo = Math.min(thePageLength, 5); }; for (let i = firstNo; i <= endNo; i++) { if (i == thePageNo) { pageArr.push( '
  • ' + i + '
  • ' ); } else { pageArr.push( '
  • ' + i + '
  • ' ); } }; $('.pageNumber').remove(); $('.pagePre').after(pageArr.join('')); urlDetaile(); } }); } //跳转详情函数 function urlDetaile(){ $('.hotList>li').click(function(){ let idUrl = $(this).attr('dataId'); window.location.href=globalConfig.context+'/portal/service/serviceDetail?id='+idUrl; }) } //时间转换 function formatDuring(mss) { var days = parseInt(mss / (1000 * 60 * 60 * 24)); var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60)); var seconds = (mss % (1000 * 60)) / 1000; return days ; } //f分页 function pages() { $('.pagination').on('click', 'li', function (e) { e.preventDefault(); if (this.className === 'pagePre') { if (thePageNo > 1) { thePageNo = 1; loadDate(thePageNo); } } else if (this.className === 'pageNext') { if (thePageNo < thePageLength) { thePageNo = thePageLength; loadDate(thePageNo); } } else { var nextPageNo = $(this).children()[0].text; if (thePageNo != nextPageNo) { $(this).siblings("li").removeClass("active"); $(this).addClass("active"); thePageNo = nextPageNo; loadDate(thePageNo); }; }; }); } //输入跳转 function inpFun() { $('.inp button').on('click', function () { let val = $(this).siblings().val(); if (!isNaN(val) && val <= thePageLength && val > 0&&val%1=='0') { thePageNo = val; loadDate(thePageNo); }else{ msg('请输入正确页码') } }) } //已选类型 function onSelect(data) { $('.industryList ul li').click(function(){ let index = $(this).index(); $(this).addClass('active').siblings().removeClass('active'); $('.objList div span').removeClass('active'); $('.objList div').eq(index).addClass('active').siblings().removeClass('active'); if(!index){ $('.objList div').eq(index).find('span').addClass('active'); } $('.productionType ol').html('
  • 不限
  • ') $('.preFirst').show(); $('.preFirst').html($(this).text()); $('.next').css('display', 'none') dataList.name=''; dataList.topId=''; dataList.secondId=''; dataList.module=$(this).attr('data-module'); loadDate(); secH(); }) $('.objList div span').on('click', function () { let secondTxt = [], scondHtml = []; $('.hot ul li').removeClass('active'); $(this).parent('div').addClass('active').siblings().removeClass('active') $('.industryList ul li p').removeClass('active'); $(this).addClass('active').siblings().removeClass('active') dataList.topId = $(this).attr('data-id'); dataList.name = ''; dataList.secondId = ''; $('.next').css('display', 'none') data.map(item => { if(item.list&&(item.list).length){ (item.list).map(atem=>{ if (atem.topLevelId == dataList.topId) { secondTxt = atem.children } }) } }) secondTxt.map(item => { scondHtml.push(`
  • ${item.name}
  • `) }) if (!dataList.topId) { dataList.topId = ''; dataList.secondId = ''; $('.preFirst').html('不限'); $('.next').css('display', 'none') scondHtml = ['
  • 不限
  • ']; } $('.productionType ol').html(scondHtml); let txt = $(this).text(); $('.onSelect .preFirst').css('display', 'block').html(` ${txt} `) loadDate(); secSelect(); secH(); }); secSelect(); secH() } //二级菜单高度处理 function secH(){ let proH = $('.productionType ol').height(); if(proH>50){ $('.productionType p').css({'height':proH,'line-height':proH+'px'}) }else{ $('.productionType p').css({'height':'50px','line-height':'50px'}) } } function secSelect(){ $('.productionType ol li').on('click', function () { dataList.name = ''; dataList.topId = $('.industryList ul li.active').attr('data-id'); $(this).addClass('active').siblings().removeClass('active'); dataList.secondId = $(this).attr('data-id'); if (!dataList.secondId) return; let txt = $(this).text(); $('.onSelect .next').css('display', 'block').html(` ${txt} `) loadDate(); }) } //搜索 function search() { $('.hot ul li').click(function () { $(this).addClass('active').siblings().removeClass('active'); dataList.name = $(this).text(); $('.productionType ol').html(`
  • 不限
  • `); $('.industryList ul li').removeClass('active'); $('.productionType ol li').removeClass('active') $('.demandSearch').val(dataList.name); $('.objList div span').removeClass('active'); dataList.topId = ''; dataList.secondId = ''; dataList.module=''; loadDate(); }); $('.searchBtn').click(function () { let val = $('.demandSearch').val(); $('.productionType ol').html(`
  • 不限
  • `); $('.industryList ul li').removeClass('active'); $('.productionType ol li').removeClass('active'); $('.objList div span').removeClass('active'); dataList.name = val; dataList.topId = ''; dataList.secondId = ''; dataList.module=''; loadDate(); }) } /* 提示 */ //提示框渐隐函数 function msg(txt) { if($('.smg').hasClass('active')){ return ; } $('.smg').addClass('active'); var lit = $('#msg').val(txt); setTimeout(function () { $('.smg').removeClass('active') $('#msg').val(''); }, 2000) } })