import 'css/bootstrap.less'; import 'bootstrap/dist/js/bootstrap.js'; import 'css/thinkTank/policyList.css'; import 'css/newMenu/public.css'; import 'css/newMenu/header.css' import 'js/public'; import { provinceList } from 'js/NewDicProvinceList'; let globalConfig={ context:''} $(function () { //数据处理 var pageSize, Province,theKeyword; var thePageNo = 1, thePageLength = 1, dataList={type:''}, pageSize =6; jump(); //一级界面跳转此页面 function jump() { let hash = window.location.search; if (hash) { if (hash.indexOf('name') > -1||hash.indexOf('type')>-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('='); theKeyword = decodeURIComponent(names[1]); dataList.title=theKeyword; $('.demandSearch').val(theKeyword); $('.policyContent .type ol li').eq(0).addClass('active').siblings().removeClass('active') } }) } else { if (newHash.indexOf('name') > -1) { let names = newHash.split('=') theKeyword = decodeURIComponent(names[1]); dataList.title=theKeyword; $('.demandSearch').val(theKeyword); $('.policyContent .type ol li').eq(0).addClass('active').siblings().removeClass('active') } if (newHash.indexOf('type') > -1) { let types = newHash.split('='); dataList.type = decodeURIComponent(types[1]); switch(dataList.type){ case '': $('.type ol li').eq(0).addClass('active').siblings().removeClass('active'); break; case '1': $('.type ol li').eq(1).addClass('active').siblings().removeClass('active'); break; case '0': $('.type ol li').eq(2).addClass('active').siblings().removeClass('active'); break; case '99': $('.type ol li').eq(3).addClass('active').siblings().removeClass('active'); break; case '98': $('.type ol li').eq(4).addClass('active').siblings().removeClass('active'); break; default: $('.type ol li').eq(0).addClass('active').siblings().removeClass('active'); break; } } } loadDate(); } } else { dataList.title=''; $('.type ol li').eq(0).addClass('active'); loadDate(); } } function loadDate(pageNo) { $('.loading').show(); $('.pagination_box').css('display', 'block'); $.ajax({ method: "get", dataType: "json", url: globalConfig.context + "/portal/policyAndNewsList", data: { pageNo: pageNo || 1, pageSize: pageSize, type:dataList.type, title: dataList.title, province: dataList.province?dataList.province:'' }, success: function (data) { var theArr = []; thePageLength = data.data.totalCount ? Math.ceil(data.data.totalCount / pageSize) : 1; if (data.data && data.data.list) { for (let i = 0; i < data.data.list.length; i++) { let thisdata = data.data.list[i], id = thisdata.id, title = thisdata.title, //标题 timeAll =new Date(thisdata.releaseDate), day = timeAll.getDate()>9?timeAll.getDate():'0'+timeAll.getDate(), //号 month =timeAll.getMonth()+1>9?timeAll.getMonth()+1:'0'+(timeAll.getMonth()+1), //年、月 year =timeAll.getFullYear(), summary = (thisdata.summary).length>90?(thisdata.summary).substr(0,90)+'...':thisdata.summary; //简介 if (summary == null) { summary == '暂无内容' } var srctt = globalConfig.context + '/portal/news/newsDetail.html?id=' + id+'&type='+thisdata.type; theArr.push([ '
  • ', '', '
    ', '

    '+month+'-'+day+'

    ', '

    '+year+'

    ', '
    ', '
    ', '

    '+title+'

    ', '

    '+summary+'

    ', '
    ', '
    ', '
  • ', ].join('')); }; }; $('.loading').hide().stop(true,true); $('.newLsit>ul').empty(); $('.newLsit>ul').append(theArr.join('')); if (data.data&&data.data.list.length< 1) { $('.pagination_box').css('display', 'none') }; if (data.data.list.length == 0) { $('.newLsit>ul').html('
    ') }; $('.totalCount').html("共 " + thePageLength + " 页 " + data.data.totalCount + " 条数据"); 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( '
  • ' + i + '
  • ' ); } else { pageArr.push( '
  • ' + i + '
  • ' ); } }; $('.pageNumber').remove(); $('.pagePre').after(pageArr.join('')); }, }); } //点击分页 $('.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); }; }; }); //导航城市添加 var industryListArr = []; provinceList.map(function (item) { industryListArr.push(['
  • ', '', item.name, '', '
  • ', ].join('')); }); if (industryListArr && industryListArr.length) { $('.area ol').append(industryListArr.join('')); $('.area ol li').eq(0).addClass('active'); }; //点击城市时 $('.area ol li').click(function () { dataList.title = $('.demandSearch').val(); var theValue = this.value; $(this).addClass("active").siblings("li").removeClass("active"); dataList.province = theValue; loadDate(); }) //搜索时 $('.searchBtn').click(function (e) { e.preventDefault(); var citys = $('.area ol li.active').attr('value'); var val_inp = $('.demandSearch').val(); console.log(citys) dataList.province = citys; dataList.title = val_inp; loadDate(); }) //点击跟多展开地区 moreFun(); function moreFun(){ $('.more').click(function(){ if($('.area').hasClass('active')){ $('.area').removeClass('active'); $(this).text('更多+'); }else{ $('.area').addClass('active'); $(this).text('更多 -'); } }) } typeFun(); //点击分类 function typeFun(){ $('.type ol li').click(function(){ let val = $(this).attr('value'); dataList.type=val; $(this).addClass('active').siblings().removeClass('active'); dataList.title=''; $('.demandSearch').val(''); loadDate(); }) } })