Commit c3fdb02e by chenwq

众筹

1 parent 6d982563
...@@ -55,83 +55,23 @@ export default { ...@@ -55,83 +55,23 @@ export default {
name: 'crowdEditWechat', name: 'crowdEditWechat',
data() { data() {
return { return {}
// 倒计时
countDownObj: {
typeTxt: '距离活动开始',
activityStatus: 1,
d: '',
h: '',
m: '',
s: ''
},
}
}, },
props: { props: {
editForm: { editForm: {
type: Object, type: Object,
default: () => { } default: () => { }
},
countDownObj: {
type: Object,
default: () => { }
} }
}, },
mounted() { }, mounted() { },
methods: { methods: {}
findCountDownTime() {
let startTime = new Date(this.editForm.activityTime[0])
let endTime = new Date(this.editForm.activityTime[1])
let currentTime = new Date()
// activityStatus 1:未开始,2进行中,3已结束
let activityStatus = currentTime < startTime ? 1 : endTime < currentTime ? 2 : 3
return {
activityStatus,
startTime: activityStatus == 1 ? currentTime : activityStatus == 2 ? currentTime : endTime,
endTime: activityStatus == 1 ? startTime : activityStatus == 2 ? endTime : endTime
}
},
countDown() {
if (this.editForm.activityTime && this.editForm.activityTime.length) {
let { activityStatus, startTime, endTime } = this.findCountDownTime()
let lefttime = parseInt((endTime.getTime() - startTime.getTime()) / 1000)
let d = parseInt(lefttime / (24 * 60 * 60))
let h = parseInt((lefttime / (60 * 60)) % 24)
let m = parseInt((lefttime / 60) % 60)
let s = parseInt(lefttime % 60)
h = this.addZero(h)
m = this.addZero(m)
s = this.addZero(s)
let typeTxt = {
1: '距离活动开始',
2: '距离活动结束',
3: '活动倒计时'
}[activityStatus]
if (this.time) clearTimeout(this.time)
this.time = setTimeout(() => {
if (d > 0) d = this.addZero(d)
this.countDownObj = {
typeTxt: typeTxt,
d: d,
h: h,
m: m,
s: s
}
this.countDown()
}, 1 * 1000)
} else {
this.countDownObj = {
typeTxt: '距离活动开始',
d: '',
h: '',
m: '',
s: ''
}
}
}
}
} }
</script> </script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!