小程序不满一页自动加载下一页

// 获取积分列表
  getJifenList: function(){
    var url = app.globalData.reqUrl + 'integral_goods/integral_detail';
    var params = {
      user_id: app.globalData.userId,
      type: this.data.type,
      page: this.data.curPage

    }
    app.request.requestGetApi(url, params, this, this.successFun_getJifenList, this.failFun)
  },
  successFun_getJifenList: function(res,selfObj){
    if (res.code == 200) {
      if (res.data.data.length > 0) {
        selfObj.setData({
          jifenList: this.data.jifenList.concat(res.data.data)
        })
        // 不满一页自动加载下一页
        wx.createSelectorQuery().select('#jifenList').boundingClientRect(res2 => {
          if (res2.height < wx.getSystemInfoSync().windowHeight) {
            selfObj.setData({
              curPage: this.data.curPage + 1
            })
            this.getJifenList();
          }
        }).exec()
      } else {
        if (this.data.jifenList.length > 0) {
          app.globalData.toastNoData();
        } else {
          console.log('暂无数据')
        }
      }
    } else {
      wx.showToast({
        title: res.message,
        icon: 'none'
      })
    }
  },

猜你喜欢

转载自www.cnblogs.com/duanzhenzhen/p/11977231.html