import Api from "../../model/api"; import {formatTime, getEventParam} from "../../utils/utils"; import {logicStatus} from "../../model/enum"; const app = getApp(); app.Base({ data: { tabList: [ {key: logicStatus.NO, label: '未读', background: 'card-bg-unread',}, {key: logicStatus.YES, label: '已读', background: 'card-bg-read',}, ], active: 0, status: 0, background: 'card-bg-unread', }, onLoad: function (options) { }, onChange(e) { const name = getEventParam(e, 'name'); const index = getEventParam(e, 'index'); const background = this.data.tabList[index].background; this.setData({ active: index, status: name, background }, async () => { this.changeResetData(this); }) }, async requestData() { const res = await Api.getStudentNoticeList({ status: this.data.status, pageNum: this.pageNum, pageSize: this.pageSize }); res.data.rows = res.data.rows.map(item => { return { content: item.noticeContent || '', time: formatTime(item.createTime), id: item.id, status: this.data.status, } }); return res; }, async noticeRead(e) { const id = getEventParam(e, "id") const res = await Api.changeNoticeStatus({status: logicStatus.YES, id}, true); wx.showToast({ title: res.msg }) await this.resetData(this); }, });