let app = getApp()
Page({
  data: {
    spinShow: false,
    loadMoreLoad: false,
    loadMoreTip: '暂无数据',
    from:0,
    size:9,
    tableData: []
  },
  onLoad: function(options) {
    this.setData({
      spinShow: true
    });
    this.search(true)
  },
  onPullDownRefresh() {
    this.setData({ spinShow: true });
    if (!this.loading) {
      this.setData({ from:0,tableData:[]});
      this.search(true)
    }
  },
  onReachBottom() {
    console.log( "onReachBottom", this.loading, this.data.from)
    if (!this.loading && this.data.from > -1) {
      this.search(false)
    }
  },
  search: function(override) {
    let _this = this
    let param = {from: override?0:this.data.from, size:this.data.size}
    app.formPost('Exam.RedoPaperList', param ).then(res => {
      _this.setData({spinShow: false});
      wx.stopPullDownRefresh()
      if (res.code === 200) {
        const re = res.data
        console.log( re )
        _this.setData({
          from: re.from,
          tableData: override ? re.list : this.data.tableData.concat(re.list)
        });
      }
    })
  }
})