| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 | /* *	@author:liting * 	@update:2018/05/19 *  */import 'css/bootstrap.less';import 'bootstrap/dist/js/bootstrap.js';import 'css/newMenu/public.css';import 'css/newMenu/header.css'import 'css/newMenu/achievementList.css';import 'js/public.js';"use strict";$(function () {    var thePageNo = 1,        thePageLength = 1,        dataList = {},        pageSize = 15;    init();        function init() {        pages();        inpFun();        summary();        onSelect();        jump();        hotSearch();        $('.onSelect .preFirst').css('display', 'none')        $('.onSelect .next').css('display', 'none')    };    //一级界面跳转此页面    function jump() {        let hash = window.location.search;        if (hash) {            if (hash.indexOf('name') > -1 || hash.indexOf('industryCategoryA') > -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('industryCategoryA') > -1) {                            let topIds = item.split('=');                            dataList.topId = decodeURIComponent(topIds[1])                        }                    })                } else {                    if (newHash.indexOf('name') > -1) {                        let names = newHash.split('=')                        dataList.name = decodeURIComponent(names[1])                        $('.demandSearch').val(dataList.name);                    }                    if (newHash.indexOf('industryCategoryA') > -1) {                        let topIds = newHash.split('=')                        dataList.topId = decodeURIComponent(topIds[1])                    }                }                summary(dataList);                loadDate();            }        } else {            dataList.name = "",            dataList.topId = "", //行业            dataList.secondId = "" //类型            summary(dataList)            loadDate();        }    }    //热搜    function hotSearch() {        $('.searchMain ol li').click(function () {            $(this).addClass('active').siblings().removeClass('active');            $('.searchMain ol li').eq(0).addClass('active');            dataList.name = $(this).text().trim();            $('.demandSearch').val(dataList.name);            let index = $(this).index();            $('.productionType ol').html(`<li data-id=''>不限</li>`);            $('.industryList ul li').removeClass('active');            $('.productionType ol li').removeClass('active')            heightFun();            if (index) {                dataList.topId = '';                dataList.secondId = '';                loadDate();            }        })    }    function summary(dataList) {        let hash = window.location.search;        $.ajax({            method: "get",            dataType: "json",            url: globalConfig.context + "/open/industryList",            data: {            },            success: function (data) {                var theArrs = [],proArr=[];                if (data.data && data.data.length) {                    let thisdata = data.data;                    thisdata.unshift({                        id: '',                        name: '不限',                        children: [{                            id: '',                            name: '不限'                        }]                    })                    thisdata.map((item, index) => {                        if (index || hash) {                            if(dataList&&dataList.topId&&dataList.topId>=0&&dataList.topId==item.id){                                $('.onSelect .preFirst').css('display', 'block').html(`                                    <span>${item.name}</span>                                `)                                theArrs.push(`                                     <li class="active" data-id=${item.id}>${item.name}</li>                                `);                                let List = item.children                                List.map(atem=>{                                    proArr.push(`                                         <li data-id=${atem.id}>${atem.name}</li>                                    `)                                })                                $('.productionType ol').html(proArr.join(''));                            }else{                                theArrs.push(`                                    <li data-id=${item.id}>${item.name}</li>                                `)                            }                        } else {                            theArrs.push(`                                <li class="active" data-id=${item.id}>${item.name}</li>                                `)                        }                    })                    $('.industryList ul').html(theArrs);                    $('.industryList ul li').eq(0).className = "active";                    if(proArr.length){                        $('.productionType ol').html(proArr.join(''));                    }else{                        $('.productionType ol').html(`<li data-id=''>不限</li>`);                        $('.productionType ol li ').eq(0).addClass = "active";                    }                    onSelect(thisdata);                    proFun();                    heightFun();                };            }        })    }    function heightFun(){        let proH = $('.productionType ol').height();        $('.productionType p').css({height:proH+'px',lineHeight:proH+'px'})        $('.productionType').css({height:proH+'px',lineHeight:proH+'px'})    }    function loadDate(pageNo) {        $('.loading').show();        $.ajax({            method: "get",            dataType: "json",            url: globalConfig.context + "/open/demandList",            data: {                pageNo: pageNo || 1,                pageSize: 15,                name: dataList.name,                industryCategoryA: dataList.topId, //行业                industryCategoryB: dataList.secondId //类型            },            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/technologyTrading/demandDetail?id=${thisdata.id}&type=${thisdata.dataCategory}">                                <div class="img noImg">									${thisdata.firstPic&&thisdata.firstPic!=null?'<img src="'+globalConfig.avatarHost+'/upload'+thisdata.firstPic+'"/>':''}                                    <span style="display:${news>7?'none':'block'}"></span>                                </div>                                <div class="txtIntroduce">                                    <div class="txts">                                        <h5 title="${thisdata.name}">${thisdata.name}</h5>                    <p><span>${thisdata.demandTypeS?thisdata.demandTypeS:'实用技术'}</span><span style="display:${thisdata.isHot&&thisdata.isHot!='null'?'block':'none'}"  class="hotImg"></span></p>                                    </div>                                    <div class="hr"></div>                                    <div class="btnTxt">                                        <span class="float-left" style="display:${thisdata.industryCategory1!=null?'block':'none'}">${thisdata.industryCategory1}</span>                                    </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 () {            $('.searchMain ol li').removeClass('active');            $('.searchMain ol li').eq(0).addClass('active');            let secondTxt = [],                scondHtml = [];            $(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.id == dataList.topId) {                    secondTxt = item.children                }            })            secondTxt.map(item => {                scondHtml.push(`                <li data-id=${item.id}>${item.name}</li>                `)            })            if (!dataList.topId) {                dataList.topId = '';                dataList.secondId = '';                $('.preFirst').html('不限');                $('.next').css('display', 'none')                scondHtml = ['<li>不限</li>'];            }            $('.productionType ol').html(scondHtml);            heightFun();            let txt = $(this).text();            $('.onSelect .preFirst').css('display', 'block').html(`                <span>${txt}</span>            `)            loadDate();            proFun();        });           }    function proFun(){        $('.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(`                <span>${txt}</span>                `)            loadDate();        })    }    $('.searchBtn').click(function () {        let val = $('.demandSearch').val();        $('.productionType ol').html(`<li data-id=''>不限</li>`);        $('.industryList ul li').removeClass('active');        $('.productionType ol li').removeClass('active')        dataList.name = val;        dataList.topId = '';        dataList.secondId = '';        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)    }})
 |