countDownCom.vue
1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<template>
<div class="count-down-com" v-if="time">
<van-count-down class="count-down" :class="'style-' + sty" :time="time" @finish="finish">
<template v-slot="timeData">
<div class="container" v-if="timeData.days > 0 && type != 'h'">
<span class="block transparent">{{ timeData.days }}</span>
<span class="colon">天</span>
</div>
<div class="container">
<span class="block" :class="{'big-block': ((timeData.days * 24) + timeData.hours) >= 100}" v-if="type == 'h'">{{ (timeData.days * 24) + timeData.hours }}</span>
<span class="block" v-else>{{ timeData.hours }}</span>
<span class="colon" v-if="sty == '2' || sty == '5'">时</span>
<span class="colon" v-else>:</span>
<span class="block">{{ timeData.minutes }}</span>
<span class="colon" v-if="sty == '2' || sty == '5'">分</span>
<span class="colon" v-else>:</span>
<span class="block">{{ timeData.seconds }}</span>
<span class="colon" v-if="sty == '2' || sty == '5'">秒</span>
</div>
</template>
</van-count-down>
</div>
</template>
<script>
// 引入组件
import Vue from 'vue';
import { CountDown } from 'vant';
Vue.use(CountDown);
export default {
name: "count-down-com",
data: function () {
return {
}
},
props: ["time", "sty", 'type'],
methods: {
/**
* 倒计时完成事件
*/
finish() {
this.$emit("finish");
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style rel="stylesheet/less" lang="less" scoped>
@import './countDownCom';
</style>