顶面
顶面
  • 发布:2015-10-13 11:19
  • 更新:2015-10-13 17:17
  • 阅读:1515

上拉加载问题,轻轻一拉就加载

分类:HBuilder

<body onload="load()">  
        <div class="mui-navbar-inner mui-bar mui-bar-nav" id="head">  
            <button type="button" class="mui-left mui-action-back mui-btn  mui-btn-link mui-btn-nav mui-pull-left">  
                <span class="mui-icon mui-icon-left-nav">返回</span>  

            </button>  
            <h1 class="mui-center mui-title">我的推荐</h1>  
        </div>  
        <input id="pageindex_record" name="pageindex_record" value="1" type="hidden" />  

        <div data-left-drawer="left" class="panel" id="recommendWithdrawals" title="我的推荐" style="margin-top: 44px;">  
            <div class="recordlist" id="recordlist">  
                <ul>  
                    <li class="recordlist_bt">  
                        <div class="app-pro-tab">  
                            <a class="pro-tab-cell">商户帐号</a>  
                            <a class="pro-tab-cell">交易金额</a>  
                            <a class="pro-tab-cell">交易笔数</a>  
                        </div>  
                    </li>  

                </ul>  
                <div id="offCanvasContentScroll" class="mui-content mui-scroll-wrapper">  
                    <div class="mui-scroll">  
                        <ul id="ul_recommendlist" style="text-align: center;"></ul>  
                    </div>  
                </div>  

            </div>  
        </div>  
        <script type="text/javascript" src="../js/mui.min.js"></script>  
        <script>  
            mui.init({  
                swipeBack: false,  
                pullRefresh: {  
                    container: '#offCanvasContentScroll',  
                    up: {  
                        contentrefresh: '正在加载...',  
                        callback: pullupRefresh  
                    }  
                }  
            });  
            var count = 0;  

            function pullupRefresh() {  
                mui('#offCanvasContentScroll').pullRefresh().endPullupToRefresh((++count > 2));  
                setTimeout(function() {  
                    var pageindex_record = document.getElementById("pageindex_record");  
                    RecommendSearch(dmurl + "/AppNew/Index/Recommend?pageindex=" + pageindex_record.value);  
                }, 1500);  
            }  
            if (mui.os.plus) {  
                mui.plusReady(function() {  
                    setTimeout(function() {  
                        mui('#offCanvasContentScroll').pullRefresh().pullupLoading();  
                    }, 1000);  
                });  
            } else {  
                mui.ready(function() {  
                    mui('#offCanvasContentScroll').pullRefresh().pullupLoading();  
                });  
            }  
            mui('#offCanvasContentScroll').scroll();  

            function load() {  
                var offCanvasContentScroll = document.getElementById("offCanvasContentScroll");  
                var height = document.getElementById("height");  
                var hei = document.documentElement.clientHeight - 100;  
                offCanvasContentScroll.style.height = hei + 'px';  
            }  

            function RecommendSearch(url) {  
                mui.ajax({  
                    Type: 'POST',  
                    url: url, // "/AppNew/Index/Withdrawals?pageindex=" + pageindex + "&tradetype=" + tradetype,  
                    dataType: 'json',  
                    error: function() {},  
                    success: function(data) {  
                        var ul_recommendlist = document.getElementById("ul_recommendlist");  
                        var result = data.listdata;  
                        for (var item in result) {  
                            ul_recommendlist.innerHTML += (" <li class='recordlist_list'><input value='" + result[item].UserID + "' style='display:none' /><div class='app-pro-tab'><a class='pro-tab-cell' >" + result[item].TrueName + "</a><a class='pro-tab-cell'  >" + result[item].dMoney + "</a><a class='pro-tab-cell'  >" + result[item].RechargeSum + "</div></li></a>");  
                        }  
                        var pageindex_record = document.getElementById("pageindex_record");  
                        //          var div_tradelist_mor = document.getElementById("div_tradelist_mor");  
                        var offCanvasContentScroll = document.getElementById("offCanvasContentScroll");  
                        pageindex_record.value = data.pageindex;  
                        if (data.hasmore == 0) {  
                            mui('#offCanvasContentScroll').pullRefresh().endPulldownToRefresh(true);  
                        } else {  
                            mui('#offCanvasContentScroll').pullRefresh().endPulldownToRefresh(false);  
                        }  
                    }  
                });  
            }  
        </script>  
    </body>  

</html>  
2015-10-13 11:19 负责人:无 分享
已邀请:
脉搏

脉搏

上拉加载这个不需要拉,而是监听的是否滑动到底部,滑动到底部就执行了。

  • 顶面 (作者)

    谢啦,已经解决

    2015-10-14 14:51

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