From 6c5e45f7c7e4094890474f23c3eb0bccdb79c190 Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Wed, 17 Apr 2024 13:14:29 +0800 Subject: [PATCH] =?UTF-8?q?bug=20fix:=20=E6=97=A5=E5=8E=86=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/home/calenView.vue | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/views/home/calenView.vue b/src/views/home/calenView.vue index cc1a48c..2138184 100644 --- a/src/views/home/calenView.vue +++ b/src/views/home/calenView.vue @@ -44,14 +44,16 @@ export default { methods: { // 初始化日历样式 generateMonth() { - const days = Math.floor((this.activityData.endTime - this.activityData.startTime) /ONE_DAY) + let beginTime = new Date(this.activityData.startTime) + let endTime = new Date(this.activityData.endTime) + let i = 0 const now = getDayBegin(new Date()) - for(let i = 0; i < days; i++ ){ + while(beginTime <= endTime) { let current = i * ONE_DAY + this.activityData.startTime - if(current <= this.activityData.endTime) { - const type = current < now ? -1 : 0 - this.current.push({day: formatDate(new Date(current)), type, time: current, index: i + 1}) - } + beginTime = new Date(current) + const type = current < now ? -1 : 0 + this.current.push({day: formatDate(new Date(current)), type, time: current, index: i + 1}) + i++ } this.getCheckInit() },