<template>
  <div id="the-header" class="the-header">
    <div class="the-header-left">
        <img src="../assets/logo3.png" alt="">
    </div>

    <div class="center-title">哈尔滨市托育综合服务中心建设项目</div>

    <div class="timers">
      {{ dateYear }} {{ dateWeek }} {{ dateDay }}
    </div>
  </div>
</template>

<script>
import { formatTime } from "@/utils/index.js";

export default {
	name: 'TheHeader',

	data() {
		return {
			timing: null,
			dateDay: null,
			dateYear: null,
			dateWeek: null,
			weekday: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
		}
	},

	methods: {
		timeFn() {
			this.timing = setInterval(() => {
				this.dateDay = formatTime(new Date(), "HH: mm: ss");
				this.dateYear = formatTime(new Date(), "yyyy-MM-dd");
				this.dateWeek = this.weekday[new Date().getDay()];
			}, 1000);
		},

		changeProject() {
			console.log(this.value);
			this.$emit('handleChangeProject', this.value);
		}
	},

	mounted() {
		this.timeFn()
		this.value = this.defaultValue
	},

	beforeDestroy() {
		clearInterval(this.timing);
	}
}
</script>

<style lang="scss">
.the-header {
  position: relative;
  width: 100%;
  height: px2rem(78);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: url(../assets/image/title.png) no-repeat;
  background-size: 100% 100%;
  background-position: center;

  .the-header-left {
    display: flex;
    align-items: center;

    font-size: px2rem(18);
    font-weight: bold;
    height: 100%;

    position: absolute;
    left: 2%;
    padding: px2rem(12) 0;
    img {
      height: 90%;
      margin-right: px2rem(12);
    }
  }

  .center-title {
    position: absolute;
    font-size: px2rem(26);
    font-weight: bold;
    left: 50%;
    transform: translateX(-50%);
    line-height: px2rem(85);
  }

  .timers {
    font-size: px2rem(18);
    font-weight: bold;

    position: absolute;
    right: 2%;
    bottom: px2rem(24);
  }
}
</style>
