<script>
//调用
ScrollBottom(function(){
shuju()
})
function shuju(){
$.ajax({
type: "GET",
url: "{S_URL}/index.php?action-ajax-type-zhanlan-catid-"+eq_catid+'-leibei-en-page-'+page,
dataType: "json",
processData : false, // 使数据不做处理
contentType : false, // 不要设置Content-Type请求头
error: function (data) {
alert("服务器繁忙, 请联系管理员!");
},
success: function (data) {
if (data.status == 200) {
$('.zhuijia').append(data.html);
// 引入 瀑布流插件方法
pubu();
page++;
} else {
alert('没有数据了!');
}
}
});
}
//滚动条到底部触发的事件
function ScrollBottom(x){
function __getScrollTop(){
var scrollTop = 0, bodyScrollTop = 0, documentScrollTop = 0;
if(document.body){bodyScrollTop = document.body.scrollTop;}
if(document.documentElement){documentScrollTop = document.documentElement.scrollTop;}
scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;
return scrollTop;
}
function __getWindowHeight(){
var windowHeight = 0;
if(document.compatMode == "CSS1Compat"){
windowHeight = document.documentElement.clientHeight;
}else{
windowHeight = document.body.clientHeight;
}
return windowHeight;
}
function __getScrollHeight(){
var scrollHeight = 0, bodyScrollHeight = 0, documentScrollHeight = 0;
if(document.body){bodyScrollHeight = document.body.scrollHeight;}
if(document.documentElement){documentScrollHeight = document.documentElement.scrollHeight;}
scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight;
return scrollHeight;
}
window.onscroll = function(){
if(__getScrollTop() + __getWindowHeight() == __getScrollHeight())
doFun(x)
};
}
function doFun(x){setTimeout(x,0)}
</script>
//$perpage = empty($_SGET['perpage']) ? 0 : intval($_SGET['perpage']);
//if(!$perpage)
$perpage = 12;
$frist = ($_SGET['page']-1)*$perpage;
if($frist<0)$frist=0;
if(empty($frist))$frist = 0;
$catid = empty($_SGET['catid'])?0:intval($_SGET['catid']);
$type = $_SGET['type'];
$leibei= $_SGET['leibei'];
$wherelist = '';
if($leibei == ''){
$leibei = 'news';
$view = 'viewnews';
}else{
$leibei = $leibei;
$view = 'enviewnews';
}
if($catid != 0){
// $wherelist .= "type = 'news' and catid IN (26,29,38) ";
$wherelist .= "type = '".$leibei."' and catid = $catid ";
}
if($type=='zhanlan'){
$sql ="select count(*) from ".tname('spaceitems')." where ".$wherelist;
$query = $_SGLOBAL['db']->query($sql);
$count = $_SGLOBAL['db']->result($query,0); //查询所有记录的总条数
$num = $count-$frist;
if($frist <= $count){
$sql ="select * from ".tname('spaceitems')." where ".$wherelist." order by dateline desc limit ".$frist.",$perpage";
$query = $_SGLOBAL['db']->query($sql);
$html = '';
while ($item = $_SGLOBAL['db']->fetch_array($query)) {
$tpid = $item['itemid'];
if($tpid){
$picid = $item['picid'];
$sqlpic = "SELECT `thumbpath` FROM `bwg_attachments` WHERE `aid`=$picid";
$querypic = $_SGLOBAL['db']->query($sqlpic);
$picarr = $_SGLOBAL['db']->fetch_array($querypic);
$quezy = $_SGLOBAL['db']->query('SELECT * FROM '.tname('spacenews').' WHERE itemid=\''.$tpid.'\'');
$newzy = $_SGLOBAL['db']->fetch_array($quezy);
}
$item['tu'] = '/attachments/'.$picarr['thumbpath'];
if($picarr['thumbpath'] == ''){
$item['tu'] = '/image/logo.png';
}
$item['newzy'] = $newzy;
$data[] = $item;
}
foreach ($data as $k=>$item){
$html .= '<div class="item" data-order="'.$num.'">
<a href="/index.php?action-'.$view.'-itemid-'.$item['itemid'].'">
<div class="zhanlan-img"><img src="'.$item['tu'].'" alt=""></div>
<div class="zhanlan-text">
<h4>'.$item['subject'].'</h4>
<p class="time">'.date("Y-m-d",$item['dateline']).'</p>
</div>
</a>
</div>';
$num--;
}
echo json_encode(array('status'=>200,'data'=>$data,'count'=>$count,'frist'=>$frist,'num'=>$num,'html'=>$html,'msg'=>'查询成功!'));
exit;
}else{
echo json_encode(array('status'=>300,'data'=>'没有数据!','count'=>$count,'frist'=>$frist,'msg'=>'没有数据!'));
exit;
}
}