index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. const getHeight = require("../../utils/getRheRemainingHeight");
  2. const _Http = getApp().globalData.http;
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. scrollHeight: 0,
  9. list: [],
  10. "content": {
  11. nocache: true,
  12. "pageNumber": 1,
  13. "pageSize": 20,
  14. "pageTotal": 1,
  15. "where": {
  16. "condition": ""
  17. }
  18. }
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad(options) {
  24. this.getList()
  25. },
  26. getList(init = false) {
  27. if (init.detail != undefined) init = init.detail;
  28. if (init) this.setData({
  29. ['content.pageNumber']: 1
  30. })
  31. if (this.data.content.pageNumber > this.data.content.pageTotal) return;
  32. _Http.basic({
  33. "classname": "saletool.notice.notice",
  34. "method": "queryNoticeList",
  35. content: this.data.content
  36. }).then(res => {
  37. console.log("通告列表", res)
  38. this.selectComponent('#ListBox').RefreshToComplete();
  39. if (res.msg != '成功') return wx.showToast({
  40. title: res.data,
  41. icon: "none"
  42. })
  43. this.setData({
  44. total: res.total,
  45. list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
  46. ['content.pageNumber']: res.pageNumber + 1,
  47. ['content.pageTotal']: res.pageTotal
  48. })
  49. })
  50. },
  51. /* 查看详情 */
  52. toDetails(e) {
  53. const {
  54. item
  55. } = e.currentTarget.dataset;
  56. wx.navigateTo({
  57. url: `./details?id=${item.sat_noticeid}`
  58. })
  59. },
  60. /**
  61. * 生命周期函数--监听页面初次渲染完成
  62. */
  63. onReady() {
  64. getHeight.getHeight('.top', this).then(res => {
  65. this.setData({
  66. scrollHeight: res
  67. })
  68. })
  69. },
  70. /**
  71. * 生命周期函数--监听页面显示
  72. */
  73. onShow() {
  74. },
  75. /**
  76. * 生命周期函数--监听页面隐藏
  77. */
  78. onHide() {
  79. },
  80. /**
  81. * 生命周期函数--监听页面卸载
  82. */
  83. onUnload() {
  84. },
  85. /**
  86. * 页面相关事件处理函数--监听用户下拉动作
  87. */
  88. onPullDownRefresh() {
  89. },
  90. /**
  91. * 页面上拉触底事件的处理函数
  92. */
  93. onReachBottom() {
  94. },
  95. /**
  96. * 用户点击右上角分享
  97. */
  98. onShareAppMessage() {
  99. }
  100. })