announcement_list.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. var app = getApp();
  2. const util = require('../../utils/utils.js');
  3. Page({
  4. data: {
  5. notice:[],
  6. links:null,
  7. page:1
  8. },
  9. onLoad: function (options) {
  10. this.notice()
  11. },
  12. notice: function () {
  13. var that = this;
  14. var area_id = ''
  15. if (wx.getStorageSync('home').id != undefined) {
  16. area_id = wx.getStorageSync('home').id
  17. }
  18. var data = {
  19. 'area_id': area_id
  20. }
  21. app.request("/ans", data, "GET").then(res => {
  22. console.log(res)
  23. that.setData({ notice: res.data.data,links:res.data.meta.pagination.links})
  24. }).catch(err => {
  25. console.log(err)
  26. })
  27. },
  28. detail: util.throttle(function (e) {
  29. console.log(e)
  30. var id = e.currentTarget.dataset.id;
  31. wx.navigateTo({
  32. url: '../public_details/public_details?id=' + id,
  33. })
  34. }, 1000),
  35. onReady: function () {
  36. },
  37. onShow: function () {
  38. },
  39. onHide: function () {
  40. },
  41. onUnload: function () {
  42. },
  43. onPullDownRefresh: function () {
  44. wx.showNavigationBarLoading();
  45. var that = this;
  46. var area_id = ''
  47. if (wx.getStorageSync('home').id != undefined) {
  48. area_id = wx.getStorageSync('home').id
  49. }
  50. var data = {
  51. 'area_id': area_id
  52. }
  53. app.request("/ans", data, "GET").then(res => {
  54. console.log(res)
  55. that.setData({ notice: res.data.data, links: res.data.meta.pagination.links })
  56. wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
  57. })
  58. },
  59. onReachBottom: function () {
  60. var that = this;
  61. if (this.data.links == null) {
  62. wx.showToast({
  63. title: '没有更多了',
  64. icon: 'none'
  65. })
  66. } else {
  67. var area_id = '';
  68. var page = that.data.page + 1;
  69. if (wx.getStorageSync('home').id != undefined) {
  70. area_id = wx.getStorageSync('home').id
  71. }
  72. var data = {
  73. 'area_id': area_id
  74. }
  75. app.request("/ans?page=" + page, data, "GET").then(res => {
  76. console.log(res)
  77. that.setData({ notice: that.data.notice.concat(res.data.data), links: res.data.meta.pagination.links, page })
  78. }).catch(err => {
  79. console.log(err)
  80. })
  81. }
  82. },
  83. onShareAppMessage: function () {
  84. }
  85. })