index.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. let app = getApp()
  2. Page({
  3. data: {
  4. spinShow: false,
  5. loadMoreLoad: false,
  6. loadMoreTip: '暂无数据',
  7. from:0,
  8. size:9,
  9. tableData: []
  10. },
  11. onLoad: function(options) {
  12. this.setData({
  13. spinShow: true
  14. });
  15. this.search(true)
  16. },
  17. onPullDownRefresh() {
  18. this.setData({ spinShow: true });
  19. if (!this.loading) {
  20. this.setData({ from:0,tableData:[]});
  21. this.search(true)
  22. }
  23. },
  24. onReachBottom() {
  25. console.log( "onReachBottom", this.loading, this.data.from)
  26. if (!this.loading && this.data.from > -1) {
  27. this.search(false)
  28. }
  29. },
  30. search: function(override) {
  31. let _this = this
  32. let param = {from: override?0:this.data.from, size:this.data.size}
  33. app.formPost('Exam.RedoPaperList', param ).then(res => {
  34. _this.setData({spinShow: false});
  35. wx.stopPullDownRefresh()
  36. if (res.code === 200) {
  37. const re = res.data
  38. console.log( re )
  39. _this.setData({
  40. from: re.from,
  41. tableData: override ? re.list : this.data.tableData.concat(re.list)
  42. });
  43. }
  44. })
  45. }
  46. })