帝国cms7.5点击加载更多,滚动加载更多 优化版

滚动加载更多

  1. <ul id="divcon1">
  2. [e:loop={"select * from phome_ecms_news order by newstime desc limit 5",6,24,0}]
  3. <li>
  4. <div class="so-header"><a href="<?=$bqsr[‘titleurl’]?>"><?=$bqr[‘title’]?></a></div>
  5. <div class="so-body">
  6. <?php
  7. if($bqr[‘titlepic’]){
  8. ?>
  9. <div class="so-pic"><a href="<?=$bqsr[‘titleurl’]?>" target="_blank"><img src="/e/extend/title/img.php?path=<?=$public_r[‘add_ossurl’]?><?=$bqr[‘titlepic’]?>" alt="<?=$bqr[‘title’]?>" width="110" height="90"></a></div>
  10. <?
  11. }
  12. ?>
  13. <div class="so-cont"><?=esub(str_replace(egetzy(‘rn’),”,$bqr[smalltext]),238);?>…</div>
  14. </div>
  15. <div class="so-footer"><span class="pull-left"><?=date("Y-m-d",$bqr[newstime])?></span><span class="pull-right">访问量:<?=$bqr[‘onclick’]?></span></div>
  16. </li>
  17. [/e:loop]
  18. </ul>
  19. <div id="divcon2"><div id="divload">点击加载更多</div></div>

复制代码

