";
}
$("#newsUl").html(context);
}
function getNewsByPage(pageNum, strType) {
var url = '/system/news/getNewsByPage/' + strType + '?pageNum='
+ pageNum + '&pageSize=' + pageSize;
$.ajax({
url : url,
type : 'POST',
dataType : 'json',
contentType : 'application/json',
success : function(response) {
console.log(response)
//var totalRecords = response.data.total; //总共有几条数据
totalPage = response.data.pages; //总页数
//var currentPageNum = response.data.pageNum; //当前页
newsList = response.data.list;
setupNewsList(newsList);
setupPage2(pageNum, totalPage);
//$('#totalRecords').text("总共:" + totalRecords + "条数据 " + "第" + currentPageNum + "/" + totalPages + "页");
}
});
};
function setupPage2(pageNum, totalPage) {
var context = "";
for (i = 1; i <= totalPage; i++) {
var strA = "" + i + "";
if (i == pageNum) {
strA = "" + i + "";
}
context = context + strA;
}
context = context + "";
$("#page2").html(context);
}
$(document).on("click", ".page2 a.pnum", function () {
var pNum = $(this).text();
pageNum = pNum;
getNewsByPage(pageNum, strType);
})
$(document).on("click", "#prevBtn", function () {
if (pageNum > 1) {
pageNum--;
getNewsByPage(pageNum, strType);
} else {
// 已经是第一页
,弹出提示框
alert("已经是第一页");
}
});
$(document).on("click", "#nextBtn", function () {
if (pageNum < totalPage) {
pageNum++;
getNewsByPage(pageNum, strType);
} else {
// 已经是最后一页
,弹出提示框
alert("已经是最后一页");
}
});