<template>
    <text class="time">{{ showTime }}</text>
</template>

<script>
export default {
    name: "timer",
    data() {
        return {
            showTime: "00:00:00",
            count: null,
            scale: 60
        }
    },
    methods: {
        startCounting() {
            let time = this.showTime.split(":");
            this.count = setInterval(() => {
                if (time[2] == this.scale) {
                    if (time[1] == this.scale) {
                        time[0] = time[0] - 0 + 1;
                        time[1] = '00';
                    } else {
                        time[1] = time[1] - 0 + 1;
                    }
                    time[2] = '00';
                } else {
                    time[2] = time[2] - 0 + 1;
                }
                this.showTime = time.map(v => v != '00' && v < 10 ? '0' + v : v).join(":")
            }, 1000);
        },
        endTiming() {
            clearInterval(this.count);
            return this.showTime;
        },
        getTime(){
            return this.showTime;

        }
    },
}
</script>

<style lang="scss"></style>