1***@163.com
1***@163.com
  • 发布:2017-12-15 17:45
  • 更新:2017-12-16 07:46
  • 阅读:1239

同一页面,tab切换列表,如何对显示列表做上拉刷新

分类:MUI

<!DOCTYPE html>
<html>

<head>  
    <meta charset="utf-8">  
    <title>Hello MUI</title>  
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">  
    <meta name="apple-mobile-web-app-capable" content="yes">  
    <meta name="apple-mobile-web-app-status-bar-style" content="black">  
    <!--css-->  

    <link rel="stylesheet" type="text/css" href="../../css/mui.css" />  
    <!--组件依赖js begin-->  

    <script type="text/javascript" src="../../js/mui.min.js"></script>  
    <style>  
        a {  
            text-decoration: none;  
            color: #000000;  
        }  

        li {  
            font-size: 15px;  
        }  

        .list-di1 {  
            color: red;  
        }  
        .mui-card .mui-control-content {  
            padding: 10px;  
        }  

        .mui-control-content {  
            height: 90%;  
        }  

        #segmentedControl {  
            background-color: white;  
            line-height: 40px;  
            width: 100%;  
            z-index: 10;  
            border-bottom: 1px #ccc solid;  
            margin-top: 57px  
        }  

        #segmentedControl .mui-active {  
            border-bottom: 1px #f50 solid;  
            color: #f50;  
        }  

        .ui-refresh-down {  
            height: 42px;  
            border-top: 1px solid #e4e4e4;  
            border-bottom: 1px solid #e4e4e4;  
            line-height: 42px;  
            background: #f0f0f0;  
            text-align: center;  
        }  
    </style>  
</head>  

