From 365a01f5e87fa5952114de2e991c8bb6d585d0b0 Mon Sep 17 00:00:00 2001 From: H1d3rOne Date: Tue, 10 Mar 2026 04:59:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=AD=BE=E5=88=B0=E4=B8=AD=E6=96=AD?= =?UTF-8?q?=E6=88=96=E8=B6=85=E8=BF=877=E5=A4=A9=E9=87=8D=E7=BD=AE?= =?UTF-8?q?=E4=B8=BA=E7=AC=AC1=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 签到中断时重置连续签到天数为1 - 连续签到超过7天时重置为第1天 - 优化签到进度显示逻辑 --- xuan-deduct-uniapp/src/pages/mine/coins.vue | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/xuan-deduct-uniapp/src/pages/mine/coins.vue b/xuan-deduct-uniapp/src/pages/mine/coins.vue index 8de9df8..cfed6a0 100644 --- a/xuan-deduct-uniapp/src/pages/mine/coins.vue +++ b/xuan-deduct-uniapp/src/pages/mine/coins.vue @@ -115,10 +115,10 @@ export default { }, computed: { todayReward() { - return this.getDayReward(this.streakDays % 7) + return this.getDayReward((this.streakDays - 1) % 7) }, currentStreak() { - return this.streakDays % 7 || (this.streakDays > 0 ? 7 : 0) + return this.streakDays } }, onShow() { @@ -167,8 +167,14 @@ export default { this.weekDays = [] for (let i = 0; i < 7; i++) { + // 计算每个位置对应的日期 + // 第1个位置是签到开始的那天,第7个位置是签到的第7天 const date = new Date(today) - date.setDate(today.getDate() - (this.currentStreak - 1 - i)) + // 从今天往前推 (currentStreak - 1 - i) 天 + // 如果 currentStreak = 3,则第1个位置是今天-2天,第2个位置是今天-1天,第3个位置是今天 + // 第4-7个位置是今天+1到+4天 + const offset = i - (this.currentStreak - 1) + date.setDate(today.getDate() + offset) this.weekDays.push({ label: weekLabels[date.getDay()], @@ -190,9 +196,15 @@ export default { yesterday.setDate(today.getDate() - 1) const yesterdayStr = this.formatDate(yesterday) + // 判断是否连续签到 if (lastSignInStr === yesterdayStr) { this.streakDays++ + // 超过7天,重置为第1天 + if (this.streakDays > 7) { + this.streakDays = 1 + } } else { + // 签到中断,重置为第1天 this.streakDays = 1 }