index.js 1.1 KB

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