选中最后一个未完成的日期

This commit is contained in:
2025-06-04 17:36:19 +08:00
parent 4a44f5749e
commit 89b70a288c
2 changed files with 75 additions and 63 deletions

View File

@@ -204,7 +204,8 @@ export class DailyChallenge extends Laya.Script {
this.label_month.text = config.MONTH_FULLNAMES[info.month - 1]
this.label_star.text = `${starCount}/${info.dayCount}`
this.selectedUnit = null
let todayUnit = null
let lastUnfinishUnit = null
let day = 1
for (let i = 0; i < this.units.length; i++) {
const unit = this.units[i]
@@ -237,7 +238,10 @@ export class DailyChallenge extends Laya.Script {
}
unit.setCalendarUnit(info.year, info.month, day, open, progress, this, this.onClickUnit)
if (info.year === nowYear && info.month === nowMonth && day === nowDay) {
this.selectedUnit = unit
todayUnit = unit
}
if (progress < 1) {
lastUnfinishUnit = unit
}
day++
} else {
@@ -245,8 +249,14 @@ export class DailyChallenge extends Laya.Script {
unit.label_show.visible = false
}
}
if (!this.selectedUnit)
if (todayUnit) {
this.selectedUnit = todayUnit
} else {
this.selectedUnit = lastUnfinishUnit
}
if (!this.selectedUnit) {
this.selectedUnit = this.units[info.begin + info.dayCount - 1]
}
this.onApplyUnit(this.selectedUnit)
}