index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. const app = getApp()
  2. Page({
  3. data: {
  4. imgUrls:[
  5. "/assets/carousel/1.png",
  6. "/assets/carousel/2.png",
  7. "/assets/carousel/3.png"
  8. ],
  9. tableData: [],
  10. from: 0,
  11. size: 10,
  12. indicatorDots: false,
  13. autoplay: true,
  14. interval: 4000,
  15. duration: 800,
  16. },
  17. swiperChange(e) {
  18. const that = this;
  19. that.setData({
  20. swiperIndex: e.detail.current,
  21. })
  22. },
  23. onLoad: function(options) {
  24. this.setData({
  25. spinShow: true
  26. });
  27. this.search(true)
  28. },
  29. onPullDownRefresh() {
  30. this.setData({ spinShow: true });
  31. if (!this.loading) {
  32. this.setData({ from:0,tableData:[]});
  33. this.search(true)
  34. }
  35. },
  36. onReachBottom() {
  37. console.log( "onReachBottom", this.loading, this.data.from)
  38. if (!this.loading && this.data.from > -1) {
  39. this.search(false)
  40. }
  41. },
  42. search: function(override) {
  43. let _this = this
  44. let param = {from: override?0:this.data.from, size:this.data.size}
  45. app.formPost('Post.getPostList', param ).then(res => {
  46. _this.setData({spinShow: false});
  47. wx.stopPullDownRefresh()
  48. if (res.code === 200) {
  49. const re = res.data
  50. console.log( re )
  51. _this.setData({
  52. from: re.from,
  53. tableData: override ? re.list : this.data.tableData.concat(re.list)
  54. });
  55. }
  56. })
  57. }
  58. })