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
| // pages/m_service/p_schedule/p_schedule.js
| import b_scheduleManager from '../behaviors/b_scheduleManager'
| const moment = require('../../../utils/moment.min')
|
| Page({
| behaviors: [b_scheduleManager],
| /**
| * 页面的初始数据
| */
| data: {
| totals: 0,
| schedules: [{
| category: '2022年9月环保工作日程',
| details: [{
| time: '9月10日',
| name: '环保日程',
| left: 3,
| }]
| }]
| },
|
| /**
| * 生命周期函数--监听页面加载
| */
| onLoad(options) {
| // const now = moment().hour(0).minute(0).second(0).millisecond(0)
| // const year = now.year()
| const schedules = []
| let totals = this.data.allSchedules.length
|
| const map = new Map()
| for (let i = 0; i < this.data.allSchedules.length; i++) {
| const s = this.data.allSchedules[i];
| s.events.forEach(e => {
| if (!map.has(e.category)) {
| map.set(e.category, [])
| }
| map.get(e.category).push({
| time: s.time.format('MM月DD日'),
| name: e.name,
| left: s.diffDays,
| })
| });
| }
| for (let item of map) {
| schedules.push({
| category: item[0],
| details: item[1]
| })
| }
| this.setData({
| schedules,
| totals
| })
| },
|
| goto() {
| var that = this
| wx.navigateTo({
| url: '/pages/m_service/p_scheduledetail/p_scheduledetail',
| success: (res) => {
| res.eventChannel.emit('acceptDataFromOpenerPage', that.data.thisSchedule)
| },
| })
| }
| })
|
|