|
|
<template>
|
|
|
<div class="count-down-wrapper">
|
|
|
<span></span>
|
|
|
<div class="count-down-wrapper" v-if="countDown !== ''">
|
|
|
<i class="time-icon"></i>
|
|
|
<span>{{ countDown }}</span>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
...
|
...
|
@@ -14,29 +15,33 @@ export default { |
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
remainTime: this.props.leftTime,
|
|
|
remainTime: this.$props.leftTime,
|
|
|
countDown: "",
|
|
|
timeoutId: null
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
this.countDown = this.formatTime();
|
|
|
this.countDown = this.formatTime().join(":");
|
|
|
|
|
|
this.timeoutId = setInterval(() => {
|
|
|
this.remainTime--;
|
|
|
this.countDown = this.formatTime();
|
|
|
this.countDown = this.formatTime().join(":");
|
|
|
}, 1000);
|
|
|
},
|
|
|
destroyed() {
|
|
|
clearInterval(this.timeoutId);
|
|
|
},
|
|
|
computed: {
|
|
|
timeList: function() {}
|
|
|
watch: {
|
|
|
countDown(val) {
|
|
|
if (val === "") {
|
|
|
clearInterval(this.timeoutId);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
formatTime() {
|
|
|
if (this.remainTime < 0) {
|
|
|
return ["00", "00", "00"];
|
|
|
if (this.remainTime <= 0) {
|
|
|
return [];
|
|
|
}
|
|
|
let remainTime = this.remainTime;
|
|
|
|
...
|
...
|
@@ -49,7 +54,7 @@ export default { |
|
|
|
|
|
const numberOfSeconds = remainTime - numberOfMinutes * 60;
|
|
|
|
|
|
return [numberOfHour, numberOfMinute, numberOfSeconds].map(time => {
|
|
|
return [numberOfHours, numberOfMinutes, numberOfSeconds].map(time => {
|
|
|
return time < 10 ? `0${time}` : `${time}`;
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -60,5 +65,21 @@ export default { |
|
|
<style lang="scss" scoped>
|
|
|
.count-down-wrapper {
|
|
|
display: flex;
|
|
|
font-size: 32px;
|
|
|
font-weight: bold;
|
|
|
align-items: center;
|
|
|
|
|
|
& > i {
|
|
|
width: 30px;
|
|
|
height: 30px;
|
|
|
display: block;
|
|
|
background: url("~statics/image/order/time-icon@3x.png");
|
|
|
background-size: contain;
|
|
|
background-position: center;
|
|
|
}
|
|
|
|
|
|
& > span {
|
|
|
padding: 0 9px;
|
|
|
}
|
|
|
}
|
|
|
</style> |
|
|
\ No newline at end of file |
...
|
...
|
|