小程序点击更多加载下一页超简单版

212 阅读1分钟

// 获取具体某天的上课记录 ,默认选择全部


<view class='item12' wx:if="{{iclass.length>=6}}" bindtap="iclassload">点击加载更多</view>

  <view class="item13" wx:if="{{iclass.length==0}}">

    暂时没有排课

  </view>

  data: {
    ipage: 1,//默认第一页  
    iclass: []      
  }
  calendar_list: function () {
    var that = this;
    that.setData({
      idate:'1999-01-01',
      ipage:1,
      iclass: []
    })
    var url = http + "/api_mem/m_calendar.asmx/calendar_list?_k=" + wx.getStorageSync('key') + "&_day=" + that.data.idate + "&_ipage=" + that.data.ipage
    wx.request({
      url: url,
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success(res) {
        var rol = res.data;
       for(var i in rol){
         if (rol[i].logo == '' || rol[i].logo == null){
           rol[i].logo = '../../images/4.png'
         }else{
           rol[i].logo = 'https://mini.lanqiy.com/upimages/'+rol[i].logo;
         }
       }
        that.setData({
          iclass: rol
        })
      }
    })
  }
  
  iclassload: function (){
    var that = this
    var url = http + "/api_mem/m_calendar.asmx/calendar_list?_k=" + wx.getStorageSync('key') + "&_day=" + that.data.idate + "&_ipage=" + (++that.data.ipage)
    wx.request({

      url: url,
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success(res) {
        var rol = res.data;
        var obj = rol[0];
        if (!obj) {
            wx.showToast({
              title: '暂无更多排课!',
              icon: 'loading',
              duration: 2000,
            })
        }else{
            for (var i in rol) {
              if (rol[i].logo == '' || rol[i].logo == null) {
                rol[i].logo = '../../images/4.png'
              } else {
                rol[i].logo = 'https://mini.lanqiy.com/upimages/' + rol[i].logo;
              }
            }
            that.setData({
              iclass: that.data.iclass.concat(rol)
            })
        }
      }
    })
  },