import '../../css/bootstrap.less';
import 'bootstrap/dist/js/bootstrap.js';
import '../../css/newMenu/public.css';
import '../../css/main_banner.css';
import '../../js/public.js';
import '../../js/main_banner.js';
import '../../css/thinkTank/policyList.css';
import {
provinceList
} from '../../js/NewDicProvinceList';
$(function () {
//数据处理
var theKeyword, pageSize, Province;
var thePageNo = 1,
thePageLength = 1,
pageSize = 6;
theKeyword = localStorage.getItem("indexKeyWord");
localStorage.removeItem("indexKeyWord");
jump();
//一级界面跳转此页面
function jump() {
let hash = window.location.search;
if (hash) {
if (hash.indexOf('name') > -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 = names[1]
}
})
} else {
if (newHash.indexOf('name') > -1) {
let names = newHash.split('=')
theKeyword = names[1]
}
}
loadDate()
}
} else {
theKeyword = "",
loadDate();
}
}
function loadDate(pageNo) {
$('.loading').show();
$.ajax({
method: "get",
dataType: "json",
url: globalConfig.context + "/portal/news/list",
data: {
pageNo: pageNo || 1,
pageSize: pageSize,
keyword: theKeyword,
provinceId: Province != 999 ? Province : undefined
},
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];
var id = thisdata.id;
var title = thisdata.title; //标题
var time = thisdata.createTimeFormattedDate; //日期
var day = time.substr(8, 2); //号
var month = time.substr(0, 7) //年、月
var summary = thisdata.summary; //简介
if (summary == null) {
summary == '暂无内容'
};
var sol = '';
var srctt = globalConfig.context + '/portal/news/newsDetail.html?id=' + id;
theArr.push([
'
',
'',
'
' + day + '
',
'
',
'
',
'',
'
',
'
' + summary + '
',
'
MORE+',
'
',
'',
].join(''));
};
};
$('.loading').hide().stop(true,true);
$('.policy ul').empty();
$('.policy ul').append(theArr.join(''));
if (data.data.list.length === 0) {
$('.pagination_box').css('display', 'none')
};
if (data.data.list.length === 0) {
$('.policy 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);
};
};
});
//链接详情
$('.invest_imglist ul').on('click', 'li', function () {
var theId = $(this).attr('value');
window.open(globalConfig.context + '/portal/thinkTank/thinkerDetail.html?id=' + theId);
})
//导航城市添加
var industryListArr = [],
industryChildrenArr = [];
industryListArr.push(['',
'',
'不限',
'',
'',
].join(''));
provinceList.map(function (item) {
industryListArr.push(['',
'',
item.name,
'',
'',
].join(''));
});
if (industryListArr && industryListArr.length) {
$('#industryList').append(industryListArr.join(''));
};
//点击城市时
$('#industryList li').click(function () {
window.location.hash='';
theKeyword = $('#search_on input').val();
var theValue = this.value;
$(this).siblings("li").removeClass("active");
$(this).addClass("active");
Province = theValue;
loadDate();
})
//搜索时
$('#btn_search').click(function (e) {
e.preventDefault();
var citys = $('#industryList .active').attr('value');
var val_inp = $('#search_on input').val();
Province = citys;
theKeyword = val_inp;
loadDate();
})
})