分页加载数据

引言:页面上拉加载数据,主要是获取到页面的高度,然后传递页码,再在前端拼接数据

<view class='list' style="height:{{winHeight-29}}px">
        <scroll-view scroll-y="{{true}}" bindscrolltolower="loadmore" enable-back-to-top="{{true}}" style="height: 100%;" lower_threshold="200">
          <block wx:for="{{list}}" wx:key>
            <view class='item acea-row row-between-wrapper'>
                <view class="picTxt acea-row row-between-wrapper">
                    <view class='pictrue'><image src='{{item.userinfo.userimg}}'></image></view>
                    <view class='text'>
                        <view class='name line1'>{{item.userinfo.username}}</view>
                        <view>建立时间: {{item.addtime}}</view>
                    </view>
                </view>
            </view>
          </block>
        </scroll-view>
    </view>
data: {
    page: 0,
    list: [],
    count: 0,
    winWidth: 0,
    winHeight: 0,
  },
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
    var that = this
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          winWidth: res.windowWidth,
          winHeight: res.windowHeight
        });
      }
    });
    that.init()
  },
init: function(){
    var that = this
    that.getlist()
  },

  getlist: function(){
    var that = this
    app.reqPost("Share", "getshareuserlist", {
      page: that.data.page,
      PHPSESSID: wx.getStorageSync('PHPSESSID')
    }, function (res) {
      console.log(res.data)
      that.setData({
        count: res.data.data.count,
        list: that.data.list.concat(res.data.data.list)  //拼接数据
      })
    })
  },
  loadmore: function () {
    this.data.page++;
    this.getlist()
  },
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。