announcement_list.js 2.1 KB

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