<template>
  <div class="time">
    <div class="timeHMS">{{ hourMinuteSecond }}</div>
    <div class="timeYMD">{{ yearMonthDay }}</div>
<!--    <div class="timeWeek">{{ week }}</div>-->

  </div>
</template>

<script>
import {HttpResetClass} from "vue-client";
import '../../../../static/fonts/font.css'

export default {
  name: "Time",
  data(){
    return{
      nextTime:"",
      hourMinuteSecond:"",
      yearMonthDay:"",
      week:"",
    }
  },
  ready(){
    this.showTime()
    // this.getInitData()
  },
  methods:{
    getInitData(){
      let http = new HttpResetClass()
      http.load('post','api/af-revenue/sql/getCallSumData',{}).then((res)=>{
        console.log("===========",res.data)
        // this.data = res.data[0]
      })
    },
    showTime() {
      this.interval = setInterval(() => {
        //開始运行
        this.nextTime = ''
        let dt = new Date();
        let weekList=new Array('日','一','二','三','四','五','六',);
        let y = dt.getFullYear();
        let mt = dt.getMonth() + 1;
        let day = dt.getDate();
        let h = dt.getHours(); //获取时
        let m = dt.getMinutes(); //获取分
        let s = dt.getSeconds(); //获取秒
        let week=dt.getDay();
        let weekStr=weekList[week];
        //时分秒<10前面拼接0
        h = this.check(h);
        m = this.check(m);
        s = this.check(s);
        // this.nextTime = h + ":" + m + ":" + s + "   " + y + "/" + mt + "/" + day + "星期"+ weekStr;
        this.hourMinuteSecond = h + ":" + m + ":" + s;
        this.yearMonthDay = y + "-" + mt + "-" + day+"星期"+ weekStr;
        // this.week="星期"+ weekStr;

      }, 1000); //设定定时器，循环运行
    },
    //检查时分秒如果<10前面拼接0
    check(i){
      let num;
      i<10?num="0"+i:num=i;
      return num;
    },
  }
}
</script>

<style scoped>
.time {
  width: 17.625vw;
  height: 5.222vh;
  position: absolute;
  top: -1.389vh;
  right: 0.365vw;
  display: flex;
  font-family: alhy;
  justify-content: space-around;
}
.timeHMS{
  width: 6vw;
  height: 5.037vh;
  font-size: 2.315vh;
  font-weight: 400;
  color: #C3DEFF;
  line-height: 8.796vh;
}
.timeYMD {
  width: 10vw;
  height: 5.574vh;
  font-size: 1.667vh;
  font-weight: 400;
  color: #C3DEFF;
  line-height: 8.796vh;
  opacity: 0.7;
}
.timeWeek{}
</style>
