var app = getApp()
Page({
  data: {
    arr: [],
    pages: 1,//当前页面
    links: '',//下一页地址
  },
  onLoad: function (options) {

  },
  detail(e) {
    my.navigateTo({
      url: '../weizhang_detail/weizhang_detail?no=' + e.currentTarget.dataset.id,
    })
  },
  onReady: function () {

  },
  onShow: function () {
    var that = this;
    that.setData({
      arr: []
    })
    that.getList()
  },
  getList: function () {
    var that = this;

    my.showLoading({
      content: '加载中...',
    })
    let data = { page: that.data.pages }
    app.request('/punishment_orders', data, 'GET').then(res => {
      if (res.status == 200) {
        console.log(res)
        let arr1 = res.data.data
        var arr = that.data.arr.concat(arr1);
        if (arr1.length == 0) {
          my.showToast({
            content: '暂无更多~',
            icon: 'none'
          })
        } else {
          that.setData({
            arr,
            links: res.data.meta.pagination.links
          })
        }
      }
      my.hideLoading({
        complete: (res) => { },
      })
    })
  },
  onHide: function () {

  },
  onUnload: function () {

  },
  onPullDownRefresh: function () {

  },
  onReachBottom: function () {
    if (this.data.links == null) {
      my.showToast({
        content: '暂无更多',
        icon: 'none'
      })
      return
    } else {
      let page = this.data.pages++
      page++
      this.setData({
        pages: page
      })
      this.getList()
    }
  },
  onShareAppMessage: function () {

  }
})
