fix: check-in
This commit is contained in:
@@ -258,6 +258,7 @@ const weekDays = computed(() => {
|
||||
|
||||
const days = [];
|
||||
const labels = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"];
|
||||
const signedDays = signInfo.value.signedDays || [];
|
||||
|
||||
for (let i = 0; i < 7; i++) {
|
||||
const d = new Date(monday);
|
||||
@@ -271,40 +272,8 @@ const weekDays = computed(() => {
|
||||
const isToday = dateStr === todayStr;
|
||||
const isFuture = dateStr > todayStr;
|
||||
|
||||
if (signInfo.value.continuousDays > 0) {
|
||||
const continuous = signInfo.value.continuousDays;
|
||||
const signedToday = signInfo.value.isSignedToday;
|
||||
|
||||
const streakEndDate = new Date(todayStr);
|
||||
if (!signedToday) {
|
||||
streakEndDate.setDate(streakEndDate.getDate() - 1);
|
||||
}
|
||||
|
||||
const streakStartDate = new Date(streakEndDate);
|
||||
streakStartDate.setDate(streakEndDate.getDate() - continuous + 1);
|
||||
|
||||
const checkDate = new Date(dateStr);
|
||||
const checkTime = checkDate.getTime();
|
||||
// Reset time components to avoid issues
|
||||
const sTime = new Date(
|
||||
streakStartDate.getFullYear(),
|
||||
streakStartDate.getMonth(),
|
||||
streakStartDate.getDate(),
|
||||
).getTime();
|
||||
const eTime = new Date(
|
||||
streakEndDate.getFullYear(),
|
||||
streakEndDate.getMonth(),
|
||||
streakEndDate.getDate(),
|
||||
).getTime();
|
||||
const cTime = new Date(
|
||||
checkDate.getFullYear(),
|
||||
checkDate.getMonth(),
|
||||
checkDate.getDate(),
|
||||
).getTime();
|
||||
|
||||
if (cTime >= sTime && cTime <= eTime) {
|
||||
isSigned = true;
|
||||
}
|
||||
if (signedDays.includes(i + 1)) {
|
||||
isSigned = true;
|
||||
}
|
||||
|
||||
days.push({
|
||||
@@ -444,6 +413,16 @@ const onOpenLucky = async () => {
|
||||
signInfo.value.totalDays = (signInfo.value.totalDays || 0) + 1;
|
||||
}
|
||||
|
||||
// Update signedDays locally
|
||||
if (!signInfo.value.signedDays) {
|
||||
signInfo.value.signedDays = [];
|
||||
}
|
||||
const today = new Date(signInfo.value.today || new Date());
|
||||
const dayIndex = today.getDay() || 7;
|
||||
if (!signInfo.value.signedDays.includes(dayIndex)) {
|
||||
signInfo.value.signedDays.push(dayIndex);
|
||||
}
|
||||
|
||||
// Update user assets (points)
|
||||
userStore.fetchUserAssets();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user