收藏
回答

上拉加载数据会加载好几页,而且有重复

var page = 1;

var limit = 5;

var GetList = function (that) {

  that.setData({

    hidden: false

  });

  wx.request({

    url: url,

    data: {

      page: page,

      limit: limit,

    },

    method: 'POST',

    header: {

      'content-type': 'application/x-www-form-urlencoded'

    },

    success: function (res) {

      console.log("get:" + page)

      var list = that.data.list;

      for (var i = 0; i < res.data.length; i++) {

        list.push(res.data[i].fields);

      }

      that.setData({

        list: list,

      });

      page++;

      that.setData({

        hidden: true

      });

    }

  });

}

Page({

  data: {

    hidden: false,

    list: [],

    scrollHeight: 0,

    scrollTop:0

  },

  onLoad: function () {

    var that = this;

    wx.getSystemInfo({

      success: function (res) {

        console.info('heith' + res.windowHeight);

        that.setData({

          scrollHeight: res.windowHeight

        });

      }

    });

    GetList(that);

  },

  bindDownLoad: function () {

    //  该方法绑定了页面滑动到底部的事件

    var that = this;

    GetList(that);

  },


})



回答关注问题邀请回答
收藏
登录 后发表内容