1***@qq.com
1***@qq.com
  • 发布:2018-04-17 17:06
  • 更新:2018-04-17 17:06
  • 阅读:2199

mui.pullToRefresh插件 问题

分类:MUI

多选项卡,上拉加载时,若第一个类型只有一页数据,第二个类型有多页数据,这是第一个tab内容是不能上拉(正常),此时上拉第二个选项时,加载第二个选项内容,此时回到去第一个类型去上拉,此时还能上拉,正确情况应该是不能上拉的,请问是什么原因?
代码如下:
<div class="mui-content">
<div id="slider" class="mui-slider mui-fullscreen">
<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
<div class="mui-scroll">
<a class="mui-control-item mui-active" href="#item1mobile">
告警信息
</a>
<a class="mui-control-item" href="#item2mobile">
控制信息
</a>
</div>
</div>
<div class="mui-slider-group">
<div id="item1mobile" class="mui-slider-item mui-control-content mui-active">
<div id="scroll1" class="mui-scroll-wrapper">
<div class="mui-scroll" id="sss">
<ul class="mui-table-view" curPage="1" id='warn_list' >
</ul>
</div>
</div>
</div>
<div id="item2mobile" class="mui-slider-item mui-control-content">
<div class="mui-scroll-wrapper">
<div class="mui-scroll">
<ul class="mui-table-view" curPage="1" id='active_list'>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>

js如下:
$.ready(function() {

    //循环初始化所有下拉刷新,上拉加载。  
    $.each(document.querySelectorAll('.mui-slider-group .mui-scroll'),   
    function(index, pullRefreshEl) {  
        $(pullRefreshEl).pullToRefresh({  
            up: {  
                auto:true,  
                contentrefresh : "正在加载...",// 可选,正在加载状态时,上拉加载控件上显示的标题内容  
                contentnomore:'没有更多数据了',// 可选,请求完毕若没有更多数据时显示的提醒内容;  
                callback: function() {  
                    var self = this;// 这里的this == mui('#refreshContainer').pullRefresh()  
                    //console.log(self);  
                    setTimeout(function() {  
                        console.log("index--"+index);  
                        var ul = self.element.querySelector('.mui-table-view');  
                        loadData(ul, index,pullRefreshEl);  
                        self.endPullUpToRefresh(false);  

                    }, 1000);  
                }  
            }  
        });  
    });  
    var loadData = function(ul, index, pullRefreshEl) {  
        var currentPage = ul.getAttribute('curPage');  
        var objId = ul.getAttribute('id');  

        $.ajax({  
            url:"******”  
            type:"get",  
            data:{  
                pageSize:5,  
                pageNumber:currentPage  
            },  
            success:function(res){  
                if(res.status==200){  
                    var data = res.data;  
                    hasNextPage = data.hasNextPage;//是否有下一页  
                    var html=getHtml(index,data.list);  
                    ul.insertAdjacentHTML('beforeend',html);  
                    mui(pullRefreshEl).pullRefresh().endPullupToRefresh(!hasNextPage);  

                    if(hasNextPage){  
                        var nextPage = Number(currentPage)+1;  
                        ul.setAttribute("curPage",nextPage);  
                    }  
                }  
            }  
        });  

    };  
    var getHtml = function(cur,data) {  
        var html = "";  
        $.each(data, function(index,item) {  
            if(cur==0){//警告数据  
                html+='<li class="mui-table-view-cell">'  
                    +'<div class="cgqcontent">'+item.eqpNickname+':'+item.warnValue+'</div>'  
                    +'<div class="lastcon">'+item.warnContent+',持续'+item.warnDuration+'</div>'  
                '</li>';  
            }else{  
                var endTime = item.activeEnd=="2999-12-31 00:00:00"?"":item.activeEnd;  
                html+='<li class="mui-table-view-cell">'  
                +'<div class="mui-table">'+  
                '<div class="mui-table-cell mui-col-xs-3 mui-text-left">'+  
                '<p>'+item.eqpNickname+'</p></div>'+  
                '<div class="mui-table-cell mui-col-xs-9">'+  
                '<p>开启:'+item.activeStart+'</p><p>关闭:'+endTime+'</p></div>'+  
                '</div></li>';  
            }  
        });  
        return html;  
    };  
});  
2018-04-17 17:06 负责人:无 分享
已邀请:

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