Files
lucky_shop/pages_promotion/components/l-time/l-time.vue
2025-10-27 15:55:29 +08:00

57 lines
971 B
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<text>{{ temp }}</text>
</template>
<script>
import _time_ from './time.js';
export default {
name: 'l-time',
props: {
//日期字符串
text: {
type: [String, Number, Date],
default: ''
},
//是否显示大于当前时间日期默认false大于显示刚刚
maxDate: {
type: Boolean,
default: false
}
},
data() {
return {
textVal: this.text
};
},
watch: {
text() {
this.textVal = this.text;
}
},
computed: {
temp() {
return this.getText();
}
},
methods: {
getText() {
let self = this;
let timeVal = _time_.getFormatTime(self.textVal, self.maxDate);
if (timeVal && (timeVal.endsWith('刚刚') || timeVal.endsWith('分钟前'))) {
setTimeout(() => {
let temp = self.textVal;
self.textVal = '';
self.textVal = temp;
}, 60000);
}
return this.textVal ? timeVal : '';
},
onClick() {
this.$emit('on-tap', this.textVal);
}
}
};
</script>
<style></style>