• APICloud 上滑加载更多


    <!DOCTYPE html>
    <html>   
        <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"
            />
            <title>
                列表
            </title>
            <script src="../../script/jquery-1.11.1.min.js">
            </script>
            <script type="text/javascript" src="../../script/api.js">
            </script>
        </head>
        
        <body>
            <div style="100%">
                <ul id="list_item">
                </ul>
            </div>       
        </body>
        <script>
            apiready = function() {
                var id = 0;
                var cellarray = new Array();
                //得到json的路径
                var href = window.location.href; // 得到当前文件的路径
                var Route = ""; //得到json的路径                
                var json = ""; //读取的json
                var arr = new Array();
                arr = href.split("/");
                for (var i = 0; i < arr.length - 1; i++) {
                    Route += arr[i] + '/';
                }
                Route += "list.json";
                //读取json的文件  
                api.readFile({
                    path: Route
                },
                function(ret, err) {
                    if (ret.status) {
                        json = ret.data;
                        //Json(json);
                        var list = eval('(' + json + ')');
                        var json1 = eval(list.data);
                        for (var i = 0; i < json1.length; i++) {
                            cellarray[i] = json1[i].img;
                        }
                        //当json的值大于10的时候
                        if (cellarray.length >= 10) {
                            //循环添加前10 个li标签                        
                            id= Ergodic(id ,id * 10 + 10,cellarray);
                        } else {
                            //小于10则直接添加                       
                            id= Ergodic(id ,cellarray.length,cellarray);                        
                        }
                    } else {
                        api.alert({
                            msg: '错误码: ' + err.code + '错误信息' + err.msg
                        });
                    }
                });
                //判断是否滑到底
                api.addEventListener({
                    name: 'scrolltobottom'
                },
                function(ret, err) {
                    if (cellarray.length - id * 10 >= 10) {
                        //循环添加前10 个li标签                 
                        id= Ergodic(id , id * 10 + 10,cellarray);
                    } else {
                        if (cellarray.length - id * 10 < 10 && cellarray.length - id * 10 > 0) {
                            //小于10则直接添加                    
                            id= Ergodic(id , cellarray.length,cellarray);
                        } else {
                            api.toast({
                                msg: '已加载完毕',
                                duration: 1000,
                                location: 'bottom'
                            });
                        }
                    }
                })
            }
            function tuandetail()
            {
                    api.openWin({
                        name : 'tuandetail_header',
                        url : '../tuandetail_header.html',
                        bounces : false,
                        delay : 200
                    });
            }
            //遍历cellarray返回id
            function Ergodic(id ,sty,cellarray)
            {
                var html = "";
                for (var i = id * 10; i < sty; i++) {
                       html += "<li  onclick='tuandetail()'>><img src='" + cellarray[i] + "'/></li> ";                               
                 }
                 $("#list_item").append(html);
                 id += 1;
                 return id;
            }
            
        </script>
     

    </html>

  • 相关阅读:
    MFC程序执行过程剖析
    不同位数操作系统的 数据长度
    测试:safenet提供的CheckKey函数 内存泄漏。具体来说是句柄.
    关于更改项目名称
    内存泄漏相关的
    美化MFC 之调整静态文本的颜色 字体。 用于添加公司标题 联系方式 口号等数据
    DAVINCI DM365-DM368开发攻略——开发环境搭建(DVSDK4.02)
    Removing Unnecessary HTTP Headers in IIS and ASP.NET 在ASP.Net和IIS中删除不必要的HTTP响应头
    Implementing Singleton in C#
    WEBAPI VS WCF微软随.NET 4.5发布新REST API框架
  • 原文地址:https://www.cnblogs.com/sg1991/p/4535999.html
Copyright © 2020-2023  润新知