umming 发布的文章

<meta name="viewport" content="width=device-width,minimum-scale=.3,maximum-scale=.3,initial-scale=.3,user-scalable=no">

<style>
.holder a:hover{color:#af1e25}
.holder a.jp-previous{margin-right:15px}
.holder a.jp-next{margin-left:15px}
.holder a.jp-current,a.jp-current:hover{background:#af1e25!important;border-color:#af1e25!important;color:#fff!important}
.holder a.jp-disabled,a.jp-disabled:hover{color:#bbb}
.holder a.jp-current,.holder a.jp-disabled,a.jp-current:hover,a.jp-disabled:hover{cursor:default}
.holder span{margin:0 5px}
.holder{display:flex;justify-content:center;flex-wrap:wrap;margin-right:10px}
.upage{display:flex;justify-content:center;flex-wrap:wrap;margin-top:40px}
.pgtool{display:flex;justify-content:center;flex-wrap:wrap}
.upage .pg1{line-height:30px;font-size:14px;color:#666}
.upage .pg2{display:none}
.pginp{height:30px;width:60px;border:1px solid #ddd;border-radius:3px;margin:0 5px;outline:0;text-align:center;-webkit-appearance:none}
#pgGo{background:#af1e25;height:30px;padding:0 10px;border:0;border-radius:3px;color:#fff;outline:0;cursor:pointer}
/style>
        function list(data) {
              var nopic = "/ggsydw/nopic.jpg";
              var html = "";
              data.forEach(function (item, index) {
                if (/cnsq.*shtml|shtml.*cnsq/.test(item.url)) {
                  item.url = "";
                }
                html += `<li><div class="img"><img class="lazy" data-original="${item.img ? item.img : nopic}" alt=""></div><div><div class="txt"><h4>${item.title}</h4>
                        <div class="info"><p><strong>机构性质:</strong><span>${item.jgxz}</span></p><p><strong>联系方式:</strong><span>${item.lxfs}</span></p><p><strong>地址:</strong><span>${item.dz}</span></p></div></div><div class="info1"><a href="${item.url ? item.url : "javascript:;"}" target="${item.url ? "_blank" : "_self"}"><img src="/cnsq/xhtml/ztzl/ggsydw/wz.png">官网</a><a href="javascript:;"><img src="/cnsq/xhtml/ztzl/ggsydw/wx.png">微信<span><img src="${item.code}" alt=""></span></a></div></div></li>`;
              });
              if (data.length != 0) {
                $("#data").html(html);
                $(".holder").jPages({
                  containerID: "data",
                  perPage: 12,
                  first: "首页",
                  previous: "上一页",
                  next: "下一页",
                  last: "尾页",
                  callback: function (pages, items) {
                    $("#legend1").html("当前 " + pages.current + " / " + pages.count + " 共" + items.count + "条记录");
                    $("img.lazy").lazyload({ effect: "fadeIn" });
                  },
                });
                $("#pgGo").click(function () {
                  var page = parseInt($(".pginp").val());
                  $(".holder").jPages(page);
                });
                $(".notip").hide();
              } else {
                $("#data").html("");
                $(".holder").html("");
                $(".notip").show();
              }
            }
        
        
        

<input type="text" id="keyword"><button id="so">搜索</button>
<ul id="data"></ul>
<button class="ajaxMore" style="display: none">加载更多</button>
<script type="text/javascript">
let curpage = 1;
let limit=15;
let sum =0;
let _fields='id,tid,title,keywords,description,litpic,body,htmlurl,target,addtime';
let _serUrl ="/GetData/getDataSearch.html";
let _model='article';
let _key='232323';
let _word = '';
let _title = 'title';
$("#so").click(function(){
    _word = $("#keyword").val();
    let  html='';
    $.ajax({
     url:_serUrl,
     dataType:"json",
     async:true,
     data:{model:_model,key:_key,search:_title,word:_word,fields:_fields,limit:limit,page:curpage},
     type:"POST",
     success:function(r){
         console.log(r);
            sum = r.sum;
             if(sum>=1&&sum<=limit){
                 $(".ajaxMore").show().html('没有更多了!');
            }else if(sum>limit){
                  $(".ajaxMore").show();
            }else{
                $(".ajaxMore").show().html('无相关数据');
            }
            $("#data").html('');
                for(const item of r.data){
                  html+=`<li><h4>${item.title}</h4></li>`;
                }
           $("#data").html(html);    
    },
     error:function(){

    }
    })

})
    
$(".ajaxMore").click(function(){
        curpage++;    
        let html = '';
        $.ajax({
             url:_serUrl,
             dataType:"json",
             async:true,
             data:{model:_model,key:_key,search:_title,word:_word,fields:_fields,limit:limit,page:curpage},
             type:"POST",
             success:function(r){
                 if(r.data.length>0){
                     let allpage = r.allpage;
                    if(curpage<=allpage){
                        if(r.data.length<limit){
                           $(".ajaxMore").text('没有更多了!');
                         };
                        for(const item of r.data){
                              html+=`<li><h4>${item.title}</h4></li>`
                         }
                        $("#data").append(html);
                         

                       }
               }

             }
        })


})


</script>