html代码
class="name">{$vo.name}
class="num">{$vo.vote_num|num_format_w=###}人气
加载中...
js代码
//下拉加载更多
$(function () {
var pageIndex = 1;
//获取滚动条当前的位置
function getScrollTop() {
var scrollTop = 0;
if (document.documentElement && document.documentElement.scrollTop) {
scrollTop = document.documentElement.scrollTop;
} else if (document.body) {
scrollTop = document.body.scrollTop;
}
return scrollTop;
}
//获取当前可视范围的高度
function getClientHeight() {
var clientHeight = 0;
if (document.body.clientHeight && document.documentElement.clientHeight) {
clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight);
} else {
clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight);
}
return clientHeight;
}
//获取文档完整的高度
function getScrollHeight() {
return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
}
window.onscroll = function () {
if (getScrollTop() + getClientHeight() == getScrollHeight()) {
$("#jiazaizhong").removeClass("none");
pageIndex++;
$.ajax({
url: url + "index.php/index/index",
type: "post",
dataType: "json",
async: false,
data: {
vote_item_id: "1",
page: pageIndex,
api: "1"
},
success: function (res) {
var cont = (res.data.total_record) / (res.data.page_size);
let obj2 = res.data;
if (parseInt(cont) == cont) {
var cont2 = cont
} else {
var cont2 = parseInt(cont) + 1
}
if (pageIndex <= cont2) {
for (var i = 0; i < res.data.page_size; i++) {
$(".player_box").append(
'n' +
'n' +
' + obj2[i].uid + "/vote_item_id/" + obj2[i].vote_item_id + ".html" + '">n' +
'n' +
' + obj2[i].pic_arr[0] + '">n' +
'n' +
'' + obj2[i].user_num + 'n' +
'n' +
'n' +
'n' +
'' + obj2[i].name + 'n' +
'' + obj2[i].vote_num + '人气n' +
'n' +
'n' +
'n'
);
}
} else {
$("#jiazaizhong").text("到底了...")
}
},
error: function () {
console.log("请求失败")
}
})
}
};
});