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
70
71
72
73
74
75
76
77
78
79
| import sysSchedules from '../../../data/schedules';
| import moment from "../../../utils/moment.min";
|
| Page({
| /**
| * 页面的初始数据
| */
| data: {
| totals: 0,
| schedules: [
| // {
| // category: '2022年9月环保工作日程',
| // details: [
| // {
| // time: '9月10日',
| // name: '环保日程',
| // left: 3,
| // },
| // ],
| // },
| ],
| },
|
| /**
| * 生命周期函数--监听页面加载
| */
| onLoad(options) {
| sysSchedules().then(res => this.parseAllSchedules(res));
| },
|
| parseAllSchedules(allSchedules) {
| const schedules = [];
| let totals = allSchedules.length;
|
| const map = new Map();
| for (let i = 0; i < allSchedules.length; i++) {
| const s = allSchedules[i];
| const _time = moment(s.time)
| const category = `${_time.year()}年${_time.month() + 1}月环保工作日程`
| if (!map.has(category)) {
| map.set(category, []);
| }
| map.get(category).push({
| time: _time.format('MM月DD日'),
| name: s.title,
| left: s.diffDays,
| s: s,
| });
| }
| for (let item of map) {
| schedules.push({
| category: item[0],
| details: item[1],
| });
| }
| this.setData({
| schedules,
| totals,
| });
| },
|
| goto(e) {
| const index = e.currentTarget.dataset.index;
| const s = this.data.schedules[index[0]].details[index[1]].s;
| // const _s = {
| // time: s.time.format('YYYY-MM-DD dddd'),
| // events: s.events,
| // diffDays: s.diffDays,
| // steps: s.steps,
| // category: s.category,
| // };
| wx.navigateTo({
| url: '/pages/mService/pScheduledetail/pScheduledetail',
| success: res => {
| res.eventChannel.emit('acceptDataFromOpenerPage', s);
| },
| });
| },
| });
|
|