notice.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import Api from "../../model/api";
  2. import {formatTime, getEventParam} from "../../utils/utils";
  3. import {logicStatus} from "../../model/enum";
  4. const app = getApp();
  5. app.Base({
  6. data: {
  7. tabList: [
  8. {key: logicStatus.NO, label: '未读', background: 'card-bg-unread',},
  9. {key: logicStatus.YES, label: '已读', background: 'card-bg-read',},
  10. ],
  11. active: 0,
  12. status: 0,
  13. background: 'card-bg-unread',
  14. },
  15. onLoad: function (options) {
  16. },
  17. onChange(e) {
  18. const name = getEventParam(e, 'name');
  19. const index = getEventParam(e, 'index');
  20. const background = this.data.tabList[index].background;
  21. this.setData({
  22. active: index,
  23. status: name,
  24. background
  25. }, async () => {
  26. this.changeResetData(this);
  27. })
  28. },
  29. async requestData() {
  30. const res = await Api.getStudentNoticeList({
  31. status: this.data.status,
  32. pageNum: this.pageNum,
  33. pageSize: this.pageSize
  34. });
  35. res.data.rows = res.data.rows.map(item => {
  36. return {
  37. content: item.noticeContent || '',
  38. time: formatTime(item.createTime),
  39. id: item.id,
  40. status: this.data.status,
  41. }
  42. });
  43. return res;
  44. },
  45. async noticeRead(e) {
  46. const id = getEventParam(e, "id")
  47. const res = await Api.changeNoticeStatus({status: logicStatus.YES, id}, true);
  48. wx.showToast({
  49. title: res.msg
  50. })
  51. await this.resetData(this);
  52. },
  53. });