修复秒杀界面倒计时显示0的问题

This commit is contained in:
Gao xiaosong
2021-06-20 00:39:16 +08:00
parent d9e537f79e
commit 112b22be69

View File

@ -42,16 +42,16 @@ export default {
default: true, default: true,
}, },
}, },
data: function () { data: function() {
return { return {
time: null, time: this.datatime,
day: '00', day: '00',
hour: '00', hour: '00',
minute: '00', minute: '00',
second: '00', second: '00',
} }
}, },
created: function () { created: function() {
this.show_time() this.show_time()
}, },
watch: { watch: {
@ -61,25 +61,22 @@ export default {
this.show_time() this.show_time()
}, },
}, },
mounted: function () {}, mounted: function() {},
methods: { methods: {
show_time: function () { show_time: function() {
let that = this let that = this
if (this.time.toString().length == 13) {
if (parseInt(this.time).length == 13) {
// 毫秒级 // 毫秒级
console.log('毫秒') console.log('毫秒')
this.time = this.time / 1000 this.time = this.time / 1000
} else if (parseInt(this.time).length == 10) { } else if (this.time.toString().length == 10) {
console.log('秒') console.log('秒')
// 秒级 // 秒级
} else { } else {
// 时间 // 时间
console.log('时间') console.log('时间')
console.log(this.time)
this.time = Date.parse(this.time) / 1000 this.time = Date.parse(this.time) / 1000
} }
console.log(that.time)
function runTime() { function runTime() {
//时间函数 //时间函数