滚动条到底部触发的事件

<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;
    }



}

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值