123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- 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([
- '<li>',
- '<a href="'+srctt+'">',
- '<div class="yearTime">',
- '<p>'+month+'-'+day+'</p>',
- '<p>'+year+'</p>',
- '</div>',
- '<div class="txt">',
- '<h4>'+title+'</h4>',
- '<p>'+summary+'</p>',
- '</div>',
- '</a>',
- '</li>',
- ].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('<div class="imgbg"></div>')
- };
- $('.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(
- '<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(''));
- },
- });
- }
- //点击分页
- $('.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(['<li value="' + item.id + '">',
- '<span>',
- item.name,
- '</span>',
- '</li>',
- ].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();
- })
- }
- })
|