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() },