• 微信小程序


    demo.wxml  文件

      
    <view wx:for="{{listdata}}" wx:key="listdata" class='listitem'>
      <view class='title'>{{ item.store_name }}</view>
      <image src='{{item.logo}}'></image>
    </view>
    
    <view class="load-more-wrap">
      <block wx:if="{{hasMore}}">
        <view class="load-content">
          <text class="weui-loading"/><text class="loading-text">玩命加载中</text>
        </view>
      </block>
      <block wx:else>
        <view class="load-content">
          <text>没有更多内容了</text>
        </view>
      </block>
    </view>    
     
    demo.js  文件
      
    Page({
      data: {
        listdata:[],   //数据
        paginated: '', 
        //{total:"12", count: 10, more: 1} total数据总数,count:当前分页数据数据,more:1表示还有,0表示无数据
        p:0, //当前分页;默认第一页
        hasMore:true  //提示
      },
      onLoad: function (options) {
        var that = this;
        var p = that.data.p;
        this.loadmore();
      },
      onReachBottom:function(){
        var that = this;
        var paginated = that.data.paginated;
        if (paginated.more != 0) {
          this.loadmore();
        }else{
          that.setData({
            "hasMore": false
          })
        }
      },
      loadmore:function(){
        wx.showToast({
          title: "玩命加载中",
          icon: 'loading',
          duration: 1000
        })
        var that = this;
        var p = ++that.data.p;
        wx.request({
          url: 'xxx',
          data: {
            "json": JSON.stringify({
              "demo": "xxx", "p": p
            })
          },
          method: 'POST',
          header: {
            'content-type': 'application/x-www-form-urlencoded'
          },
          success:function(res){
            if (res.data.data != 0) {
              that.setData({
                "listdata": that.data.listdata.concat(res.data.data), //加载数据
                "paginated": res.data.paginated, //{total:"12", count: 10, more: 1} 此处主要用于上拉加载是否加载数据
                "p":p
              })
            } else {
              that.setData({
                "hasMore":false
              })
            }
          }
        })
      }
    })
    

     
     
     
     
  • 相关阅读:
    jQuery基础教程-第8章-002Adding jQuery object methods
    jQuery基础教程-第8章-001Adding new global functions
    福利彩票-001什么是福利彩票
    Java生产者消费者问题
    Java集合
    Java线程
    JavaPersistenceWithMyBatis3笔记-第5章Configuring MyBatis in a Spring applications-001
    CentOS安装和配置Apache(httpd)
    CentOS安装和配置FTP
    PHP 常用获取路径代码
  • 原文地址:https://www.cnblogs.com/changxue/p/8275770.html
Copyright © 2020-2023  润新知