Riku
2024-08-13 cf693a5227f17bbf2201512128d267281a8c5695
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
 * 工作提醒通知相关数据接口
 */
 
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 };