function newPage() {
var obj_2 = {
obj_box: ".page_1",
total_item: +window.sessionStorage.getItem("total"), //总共数据
type: +window.sessionStorage.getItem("newType"),
per_num: 10, //每页显示数据
current_page: 1, //当前页
change_content: function(per_num, current_page) {
per_num = per_num ? per_num : 10;
current_page = current_page ? current_page : 1;
var type = window.sessionStorage.getItem("newType");
if (type == "undefined") {
var data = {
pageNo: current_page
};
} else {
var data = {
type,
pageNo: current_page
};
}
$.ajax({
url: api + "/open/listNews",
data,
type: "GET",
dataType: "json",
success: function(data) {
if (data.error && data.error.length) {
alert("数据加载失败,请刷新页面");
} else {
var html = "";
if (data.data.list.length) {
for (var i = 0; i < data.data.list.length; i++) {
var newList = data.data.list[i];
var content = newList.content.replace(/<.*?>/gi, "");
html +=
"
" +
newList.title +
"
" +
newList.releaseTimeConvert +
"" +
content +
"
";
}
window.sessionStorage.setItem("total", data.data.totalCount);
} else {
html =
"暂无新闻动态
";
$(".page_ctrl").css({
display: "none"
});
}
$(".newslist").html(html);
}
}
});
}
};
//调用分页
page_ctrl(obj_2);
}
function newFn() {
// var api = window.globalConfig.apiUrl ? window.globalConfig.apiUrl : "http://kede.jishutao.com"
$(".secondary-menu").on("click", "a", function() {
$(".secondary-menu ul li").removeClass("active");
$(this)
.parent()
.addClass("active");
if ($(this).html() == "全部") {
window.sessionStorage.setItem("newType", undefined);
} else if ($(this).html() == "科德新闻") {
window.sessionStorage.setItem("newType", 0);
} else if ($(this).html() == "行业资讯") {
window.sessionStorage.setItem("newType", 1);
}
var type = window.sessionStorage.getItem("newType");
if(type != "undefined") {
var data = {
type,
releaseStatus: 1
}
}else {
var data = {
releaseStatus: 1
}
}
$.ajax({
method: "get",
url: api + "/open/listNews",
data,
success: function(data) {
if (data.error && data.error.length) {
alert("数据加载失败,请刷新页面");
} else {
var html = "";
if(data.data.list.length) {
for (var i = 0; i < data.data.list.length; i++) {
var newList = data.data.list[i];
var content = newList.content.replace(/<.*?>/gi, "");
html +=
"" +
newList.title +
"
" +
newList.releaseTimeConvert +
"" +
content +
"
";
}
window.sessionStorage.setItem("total", data.data.totalCount);
newPage()
}else {
html =
"暂无新闻动态
";
$(".page_ctrl").css({
display: "none"
});
}
$(".newslist").html(html);
}
}
});
});
$(".secondary-menu > div > ul > li > a")
.eq(0)
.click();
}
newFn()