对象数组中间隔天数显示标记

119 阅读1分钟

let date = new Date()let today = `${date.getFullYear()}-${(date.getMonth() + 1) <= 9 ? 0 : ''}${(date.getMonth() + 1)}-${date.getDate() <= 9 ? 0 : ''}${date.getDate()}`    setTimeFrame (list) {      let initialValue      if (this.customersList.length) { // 初始化值设置,佣金列表有数据取最后一个数据的时间,没有数据取单天时间        initialValue = this.customersList[this.customersList.length - 1].create_time.substring(0, 10)      } else {        initialValue = today      }      list.reduce((accumulator, currentValue) => {        let currentTime = currentValue.create_time.substring(0, 10)        if (currentTime !== accumulator) {          currentValue.timeFrame = currentTime        }        return currentTime      }, initialValue)      if (!this.customersList.length) {        if (list[0].create_time.substring(0, 10) === initialValue) { list[0].timeFrame = '今天' }      }    },