<script type="text/javascript">
var loadConfig = {
url_api:'/plus/list.php',
typeid:{dede:field name="typeid"/},
page:2,
pagesize:8, //这个就是滑动一次添加几条信息的参数设置
loading : 0,
}
function loadMoreApply(){
if(loadConfig.loading == 0){
var typeid = loadConfig.typeid;
var page = loadConfig.page;
var pagesize = loadConfig.pagesize;
var url = loadConfig.url_api,data={ajax:'pullload',typeid:typeid,page:page,pagesize:pagesize};
var sTop = document.body.scrollTop || document.documentElement.scrollTop, dHeight = $(document).height(), cHeight = document.documentElement.clientHeight;
console.log(dHeight);
if (sTop + cHeight >= dHeight - cHeight) {
loadConfig.loading = 1;
function ajax(url, data) {
$.ajax({url: url,data: data,async: false,type: 'GET',dataType: 'json',success: function(data) {
addContent(data);
}});
}
ajax(url,data);
}
}
}
function addContent (rs){
if(rs.statu== 1){
var data = rs.list;
var total = rs.total;
var arr=[];
var length = data.length;
for(var i=0;i<length;i++){
arr.push('<li>');
arr.push('<div class="viewimg">');
arr.push('<div class="hotimgzz"></div>');
arr.push('<a href="'+data[i].waparcurl+'" class="zzsz"></a>');
arr.push('<a href="'+data[i].waparcurl+'" target="_blank" title="'+data[i].title+'">');
arr.push('<img src="'+data[i].picname+'" alt="'+data[i].title+'" width="250" height="165"/>');
arr.push('</a>');
arr.push('<div class="standpoint"><a href="'+data[i].typeurl+'">'+data[i].typelink+'</a></div>');
arr.push('</div>');
arr.push('<h3><a href="'+data[i].waparcurl+'" target="_blank" title="'+data[i].title+'">'+data[i].title+'</a></h3>');
arr.push('<p>'+data[i].description+'...</p>');
arr.push('<span>'+data[i].stime+'</span>');
arr.push('</li>');
}
$('.yz_xinwen').append(arr.join(''));
loadConfig.load_num = rs.load_num;
if((parseInt(total/8)+1) == loadConfig.page){
$('.yz_jiazai').html('<div style="width:100%; float:left; text-align:center; padding: 10px 0px; color:#fff; background:#00aa98; font-size: 16px; cursor:pointer;">加载完成</div>');
}else{
$('.yz_jiazai').html('<div style="width:100%; float:left; text-align:center; padding: 10px 0px; color:#fff; background:#00aa98; font-size: 16px; cursor:pointer;">点击加载'+loadConfig.page+'</div>');
}
if(total<loadConfig.page*loadConfig.pagesize || loadConfig.page > loadConfig.load_num){
window.removeEventListener('click',loadMoreApply,false);
}
loadConfig.page++;
loadConfig.loading = 0;
}
}
function pullLoad(){
window.addEventListener('click', loadMoreApply, false);
}
pullLoad();
</script>
|