<template>
  <div class="remain-time">剩余时间 {{remainTimeFormatted}}</div>
</template>

<script>
import moment from "moment";

export default {
  name: "RemainTime",
  data() {
    return {
      remainTime: null
    };
  },
  async mounted() {
    const res = await this.$http.get("/api/exam_control/heartbeat");
    this.remainTime = res.data.leftTime;
  },
  computed: {
    remainTimeFormatted: function() {
      return moment.utc(this.remainTime).format("HH:mm:ss");
    }
  }
};
</script>
