unknown
2022-08-16 edd35a251b58b1fad17015deda92324f74458434
pages/notice/notice.js
@@ -1,4 +1,9 @@
// pages/notice/notice.js
const notificationservice = require("../../service/notificationservice")
const moment = require('../../utils/moment.min')
const util = require("../../utils/util.js")
const app = getApp()
Page({
  /**
@@ -17,16 +22,9 @@
      }
    ],
    pageList: [
      {
        url: "/res/icons/notice_3.png"
      },
      {
        url: "/res/icons/notice_1.png"
      },
      {
        url: "/res/icons/notice_2.png"
      },
      [],
      [],
      []
    ]
  },
@@ -66,5 +64,36 @@
   */
  onLoad: function (options) {
    this.tabsHeight('.page0');
    this.getNotice()
  },
  onReachBottom () {
    if (this.cPage && this.tPage) {
      if (this.cPage < this.tPage) {
        this.getNotice(this.cPage + 1)
      }
    }
  },
  getNotice(cPage = 1) {
    var that = this
    notificationservice.getNotification(app.globalData.accessToken.userId, cPage, {
      onHead(header) {
        that.cPage = parseInt(header.currentPage)
        that.tPage = parseInt(header.totalPage)
        console.log(`cPage:${that.cPage}, tPage:${that.tPage}`);
      },
      success(res) {
        res.forEach(r => {
          r.updateTime = util.formatTime(r.updateTime)
        });
        let notices = that.data.pageList[0].concat(res)
        that.setData({
          ['pageList[0]']: notices
        })
        that.tabsHeight('.page0');   //刷新高度
      }
    }, 5)
  },
})