flyx/components/xw-CountDown2/index - 副本.vue
2024-07-07 16:19:19 +08:00

97 lines
1.5 KiB
Vue

<template>
<view class="time" :style="justifyLeft">
<text class="styleAll">{{ intDiff }}</text>
</view>
</template>
<script>
export default {
name: "countDown",
props: {
justifyLeft: {
type: String,
default: ""
},
//距离开始提示文字
tipText: {
type: String,
default: "倒计时"
},
dayText: {
type: String,
default: "天"
},
hourText: {
type: String,
default: "时"
},
minuteText: {
type: String,
default: "分"
},
secondText: {
type: String,
default: "秒"
},
datatime: {
type: Number,
default: 0
},
isDay: {
type: Boolean,
default: true
},
ishour: {
type: Boolean,
default: true
}
},
data: function() {
return {
day: "00",
hour: "00",
minute: "00",
second: "00",
intDiff: 0
};
},
created: function() {
this.$nextTick(() => {
this.show_time();
})
},
mounted: function() {},
methods: {
show_time: function() {
let that = this;
function runTime() {
//时间函数
that.intDiff = that.datatime - Date.parse(new Date()) / 1000; //获取数据中的时间戳的时间差;
if (that.intDiff <= 0) {
that.$emit('change', {
's': that.intDiff
})
}
}
runTime();
setInterval(runTime, 1000);
}
}
};
</script>
<style>
.time {
display: flex;
justify-content: center;
color: #fff;
}
.red {
/* color: #fc4141; */
margin: 0 4rpx;
}
</style>