<body>  

    <div id="page">  

        <div class="mui-content">  

            <div id="segmentedControl" class="mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">  
                <a class="mui-control-item mui-active" href="#item1">司机发布</a>  
                <a class="mui-control-item" href="#item2">乘客发布</a>  
            </div>  

            <section id="pullrefresh">  
                <div class="ui-refresh" id="car">  

                    <div id="item1" class="mui-control-content mui-active">  
                        <ul class="data-list" class="mui-table-view" >  
                        <a href="detail.html" class="list">  
                            <li class="mui-table-view-cell" id="list-1">  
                                <div class="mui-slider-handle">  
                                    <div class="mui-table-cell">  
                                        <span class="list-di1">李师傅    A小区</span>  
                                        <div class="cm_box" style="border: 0px;">  
                                            <div class="cm_l">  
                                                <div class="car_header"><img src="../../images/Nopictures.jpg" />  
                                                    <p style="text-align: center;">萌萌萌萌</p>  
                                                </div>  
                                            </div>  
                                            <div class="cm_r">  
                                                <ul>  
                                                    <li style="border: 0px;"><span class="start_y">苍南县高岚路327号</span></li>  
                                                    <li style="border: 0px;"><span class="end_y">矾山镇文昌路161-15号</span></li>  
                                                </ul>  
                                            </div>  
                                            <span class="mui-badge" style="background-color: white;">  
                                    <p ><span class="mui-badge" style="background-color: white;color: red; font-size: 24px;">2</span>元</p>  
                                            <p style="padding-top: 10px;"><span class="mui-badge" style="background-color: white;color: blue; font-size: 24px;">3</span>座位</p>  
                                            </span>  
                                        </div>  
                                    </div>  
                                    <div style="font-size: 12px; background-color: whitesmoke; width: 100%;">发布时间:2017-11-02 17:20:51</div>  
                                </div>  
                                <div class="mui-slider-right mui-disabled">  
                                    <a class="mui-btn mui-btn-red" ontouchend="delectFun(1);">删除</a>  
                                </div>  
                            </li>  
                        </a>  
                        <a href="detail.html" class="list">  
                            <li class="mui-table-view-cell" id="list-2">  
                                <div class="mui-slider-handle">  
                                    <div class="mui-table-cell">  
                                        <span class="list-di1">王师傅   C小区</span>  
                                        <div class="cm_box" style="border: 0px;">  
                                            <div class="cm_l">  
                                                <div class="car_header"><img src="../../images/Nopictures.jpg" />  
                                                    <p style="text-align: center;">挽歌</p>  
                                                </div>  
                                            </div>  
                                            <div class="cm_r">  
                                                <ul>  
                                                    <li style="border: 0px;"><span class="start_y">朝阳区霄云路50号</span></li>  
                                                    <li style="border: 0px;"><span class="end_y">朝阳区霄云路50号-15号</span></li>  
                                                </ul>  
                                            </div>  
                                            <span class="mui-badge" style="background-color: white;">  
                                    <p ><span class="mui-badge" style="background-color: white;color: red; font-size: 24px;">4</span>元</p>  
                                            <p style="padding-top: 10px;"><span class="mui-badge" style="background-color: white;color: blue; font-size: 24px;">1</span>座位</p>  
                                            </span>  
                                        </div>  
                                    </div>  
                                    <div style="font-size: 12px; background-color: whitesmoke; width: 100%;">发布时间:2017-11-02 17:20:51</div>  
                                </div>  
                                <div class="mui-slider-right mui-disabled">  
                                    <a class="mui-btn mui-btn-red" ontouchend="delectFun(2);">删除</a>  
                                </div>  
                            </li>  
                        </a>  
                    </ul>  
                    </div>  

                    <div id="item2" class="mui-control-content">  
                        <ul class="data-list" class="mui-table-view" >  
                        <a href="detail.html" class="list">  
                            <li class="mui-table-view-cell" id="list-3">  
                                <div class="mui-slider-handle">  
                                    <div class="mui-table-cell">  
                                        <span class="list-di">李师傅    A小区</span>  
                                        <div class="cm_box" style="border: 0px;">  
                                            <div class="cm_l">  
                                                <div class="car_header"><img src="../../images/Nopictures.jpg" />  
                                                    <p style="text-align: center;">萌萌萌萌</p>  
                                                </div>  
                                            </div>  
                                            <div class="cm_r">  
                                                <ul>  
                                                    <li style="border: 0px;"><span class="start_y">苍南县高岚路327号</span></li>  
                                                    <li style="border: 0px;"><span class="end_y">矾山镇文昌路161-15号</span></li>  
                                                </ul>  
                                            </div>  
                                            <span class="mui-badge" style="background-color: white;">  
                                    <p ><span class="mui-badge" style="background-color: white;color: red; font-size: 24px;">2</span>元</p>  
                                            <p style="padding-top: 10px;"><span class="mui-badge" style="background-color: white;color: blue; font-size: 24px;">3</span>座位</p>  
                                            </span>  
                                        </div>  
                                    </div>  
                                    <div style="font-size: 12px; background-color: whitesmoke; width: 100%;">发布时间:2017-11-02 17:20:51</div>  
                                </div>  
                                <div class="mui-slider-right mui-disabled">  
                                    <a class="mui-btn mui-btn-red" ontouchend="delectFun(3);">删除</a>  
                                </div>  
                            </li>  
                        </a>  
                    </ul>  
                    </div>  

                    <div class="ui-refresh-down"></div>  

                </div>  
            </section>  

        </div>  

    </div>  
    <div id="btn_div">  
        <div id="btn_dj"><span id="btn_input" class="btn_img hide_b"></span></div>  
        <div id="menu_b" class="menu_btn hide_m">  
            <a href="add.html">发布信息</a>  
        </div>  
    </div>  

    <script>  
        mui('body').on('tap', 'a', function() { document.location.href = this.href; });  
        $(".mui-badge").on('tap', 'a', function(event) {  
            this.click();  
        });  

        mui.init({  
            swipeBack: false,  
            pullRefresh: {  
                container: '#pullrefresh',  
                down: {  
                    callback: pulldownRefresh  
                },  
                up: {  
                    contentrefresh: '正在加载...',  
                    callback: pullupRefresh  
                }  
            }  
        });  
        /**  
         * 下拉刷新具体业务实现  
         */  
        function pulldownRefresh() {  
            setTimeout(function() {  
                var table = document.body.querySelector('.mui-control-content .mui-active .data-list');  
                mui.toast('刷新成功');  

                mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed  
            }, 1000);  
        }  

        var count = 0;  

        /**  
         * 上拉加载具体业务实现  
         */  
        function pullupRefresh() {  
            setTimeout(function() {  
                mui('#pullrefresh').pullRefresh().endPullupToRefresh((++count > 2)); //参数为true代表没有更多数据了。  

                var cells = document.body.querySelectorAll('.list');  
                for(var i = cells.length, len = i + 3; i < len; i++) {  
                    $("").append('<a href="detail.html" class="list">' +  
                        '   <li class="mui-table-view-cell" id="' + i + '1">' +  
                        '       <div class="mui-slider-handle">' +  
                        '           <div class="mui-table-cell">' +  
                        '               <span class="list-di">师傅    小区</span>' +  
                        '               <div class="cm_box" style="border: 0px;">' +  
                        '                   <div class="cm_l">' +  
                        '                       <div class="car_header"><img src="../../images/Nopictures.jpg" />' +  
                        '                           <p style="text-align: center;">名字</p>' +  
                        '                       </div>' +  
                        '                   </div>' +  
                        '                   <div class="cm_r">' +  
                        '                       <ul>' +  
                        '                           <li style="border: 0px;"><span class="start_y">出发点</span></li>' +  
                        '                           <li style="border: 0px;"><span class="end_y">目的地</span></li>' +  
                        '                       </ul>' +  
                        '                   </div>' +  
                        '                   <span class="mui-badge" style="background-color: white;">' +  
                        '           <p ><span class="mui-badge" style="background-color: white;color: red; font-size: 24px;">2</span>元</p>' +  
                        '                   <p style="padding-top: 10px;"><span class="mui-badge" style="background-color: white;color: blue; font-size: 24px;">3</span>座位</p>' +  
                        '                   </span>' +  
                        '               </div>' +  
                        '           </div>' +  
                        '           <div style="font-size: 12px; background-color: whitesmoke; width: 100%;">发布时间:2017-11-02 17:20:51</div>' +  
                        '       </div>' +  
                        '       <div class="mui-slider-right mui-disabled">' +  
                        '           <a class="mui-btn mui-btn-red" ontouchend="delectFun(' + i + ');">删除</a>' +  
                        '       </div>' +  
                        '   </li>' +  
                        '</a>');  
                    $("#tab1 li").css("background-color", "white");  
                }  
            }, 1000);  
        }  

    </script>  

</body>  

</html>

2017-12-15 17:45 负责人:无 分享
已邀请:
小资电脑

小资电脑

mui的demo里有示例

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