riku
2026-01-19 068be2757aa2d51e3f6604dae54287683160ad0e
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import {
  parseLedgerStat,
  parseSelfPatrol,
  refreshLedgerStatus,
} from '../../../model/ledger';
import { useTab } from './tab.js';
import { useSummary } from './summary.js';
import { useToolbar } from './toolbar.js';
import { useList } from './list.js';
const ledgerservice = require('../../../service/ledgerservice');
const moment = require('../../../utils/moment.min');
const app = getApp();
 
const userId = '4qBbkYqaOnfg7eXO';
const sceneType = '9';
 
Page({
  //每月台账提交期限日
  DEADLINEDAY: app.globalData.userSetting.ledgerDeadline,
  behaviors: [useTab, useSummary, useToolbar, useList],
  data: {
    tabList: [],
    pageList: [],
    thisMonthInfo: {},
    lastMonthInfo: {},
  },
  onLoad(options) {
    let now = moment();
    let limitTime = moment().date(this.DEADLINEDAY);
    //如果是新注册用户不到一个月,则不提醒本月情况,直接提醒下个月的情况
    if (app.globalData.newUser) {
      limitTime.add(1, 'M');
    }
    let deadline = limitTime.format(`MM-${this.DEADLINEDAY}`);
    let leftday = limitTime.diff(now, 'days');
    let thisMonth = now.format('YYYY-MM');
    let lastMonth = now.add(-1, 'M').format('YYYY-MM');
    this.setData({
      deadline,
      leftday,
      thisMonth,
      lastMonth,
    });
 
    now = moment();
    //本月
    this.getLedgerType(now.format('YYYY-MM-DD'), r => {
      this.setData({
        tabList: r.types,
        pageList: r.items,
        thisMonthInfo: r.monthInfo,
      });
      this.handleSort();
    });
    //上月
    this.getLedgerType(now.add(-1, 'M').format('YYYY-MM-DD'), r => {
      this.setData({
        lastMonthInfo: r.monthInfo,
      });
    });
  },
  getLedgerType(time, success, lastMonth) {
    ledgerservice.getLedgerSummary(
      app.globalData.accessToken.userId,
      app.globalData.userInfo.extension2,
      // userId, sceneType,
      time,
      {
        success: res => {
          success(parseLedgerStat(res, lastMonth));
        },
      },
    );
  },
  gotoLedgerDetail(e) {
    var indexGroup = e.currentTarget.dataset.index;
    // var indexGroup = [parseInt(i[0]), parseInt(i[1])];
    var ledger = this.data.pageList[indexGroup[0]][indexGroup[1]];
 
    var that = this;
    wx.navigateTo({
      url: '/pages/mLedger/ledgerupload/ledgerupload',
      events: {
        uploadOver: function (data) {
          let i = data.indexGroup;
          let { pageList, tabList } = that.data;
          tabList[i[0]].tag--;
          pageList[i[0]][i[1]].upLoad = true;
          pageList[i[0]][i[1]].tag = '/res/icons/round_check_fill.png';
          pageList[i[0]][i[1]].opacity = 0.7;
          that.setData({
            pageList,
            tabList,
          });
        },
      },
      success: res => {
        // 通过 eventChannel 向被打开页面传送数据
        res.eventChannel.emit('acceptDataFromOpenerPage', {
          ledger: ledger,
          indexGroup: indexGroup,
          type: 0,
        });
      },
    });
  },
});