<template>
  <div>
    <div class="date row item-center pdg20">
      <div class="row datebox scroll">
        <p v-for="(item,index) in date" :key="index">{{item.title}}</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      date: [{ id: "today", title: "今日" }]
    };
  },
  methods: {
    fun_date() {
      let date = new Date();
      let MonthNum = 0;
      let lastMonth = new Date(
        date.getFullYear(),
        date.getMonth() + 1,
        0
      ).getDate();
      for (let i = 1; i < 7; i++) {
        let years = date.getFullYear();
        let month = date.getMonth() + 1;
        let day =
          date.getDate() + i < 10
            ? "0" + (date.getDate() + i)
            : date.getDate() + i;
        if (date.getDate() + i > lastMonth) {
          MonthNum++;
          month = date.getMonth() + 2;
          day = "0" + MonthNum;
        }

        let str = "";
        let week = date.getDay() + i;
        if (week == 7) {
          str = "周日";
        } else if (week == 1) {
          str = "周一";
        } else if (week == 2) {
          str = "周二";
        } else if (week == 3) {
          str = "周三";
        } else if (week == 4) {
          str = "周四";
        } else if (week == 5) {
          str = "周五";
        } else if (week == 6) {
          str = "周六";
        }
        // if (i == 1) {
        //   this.date.push({ id: "morning", title: "早盘" });
        // }
        let time = {};
        time.id = years + "-" + month + "-" + day;
        time.title = str + month + "月" + day + "日";
        this.date.push(time);
      }
      // console.log(this.date);
    }
  },
  created() {
    this.fun_date();
  }
};
</script>

<style scoped>
</style>