<template>
  <div class="token-timing">
    <span>{{ title }}</span>
  </div>
</template>
<script >
import { timeDiff } from "@/utils/hciot";
export default {
  name: "ETiming",
  data() {
    return {
      title: "",
    };
  },
  props: {
    startTime: {
      type: String,
    },
    endTime: {
      type: String,
    },
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      let startTime = new Date(this.startTime).getTime();
      let endTime = new Date(this.endTime).getTime();
      let timeArr = timeDiff(startTime, endTime);
      let titleText = `${timeArr[0] > 0 ? timeArr[0] + "天" : ""} ${
        timeArr[1] > 0 ? timeArr[1] + "时" : ""
      } ${timeArr[2] > 0 ? timeArr[2] + "分" : ""} ${
        timeArr[3] > 0 ? timeArr[3] + "秒" : ""
      } `;
      this.title = titleText;
    },
  },
};
</script>

