index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. onShareAppMessage: function() {
  43. },
  44. search: function(override) {
  45. let _this = this
  46. let param = {from: override?0:this.data.from, size:this.data.size}
  47. app.formPost('Post.getPostList', param ).then(res => {
  48. _this.setData({spinShow: false});
  49. wx.stopPullDownRefresh()
  50. if (res.code === 200) {
  51. const re = res.data
  52. console.log( re )
  53. _this.setData({
  54. from: re.from,
  55. tableData: override ? re.list : this.data.tableData.concat(re.list)
  56. });
  57. }
  58. })
  59. }
  60. })