Files
crm-uni/components/Countdown/Countdown.vue
T
浅念 5e8e44f88f Squashed commit of the following:
commit f9e9899e0e
Author: 浅念 <email@sample.com>
Date:   Fri Mar 28 11:10:56 2025 +0800

    设置默认语言为英语

commit 303121ba81
Author: 浅念 <email@sample.com>
Date:   Fri Mar 28 11:00:05 2025 +0800

    调用接口调整

commit 37e0e55d96
Author: 浅念 <email@sample.com>
Date:   Fri Mar 28 10:33:48 2025 +0800

    线上接口地址

commit 11dd7de521
Author: 浅念 <email@sample.com>
Date:   Thu Mar 27 16:54:52 2025 +0800

    修改样式

commit 8ceb98b321
Author: 浅念 <email@sample.com>
Date:   Thu Mar 27 16:47:04 2025 +0800

    隐藏我的名片

commit f58e712684
Author: 浅念 <email@sample.com>
Date:   Thu Mar 27 16:44:43 2025 +0800

    样式调整

commit 54ad6c9e37
Author: 浅念 <email@sample.com>
Date:   Thu Mar 27 16:35:21 2025 +0800

    修改语言包

commit 526f934a75
Author: 浅念 <email@sample.com>
Date:   Thu Mar 27 16:13:47 2025 +0800

    标签功能

commit 8583ff2543
Author: 浅念 <email@sample.com>
Date:   Wed Mar 26 17:02:04 2025 +0800

    标签管理页面

commit be8674fd51
Author: 浅念 <email@sample.com>
Date:   Tue Mar 25 17:29:37 2025 +0800

    样式调整

commit a5d5ce4e7c
Author: 浅念 <email@sample.com>
Date:   Tue Mar 25 17:23:40 2025 +0800

    倒计时组件

commit f88048b876
Author: 浅念 <email@sample.com>
Date:   Tue Mar 25 17:19:43 2025 +0800

    首页添加跟进提醒

commit f9a39d5aaa
Author: 浅念 <email@sample.com>
Date:   Tue Mar 25 13:13:39 2025 +0800

    提交

commit e3abe0bf18
Author: 浅念 <email@sample.com>
Date:   Tue Mar 25 13:12:24 2025 +0800

    名片部分页面。地图定位。国家下拉搜索  回收站
2025-03-28 14:46:49 +08:00

104 lines
2.1 KiB
Vue

<template>
<view class="countdown">
<view class="time green" v-if="!isend">
<image src="/static/image/gtime.png" mode=""></image>
<text v-if="showDays && timeObj.days > 0" >{{ timeObj.days }}{{$t('day')}} </text>
<text> {{ timeObj.hours | padZero }} : </text>
<text> {{ timeObj.minutes | padZero }} : </text>
<text> {{ timeObj.seconds | padZero }}</text>
</view>
<view class="time timered" v-else>
<image src="/static/image/redtime.png" mode=""></image>
<text>{{$t('timeout')}}</text>
</view>
</view>
</template>
<script>
export default {
props: {
// 倒计时总秒数
totalSeconds: {
type: Number,
required: true
},
// 是否显示天数
showDays: {
type: Boolean,
default: true
}
},
data() {
return {
timeObj: {
days: 0,
hours: 0,
minutes: 0,
seconds: 0
},
isend:false,
timer: null,
totalSeconds1:this.totalSeconds
}
},
filters: {
padZero(value) {
return value.toString().padStart(2, '0');
}
},
mounted() {
if(this.totalSeconds>0){
this.runCountdown();
}else{
this.isend=true
}
},
methods: {
runCountdown() {
this.updateTime(this.totalSeconds1);
this.timer = setInterval(() => {
if (this.totalSeconds1 <= 0) {
clearInterval(this.timer);
this.isend=true
this.$emit('end');
return;
}
this.totalSeconds1--;
this.updateTime(this.totalSeconds1);
}, 1000);
},
updateTime(seconds) {
this.timeObj.days = Math.floor(seconds / (24 * 3600));
const remaining = seconds % (24 * 3600);
this.timeObj.hours = Math.floor(remaining / 3600);
this.timeObj.minutes = Math.floor((remaining % 3600) / 60);
this.timeObj.seconds = remaining % 60;
}
},
beforeDestroy() {
clearInterval(this.timer);
}
}
</script>
<style lang="scss">
.countdown{
.time{
display: flex;
align-items: center;
text{
margin: 0px 2px;
}
}
image{
width: 18px;
height: 18px;
margin-right: 5px;
}
}
.green{
color: #27C89C;
}
.timered{
color: #FF4040;
}
</style>