zoukankan      html  css  js  c++  java
  • 双webview下拉刷新上拉加载

    主页:

    collection.html

    <div id="content" class="content">
    </div>

    js:

    mui.init({
                gestureConfig:{
                    doubletap:true
                },
                subpages:[{
                    url:'collectionSub.html',
                    id:'collectionSub.html',
                    styles:{
                        top: '45px',
                        bottom: '0px',
                    }
                }]
            });

    子页面:

    collectionSub.html
    <div id="pullrefresh" class="mui-content mui-scroll-wrapper" pageNumber="0" totalPages="0">
                <div class="mui-scroll" id="content">
                    
                </div>
    
            </div>
            <script id="test" type="text/html">
                <ul class="mui-table-view mui-table-view-chevron walletHistoryUl">
    
                    <li class='refund-Item-li'>
                        <div class="Chargingpile" onclick="seemore({{id}},'{{title}}',{{dist}},{{latitude}},{{longitude}})">
                            <h4>{{ title }}<span class="distance">{{dist}}m</span></h4>
                            <p>{{ address }}</p>
                            <div>
                                <div class="Number"><img src="img/kuai.png" /><span>快充{{ fastFilling }}个</span></div>
                                <div class="Number"><img src="img/man.png" /><span>慢充{{ slowFilling }}个</span></div>
                                <a class="seemore">查看详情></a>
                            </div>
                        </div>
                    </li>
                </ul>
            </script>

    js:

    var pays = {};
                var w = null;
                var lat = 0;
                var lng = 0;
                mui('.mui-scroll-wrapper').scroll({
                    deceleration: 0.0005 //flick 减速系数,系数越大,滚动速度越慢,滚动距离越小,默认值0.0006
                });
                mui.init({
                    pullRefresh: {
                        container: '#pullrefresh',
                        up: {
                            callback: pullupRefresh
                        },
                        down: {
                            callback: pulldownRefresh
                        }
                    }
                });
    
                mui.plusReady(function() {
                    myCollectChargingPile("1");
                })
    
                function pulldownRefresh() {
                    setTimeout(function() {
                        myCollectChargingPile("1");
                        mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
                        mui('#pullrefresh').pullRefresh().refresh(true);
                    }, 1500);
                }
    
                function pullupRefresh() {
                    setTimeout(function() {
                        pageNumber = $("#pullrefresh").attr("pageNumber");
                        totalPages = $("#pullrefresh").attr("totalPages");
                        console.log("pageNumber:" + pageNumber);
                        console.log("totalPages:" + totalPages);
                        if(pageNumber >= totalPages) {
                            mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); //参数为true代表没有更多数据了。
                            return;
                        } else {
                            // 非最后一页,则请求下一页
                            pageNumber++;
                        }
                        mui('#pullrefresh').pullRefresh().refresh(true);
                        myCollectChargingPile(pageNumber);
                    }, 1500);
                }
    
                function myCollectChargingPile(pageNum) {
                    var clat = parseFloat(plus.storage.getItem('lat'));
                    var clng = parseFloat(plus.storage.getItem('lng'));
                    $.ajax({
                        type: "post",
                        url: IP + '/mobile/user/myCollectChargingPile.html',
                        data: {
                            token: plus.storage.getItem("token"),
                            pageSize: "20",
                            pageNumber: pageNum
                        },
                        dataType: "json",
                        success: function(data) {
                            if(pageNum === data.data.totalPage) {
                                mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
                            } else {
                                mui('#pullrefresh').pullRefresh().endPullupToRefresh(false);
                            }
                            $("#pullrefresh").attr("totalPages", data.data.totalPage);
                            $("#pullrefresh").attr("pageNumber", data.data.pageNumber);
                            if(pageNum == 1) {
                                $("#content").empty();
                            }
                            if(data.errorCode == 0) {
                                var list = data.data.list;
                                var ul = $(".mui-table-view");
                                $.each(list, function(i, n) {
                                    var address = n.address;
                                    var latitude = n.latitude;
                                    var id = n.id;
                                    var slowFilling = n.slowFilling;
                                    var title = n.title;
                                    var fastFilling = n.fastFilling;
                                    var longitude = n.longitude;
                                    var dist = getDistance(clat, clng, latitude, longitude);
                                    var data = {
                                        address: address,
                                        latitude: latitude,
                                        id: id,
                                        slowFilling: slowFilling,
                                        title: title,
                                        fastFilling: fastFilling,
                                        longitude: longitude,
                                        dist: dist,
                                    };
                                    console.log(JSON.stringify(data))
                                    var html = template('test', data);
                                    $('#content').append(html);
    
                                });
    
                            } else {
                                plus.nativeUI.toast(data.errorInfo);
                            }
                        }
                    });
                }
  • 相关阅读:
    [DOJ练习] 无向图的邻接矩阵表示法验证程序
    [DOJ练习] 求无向图中某顶点的度
    [邻接表形式]有向图的建立与深度,广度遍历
    [DOJ练习] 有向图的邻接表表示法验证程序(两种写法)
    [Java 学习笔记] 异常处理
    [总结]单源最短路(朴素Dijkstra)与最小生成树(Prim,Kruskal)
    时间选择插件jquery.timepickr
    页面值传入后台出现中文乱码
    CheckTreecheckbox树形控件
    JQuery EasyUI DataGrid
  • 原文地址:https://www.cnblogs.com/ccllj/p/9637960.html
Copyright © 2011-2022 走看看