-- 截取数据
function JpbyPopularizeCtrl:GetCurPageData(curPage,rows,listLen)
local len = listLen;
local pageList = { }
local totalPage = math.ceil(listLen / rows);
if curPage <= 0 then
curPage = 1;
end
if curPage > totalPage then
curPage = totalPage;
end
local fromIndex = (curPage - 1) * rows;-- 从0开始
local toIndex;
if fromIndex + rows >= len then -- 需要截取的长度 >= len
toIndex = len
else
toIndex = fromIndex + rows
end
if fromIndex <= len then
pageList.fromIndex = fromIndex
pageList.toIndex = toIndex
else
print("超出指定范围");
return
end
return pageList;
end