announce.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. var api = require('../../utils/api.js');
  2. var app = getApp()
  3. Page({
  4. data: {
  5. list: []
  6. },
  7. onLoad: function () {
  8. this.loadMoreAnnouncesList();
  9. },
  10. onReachBottom: function () {
  11. this.loadMoreAnnouncesList();
  12. // is_no_more || this.loadMoreGoodsList();
  13. },
  14. loadMoreAnnouncesList: function() {
  15. var that = this;
  16. wx.showLoading({
  17. title: '加载中',
  18. })
  19. wx.request({
  20. url: api.getAnnouncesUrl,
  21. method: 'GET',
  22. data: {
  23. 'offset': that.data.list.length
  24. },
  25. success: res => {
  26. if (res.data.list.length > 0) {
  27. var new_list = that.data.list.concat(res.data.list);
  28. that.setData({
  29. list: new_list
  30. });
  31. } else {
  32. wx.showToast({
  33. title: '到底了',
  34. icon: 'none',
  35. duration: 800
  36. })
  37. }
  38. },
  39. complete: res => {
  40. wx.hideLoading()
  41. }
  42. })
  43. },
  44. redirectToAnnounce: function(e) {
  45. let id = e.currentTarget.dataset.id;
  46. wx.navigateTo({
  47. url: '/pages/announce-detail/index?id=' + id
  48. })
  49. }
  50. })