riku
2022-08-23 8fbd6b8d09e70494d920cc0b77812e9643be3196
pages/promise/promise.js
@@ -16,7 +16,7 @@
    promise: [{
      period: '承诺周期:2021年1月~2021年12月',
      time: '2021年1月6日完成',
      picPath: '',
      picPath: [],
      pdfPath: ''
    }],
    deadline: "承诺截止时间:----年--月--日",
@@ -29,13 +29,14 @@
   */
  onLoad: function (options) {
    this._initPlanYear()
    // this.getCommitment()
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    console.log("promise: onshow");
    this.getCommitment()
  },
@@ -59,18 +60,24 @@
  checkStatus() {
    if (this.promiseHistory.length > 0) {
      var first = this.promiseHistory[0]
      var firstYear = moment(first.cmCreateTime).year()
      if (firstYear >= this.data.year) {
        var deadline = moment().add(1, 'years').endOf('year').format("YYYY年MM月DD日")
      var cTime = moment(first.cmCreateTime)
      let leftDays = cTime.add(1, 'years').diff(moment(), 'days')
      // that.setData({
      //   promsieInfo: {
      //     leftDays: leftDays
      //   }
      // })
      if (leftDays > 0) {
        var deadline = cTime.format("YYYY-MM-DD")
        this.setData({
          text1: "很棒!本次承诺已完成",
          text1: "本次承诺已完成",
          text3: "查看承诺",
          status: 1,
          deadline: `下次承诺时间:${deadline}`
          deadline: `承诺有效时间:剩余${leftDays}天`
        })
      } else {
        this.setData({
          text1: "已开启!请及时完成承诺",
          text1: "请及时完成承诺",
          text3: "去承诺",
          status: 0,
        })