riku
2022-08-05 45b2c022e27dda53ee4e5266fbdbdf1ac3aa4c65
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
// pages/promise/promise.js
const moment = require('../../utils/moment.min')
const app = getApp()
 
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    text1: "已开启!请及时完成承诺",
    text3: "去承诺",
    promise: [{
      period: '承诺周期:2021年1月~2021年12月',
      time: '2021年1月6日完成'
    }, {
      period: '承诺周期:2020年1月~2020年12月',
      time: '2020年1月6日完成'
    }],
    newPromise: [{
      period: '承诺周期:2022年1月~2022年12月',
      time: '2022年5月10日完成'
    },{
      period: '承诺周期:2021年1月~2021年12月',
      time: '2021年1月6日完成'
    }, {
      period: '承诺周期:2020年1月~2020年12月',
      time: '2020年1月6日完成'
    }],
    deadline: "----年--月--日",
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this._initPlanYear()
  },
 
    /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this
    wx.getStorage({
      key: "promise",
      success(res) {
        if(res.data){
          that.setData({
            promise: that.data.newPromise
          })
        }
      }
    })
  },
 
  /**
   * 初始化年份
   */
  _initPlanYear() {
    var now = moment()
    var year = now.year()
    var period = `${now.year()}/${now.month()+1}-${now.month()+1}`
    var deadline = now.endOf('year').format("YYYY年MM月DD日")
    this.setData({
      planYear: `${year}年`,
      maxYear: year,
      thisPeiod: period,
      deadline: deadline
    })
  },
 
  /**
   * 页面跳转
   */
  goto: function (e) {
    var url = ""
    var index = e.currentTarget.dataset.index
    switch (index) {
      case "0":
        //去承诺
        url = `/pages/promiseinfo/promiseinfo`
        break;
      case "1":
        //查看承诺结果
        url = `/pages/promiseresult/promiseresult`
        break;
      case "2":
        //
        url = ""
        return;
      case "3":
        //
        url = ""
        break;
      case "4":
        break;
      case "5":
        break;
    }
    if (url != "") {
      wx.navigateTo({
        url: url
      })
    }
  },
})