路过晴天
路过晴天
  • 发布:2017-07-30 11:59
  • 更新:2017-11-07 15:01
  • 阅读:1892

上拉刷新问题:通过查询控件输入不同查询条件查询不同数量数据后加载到上拉刷新容器中,如果数据不满足一页提示无更多数据后,再换查询条件查出 多页数据,最下面依旧显示无更多数据,无法上拉加载

分类:MUI

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<link href="css/mui.min.css" rel="stylesheet" />
<script type="text/javascript" src="js/mui.min.js"></script>
<script src="js/mui.js"></script>
<script type="text/javascript" src="myjs/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="myjs/restapi.js" ></script>
<script type="text/javascript">
mui.init({
pullRefresh: {
container: '#pullrefresh',
up: {
contentrefresh: '正在加载...',
callback: pullupRefresh
}
}
});

        var counts = 0;  
        var totalPage = 0;  
        var count = 10;  
        var page=0;  
        /*   
         * 上拉加载具体业务实现  
         */  
        function pullupRefresh() {  
                var name=$("#searchInput").val();  
                setTimeout(function() {  
                var code = -1;  
                page++;  
                $.ajax({  
                    type: "get",  
                    async: true,  
                    url: "http://localhost:8866/timeSheet/queryProjects?page=" + page + "&count=" + count + "&name=" + name + "&code=" + code,  
                    dataType: "json",  
                    success: function(data) {  
                        var datalist = data.data.list;  
                        var table = document.body.querySelector('.mui-table-view');  
                        mui.each(datalist, function(index, val) {  
                            //console.log(val.Id);  
                            var li = document.createElement('li');  
                            li.className = 'mui-table-view-cell';  
                            li.innerHTML = '<a class="mui-navigate-right" onclick="getvalue(\'' + val.Id + '\',\'' + val.Name + '\',\''+val.Ptype+'\')">' +  
                                val.Name +  
                                '<p>' +  
                                val.Ptype +  
                                '<span class="mui-badge mui-badge-success" style="float:right">' +  
                                val.UName +  
                                '</span>'  
                            '</p>' +  
                            +'</a>';  
                            //下拉刷新,新纪录插到最前面;  
                            table.appendChild(li);  
                        });  
                        console.log("datalist:"+datalist.length);  
                        console.log("name:"+name);  
                        if(datalist.length==10 || datalist.length>0){  
                            totalPage++;  
                            mui('#pullrefresh').pullRefresh()  
                            .endPullupToRefresh((++counts > totalPage)); //参数为true代表没有更多数据了。  
                        }else{  
                            mui('#pullrefresh').pullRefresh()  
                            .endPullupToRefresh((++counts > totalPage)); //参数为true代表没有更多数据了。  
                        }  

                    }  

                });  

            }, 1500);  
        }  

//查询  
  var fi="";  
  function search(){  
    var name=$("#searchInput").val();  
    if(fi==name){  
        page=0;  
        pullupRefresh();  
    }else{  
        page=0;  
        fi==name;  
        clears();  

        mui('#pullrefresh').pullRefresh().pullupLoading();//重新加载  

// mui('#pullrefresh').pullRefresh().refresh(true);//

        //mui('#pullrefresh').pullRefresh().endPullupToRefresh(); //数据加载完,  

    }  

  }       
        //初次进页面刷新  
        if(mui.os.plus) {  
            mui.plusReady(function() {  
                setTimeout(function() {  
                    mui('#pullrefresh')  
                        .pullRefresh()  
                        .pullupLoading();  
                }, 1000);  
            });  
        } else {  
            mui.ready(function() {  
                mui('#pullrefresh')  
                    .pullRefresh()  
                    .pullupLoading();  
            });  
        }  
        //返回到工时页面  
        function getvalue(ids, name,type) {  
            var pwc=plus.webview.currentWebview();  
            var times=pwc.timesheet;  
            var uid=pwc.uid;  
            if(times=="timesheet"){  
                mui.openWindow({  
                url: "XiangMuLeiGongShiTianBao.html",  
                id: 'XiangMuLeiGongShiTianBao',  
                extras: {  
                    ids: ids,  
                    name: name,  
                    uid:uid,  
                    type:type  
                }  
            });  
            }else if(times=="nottimesheet"){  
                mui.openWindow({  
                url: "FeiXiangMuLeiGongShiTianBao.html",  
                id: 'FeiXiangMuLeiGongShiTianBao',  
                extras: {  
                    ids: ids,  
                    name: name,  
                    uid:uid,  
                    type:type  
                }  
            });  
            }  

        }  

    //清除ul数据  
  function clears(){  
    var s=document.getElementById("removeli");  
    var len=s.childNodes.length;  
    for(var i=0;i<len;i++){    
            s.removeChild(s.childNodes[0]);  
    }  

  }  

    </script>  
</head>  

<body>  
    <header class="mui-bar mui-bar-nav">  
        <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>  
        <h1 class="mui-title">项目列表</h1>  
    </header>  
    <div class="mui-content" style="background-color:#fff">  

        <!--下拉刷新容器-->  
        <div id="pullrefresh" class="mui-content mui-scroll-wrapper">  

            <div class="mui-scroll">  
                <!--数据列表-->  
                <div >  
                    <div class="mui-content">  
                        <div class="mui-input-row mui-search"  class="mui-col-sm-8" >  
                                    <input type="search" id="searchInput"  class="mui-input-clear" placeholder="">  
                                </div>  
                                <div >  
                                    <button onclick="search()">查询</button>  
                                </div>  
                    </div>  
                    <ul class="mui-table-view" id="removeli">  
                    </ul>  
                </div>  

            </div>  
        </div>  

    </div>  
</body>  

</html>

2017-07-30 11:59 负责人:无 分享
已邀请:
x***@163.com

x***@163.com

遇到和你差不多的问题,您解决了么?

阿星蜀黍

阿星蜀黍 - 嘛钱不钱的,乐呵乐呵得了

关注

q***@163.com

q***@163.com

求问这个问题解决了吗?

q***@163.com

q***@163.com

你这个是单页面的上拉加载,最后是不是mui('#pullrefresh').pullRefresh().disablePullupToRefresh();了,如果是这样,就在你访问url成功后,先mui('#pullrefresh').pullRefresh().enablePullupToRefresh();处理一下,我的是多页面的上拉加载, //循环初始化所有下拉刷新,上拉加载。
$.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function(index, pullRefreshEl) {
$(pullRefreshEl).pullToRefresh({
up: {
auto: true,
contentnomore: '',
contentinit: '',
contentrefresh: '正在加载...',
contentdown: '上拉加载更多',
callback: function() {
console.log(index);
var self = this;
setTimeout(function() {
var result = true;
if(index == 0) } else if(index == 1) {

                                } else if(index == 2) {  

                                }  
                            }, 2000);  
                        }  
                    }  
                });  
            });  

self.endPullUpToRefresh(true);以后无法上拉加载了

该问题目前已经被锁定, 无法添加新回复