/** * 工作提醒通知相关数据接口 */ import { get, post } from '../baseRequset'; import { getNoticeList } from '../../model/notice'; const app = getApp(); //查找通知 function fetchNotice({ page = 1, per_page = 30 }) { return get({ url: `/notifications`, params: { userId: app.globalData.accessToken.userId, page: page, per_page: per_page, }, }).then(res => { res.data = getNoticeList(res.data); return res; }); } // 发布通知 function releaseNotice(notice) { notice.authorId = app.globalData.accessToken.userId; notice.authorName = app.globalData.userInfo.acountname; return post({ url: `/notifications/${notice.authorId}/release2`, data: notice, }).then(res => { return res.data; }); } // 获取通知模板 function fetchNoticeTemplate({ typeId, subTypeId }) { return get({ url: `/notifications/template`, params: { typeId, subTypeId, }, }).then(res => { return res.data; }); } // 更新通知阅读状态 function updateReadState(readState) { return post({ url: `/notifications/${app.globalData.accessToken.userId}/readState`, data: readState, }).then(res => { return res.data; }); } // 获取用户未读通知数量 function fetchUnReadNoticeNum() { return get({ url: `/notifications/${app.globalData.accessToken.userId}/unread`, }).then(res => { return res.data; }); } export { fetchNotice, releaseNotice, fetchNoticeTemplate, updateReadState, fetchUnReadNoticeNum };