123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 |
- /*
- * @author:liting
- * @update:2018/07/23
- *
- */
- import 'css/bootstrap.less';
- import 'bootstrap/dist/js/bootstrap.js';
- import 'css/newMenu/public.css';
- import 'css/newMenu/header.css'
- import 'css/newMenu/patentList.css';
- import 'js/public.js';
- "use strict";
- $(function () {
- var thePageNo = 1,
- thePageLength = 1,
- dataList = {},
- pageSize = 15;
- init();
- function init() {
- pages();
- inpFun();
- summary();
- search();
- $('.onSelect .preFirst').css('display', 'none');
- $('.onSelect .next').css('display', 'none');
- $('.hot ul li').removeClass('active');
- };
- //一级界面跳转此页面
- function jump() {
- let hash = window.location.search;
- if (hash) {
- if (hash.indexOf('name') > -1 || hash.indexOf('topId') > -1 || hash.indexOf('secondId') > -1) {
- let newHash = hash.substr(1, hash.length)
- if (newHash.indexOf('&') > -1) {
- let hashArr = newHash.split('&');
- hashArr.map(item => {
- if (item.indexOf('name') > -1) {
- let names = item.split('=')
- dataList.name = decodeURIComponent(names[1])
- $('.demandSearch').val(dataList.name);
- }
- if (item.indexOf('topId') > -1) {
- let topIds = item.split('=')
- dataList.topId = decodeURIComponent(topIds[1]);
- dataList.data.map((item,index)=>{
- if(dataList.topId==item.topLevelId){
- $('.serviceList .industry').eq(index).find('.industryList ul li:eq(0)').addClass('active');
- }
- })
- }
- if (item.indexOf('secondId') > -1) {
- let secondIds = item.split('=')
- dataList.secondId = decodeURIComponent(secondIds[1])
- }
- })
- } else {
- if (newHash.indexOf('name') > -1) {
- let names = newHash.split('=')
- dataList.name = decodeURIComponent(names[1])
- $('.demandSearch').val(dataList.name);
- }
- if (newHash.indexOf('topId') > -1) {
- let topIds = newHash.split('=')
- dataList.topId = decodeURIComponent(topIds[1])
- dataList.data.map((item,index)=>{
- if(dataList.topId==item.topLevelId){
- $('.serviceList .industry').eq(index).find('.industryList ul li:eq(0)').addClass('active');
- }
- })
- }
- if (newHash.indexOf('secondId') > -1) {
- let secondIds = newHash.split('=')
- dataList.secondId = decodeURIComponent(secondIds[1])
- }
- }
- loadDate()
- }
- } else {
- dataList.name = "",
- dataList.topId = "", //行业
- dataList.secondId = "" //类型
- dataList.ordetType=0;
- dataList.orderSort='';
- loadDate();
- }
- }
- function summary() {
- $.ajax({
- method: "get",
- dataType: "json",
- url: globalConfig.context + "/portal/service/jtBusiness/getCategoryList",
- data: {
- module: 1
- },
- success: function (data) {
- console.log(data)
- var theArrs = [];
- if (data.data && data.data.length) {
- let thisdata = data.data;
- dataList.data=thisdata;
- thisdata.map((item) => {
- theArrs.push(`
- <div class="industry" data="${item.topLevelId}"><p>${item.topLevel}</p><div class="industryList"><ul><li data-id=''>不限</li>
- `)
- if (item.children) {
- item.children.map(atem => {
- theArrs.push(`
- <li data-id=${atem.id}>${atem.name}</li>
- `)
- })
- theArrs.push(`
- </ul>
- ${item.children.length>7?'<a href="javascript:void(0);" class="more">更多+</a>':''}
- </div>
- </div>
- `)
- }
- })
- $('.serviceList').html(theArrs.join(''));
- onSelect(thisdata);
- jump()
- };
- }
- })
- }
- 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: 1,
- ordetType:dataList.ordetType,
- orderSort:dataList.orderSort
- },
- 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);
- theArrs.push(`
- <li>
- <a href="${globalConfig.context}/portal/service/serviceDetail?id=${thisdata.id?thisdata.id:''}">
- <div class="img serviceImg">
- ${thisdata.maxImgUrl&&thisdata.maxImgUrl!=null?'<img src="'+globalConfig.avatarHost+'/upload'+thisdata.maxImgUrl+'"/>':''}
- </div>
- <div class="txtIntroduce">
- <div class="txts">
- <h5>${thisdata.name}</h5>
- </div>
- <div class="btnTxt">
- <p><span class="companyImg"></span><span class="companyName">${thisdata.companyName}</span><span class="number">销量 : ${thisdata.dealCount?thisdata.dealCount:0}</span></p>
- </div>
- </div>
- </a>
- </li>
- `);
- };
- };
- $('.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("<div class='list_none'></div>");
- $('.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,
- 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(
- '<li class="pageNumber active"><a href="#" value=' + i + ' >' + i + '</a></li>'
- );
- } else {
- pageArr.push(
- '<li class="pageNumber"><a href="#" value=' + i + ' >' + i + '</a></li>'
- );
- }
- };
- $('.pageNumber').remove();
- $('.pagePre').after(pageArr.join(''));
- }
- });
- }
- //时间转换
- 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 .btn').on('click', function () {
- let val = $(this).siblings().val();
- if (!isNaN(val) && val <= thePageLength && val > 0) {
- thePageNo = val;
- loadDate(thePageNo);
- } else {
- msg('请输入正确页码')
- }
- })
- }
- //已选类型
- function onSelect(data) {
- $('.industryList ul li').on('click', function () {
- $('.industryList ul li').removeClass('active')
- $(this).addClass('active');
- dataList.secondId = $(this).attr('data-id');
- dataList.topId = $(this).parents('.industry').attr('data');
- dataList.name = '';
- let txt = $(this).text();
- $('.onSelect .preFirst').css('display', 'block').html(`
- <span>${txt}</span>
- `)
- loadDate();
- });
- //更多
- $('.industryList .more').click(function () {
- let ulH = $('.industryList ul').height();
- if ($(this).parents('.industry').hasClass('activeH')) {
- $(this).parents('.industry').removeClass('activeH');
- $(this).parents('.industry').height(52);
- $(this).text('更多+')
- $(this).parents('.industry').find('p').css({'height':'52px','line-height':'52px'})
- }else{
- $(this).text('收起')
- $(this).parents('.industry').addClass('activeH');
- $(this).parents('.industry').height(ulH);
- $(this).parents('.industry').find('p').css({'height':ulH+'px','line-height':ulH+'px'})
- }
- })
- }
- //搜索
- function search() {
- $('.hot ul li span').click(function(){
- $(this).parents('ul').find('.sort span').removeClass('active');
- $(this).addClass('active');
- })
- $('.hot ul li:eq(0) span').click(function (e) {
- if((e.target.className).indexOf('up')>-1){
- dataList.ordetType=1;
- dataList.orderSort=1;
- }else{
- dataList.ordetType=1;
- dataList.orderSort=0
- }
- loadDate();
- });
- $('.hot ul li:eq(1) span').click(function (e) {
- if((e.target.className).indexOf('up')>-1){
- dataList.ordetType=2;
- dataList.orderSort=1;
- }else{
- dataList.ordetType=2;
- dataList.orderSort=0
- }
- loadDate();
- });
- $('.searchBtn').click(function () {
- let val = $('.demandSearch').val();
- $('.industry ul li').removeClass('active');
- $('.hot ul li .sort span').removeClass('active')
- $('.preFirst').hide();
- dataList.name = val;
- dataList.topId = '';
- dataList.secondId = '';
- dataList.ordetType=0;
- dataList.orderSort=0;
- 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)
- }
- })
|