JavaScript

  1. <script language="javascript" type="text/javascript">
  2. $(document).ready(function(){
  3.     var page = 1;//这个不是真正的页数,而是位移量
  4.     var nextpage = 1;
  5.     var wan=true;
  6.     var totalheight = 0;   
  7.     function loadData(){   
  8.     totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());  
  9.      if ($(document).height() <= totalheight && wan==true) {  // 说明滚动条已达底部  
  10.         var cid = 0;
  11.         page = nextpage;
  12.         $.ajax({
  13.             url : ‘/ajax/getmore.php’,
  14.             type:’get’,
  15.             data:{"classid":cid,’next’:page},
  16.             dataType : ‘html’,
  17.             beforeSend:function(){
  18.                 $(‘#divload’).html(‘<div id="pullUp"><p class="pullUpLabela"><img src="/Style/css/img/wait1.gif" width="20"><span>正在载入</span></p></div>’);
  19.                 $(‘#divcon2’).show();
  20.                 wan=false;
  21.             },
  22.             success : function(str){
  23.                 if(str!=""){
  24.                     $(‘#divcon1’).show();
  25.                     $(‘#divcon2’).hide();
  26.                     $(‘#divcon1’).append(str);
  27.                     nextpage++;
  28.                     wan=true;
  29.                 }else{
  30.                     $(‘#divload’).html(‘<div id="pullUp"> <span class="pullUpLabel">加载完毕!</span></div>’);
  31.                     $(‘#divcon2’).show();
  32.                 }
  33.             }
  34.         });
  35.     }}
  36.       $(window).scroll( function() {   
  37.             loadData();  
  38.         });   
  39. })
  40. </script>

复制代码

php

  1. <?php
  2. $ye=strFilter($_GET["next"]);
  3. $clasid=strFilter($_GET["classid"]);
  4. if($clasid==1){$clasid="2,3,4,5,6";}
  5. if($clasid==7){$clasid="8,9,10,11,12,13";}
  6. if($clasid==14){$clasid="15,16,17";}
  7. if($clasid==18){$clasid="19,20,21,22";}
  8. if($clasid==23){$clasid="24,25,26,27,38";}
  9. if($clasid==28){$clasid="29,30,31,32";}
  10. if($clasid==33){$clasid="34,35,36,37";}
  11. if($clasid==0){
  12.         $aabbccdd = base64_encode("select * from phome_ecms_news order by newstime limit");
  13. }else{
  14.         $aabbccdd = base64_encode("select * from phome_ecms_news where classid in ($clasid) order by newstime desc limit");
  15. }
  16. function strFilter($str){
  17.                 $str = str_replace(‘`’, ”, $str);
  18.     $str = str_replace(‘`’, ”, $str);
  19.     $str = str_replace(‘·’, ”, $str);
  20.     $str = str_replace(‘~’, ”, $str);
  21.     $str = str_replace(‘!’, ”, $str);
  22.     $str = str_replace(‘!’, ”, $str);
  23.     $str = str_replace(‘@’, ”, $str);
  24.     $str = str_replace(‘#’, ”, $str);
  25.     $str = str_replace(‘[color=#333333][font=-apple-system, BlinkMacSystemFont, &quot][size=16px]点击加载更多,php同上[/size][/font][/color]
  26. [code]var is_have_con = "Y";
  27. $(function() {
  28.         var pagenum = 1;
  29.         $(‘.moreget’).on(‘click’, function() {
  30.                 if (is_have_con == "Y") {
  31.                         $.ajax({
  32.                                 url: ‘/ajax/getmore.php’,
  33.                                 type: ‘get’,
  34.                                 data: {
  35.                                         "next": pagenum
  36.                                 },
  37.                                 dataType: ‘html’,
  38.                                 beforeSend: function() {
  39.                                         $(".moreget").text(‘玩命加载中…’)
  40.                                 },
  41.                                 success: function(data) {
  42.                                         if (5 >= pagenum) {
  43.                                                 $(".morelist").append(data);
  44.                                                 $(".moreget").text(‘点击加载更多’);
  45.                                                 pagenum++
  46.                                         } else {
  47.                                                 $(".moreget").text(‘已经到底了!’);
  48.                                                 is_have_con = "N";
  49.                                                 return false
  50.                                         }
  51.                                 }
  52.                         })
  53.                 }
  54.         })
  55. });

复制代码



, ”, $str);
    $str = str_replace(‘¥’, ”, $str);
    $str = str_replace(‘%’, ”, $str);
    $str = str_replace(‘^’, ”, $str);
    $str = str_replace(‘……’, ”, $str);
    $str = str_replace(‘&’, ”, $str);
    $str = str_replace(‘*’, ”, $str);
    $str = str_replace(‘(‘, ”, $str);
    $str = str_replace(‘)’, ”, $str);
    $str = str_replace(‘(’, ”, $str);
    $str = str_replace(‘)’, ”, $str);
    $str = str_replace(‘-‘, ”, $str);
    $str = str_replace(‘_’, ”, $str);
    $str = str_replace(‘——’, ”, $str);
    $str = str_replace(‘+’, ”, $str);
    $str = str_replace(‘=’, ”, $str);
    $str = str_replace(‘|’, ”, $str);
    $str = str_replace(”, ”, $str);
    $str = str_replace(‘[‘, ”, $str);
    $str = str_replace(‘]’, ”, $str);
    $str = str_replace(‘【’, ”, $str);
    $str = str_replace(‘】’, ”, $str);
    $str = str_replace(‘{‘, ”, $str);
    $str = str_replace(‘}’, ”, $str);
    $str = str_replace(‘;’, ”, $str);
    $str = str_replace(‘;’, ”, $str);
    $str = str_replace(‘:’, ”, $str);
    $str = str_replace(‘:’, ”, $str);
    $str = str_replace(‘\”, ”, $str);
    $str = str_replace(‘"’, ”, $str);
    $str = str_replace(‘“’, ”, $str);
    $str = str_replace(‘”’, ”, $str);
    $str = str_replace(‘,’, ”, $str);
    $str = str_replace(‘,’, ”, $str);
    $str = str_replace(‘<‘, ”, $str);
    $str = str_replace(‘>’, ”, $str);
    $str = str_replace(‘《’, ”, $str);
    $str = str_replace(‘》’, ”, $str);
    $str = str_replace(‘.’, ”, $str);
    $str = str_replace(‘。’, ”, $str);
    $str = str_replace(‘/’, ”, $str);
    $str = str_replace(‘、’, ”, $str);
    $str = str_replace(‘?’, ”, $str);
    $str = str_replace(‘?’, ”, $str);
    return trim($str);
}
require("../e/class/connect.php");
if(!defined(‘InEmpireCMS’)){exit();}
require("../e/class/db_sql.php");
require("../e/class/q_functions.php");
$link=db_connect();
$empire=new mysqlquery();
$yema = $ye*10;
$query = $empire->query(base64_decode($aabbccdd)." $yema,10") or die("SQL语句执行失败2");
while($rs=$empire->fetch($query)){
$src  = $rs[id];
$xwclassid=$rs[‘classid’];
$xwtitle=$rs[‘title’];
$xwtitleurl=$rs[‘titleurl’];
$xwtitlepic=$rs[‘titlepic’];
$smalltext=$rs[‘smalltext’];
$newstime=$rs[‘newstime’];
$onclick=$rs[‘onclick’];
$queryss = $empire->query("select * from phome_enewsclass where classid=’$xwclassid’") or die("SQL语句执行失败3");
while($rstt=$empire->fetch($queryss)){$xwclassname=$rstt[classname];$xwclasspath=$rstt[classpath];}
?>
<li>
<div class="so-header"><a href="<?=$xwtitleurl?>"><?=$xwtitle?></a></div>
<div class="so-body">
<?php
if($xwtitlepic){
?>
<div class="so-pic"><a href="<?=$xwtitleurl?>" target="_blank"><img src="/e/extend/title/img.php?path=<?=$public_r[‘add_ossurl’]?><?=$xwtitlepic?>" alt="<?=$xwtitle?>" width="110" height="90"></a></div>
<?
}
?>
<div class="so-cont"><?=esub(str_replace(egetzy(‘rn’),”,$smalltext),238);?>…</div>
</div>
<div class="so-footer"><span class="pull-left"><?=date(‘Y-m-d’,$newstime)?></span><span class="pull-right">访问量:<?=$onclick?></span></div>
</li>
<?php } ?>[/code]点击加载更多,php同上

  1. var is_have_con = "Y";
  2. $(function() {
  3.         var pagenum = 1;
  4.         $(‘.moreget’).on(‘click’, function() {
  5.                 if (is_have_con == "Y") {
  6.                         $.ajax({
  7.                                 url: ‘/ajax/getmore.php’,
  8.                                 type: ‘get’,
  9.                                 data: {
  10.                                         "next": pagenum
  11.                                 },
  12.                                 dataType: ‘html’,
  13.                                 beforeSend: function() {
  14.                                         $(".moreget").text(‘玩命加载中…’)
  15.                                 },
  16.                                 success: function(data) {
  17.                                         if (5 &gt;= pagenum) {
  18.                                                 $(".morelist").append(data);
  19.                                                 $(".moreget").text(‘点击加载更多’);
  20.                                                 pagenum++
  21.                                         } else {
  22.                                                 $(".moreget").text(‘已经到底了!’);
  23.                                                 is_have_con = "N";
  24.                                                 return false
  25.                                         }
  26.                                 }
  27.                         })
  28.                 }
  29.         })
  30. });

复制代码


温馨提示:本文最后更新于2022-09-12 11:37:14若文章内容或图片失效,请在下方留言或联系丁塔克
本站资源均为作者提供和网友推荐收集整理而来,仅供学习和研究使用,请在下载后24小时内删除,谢谢合作!
© 版权声明
THE END
点赞9 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容

热门圈子总有聊不完的话题
星球求救信号帮助是一种美德