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

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

@@ -7129,6 +7129,68 @@
} }
] ]
}, },
{
"_$id": "ybbojil0",
"_$type": "Box",
"name": "btn_left",
"x": 11,
"y": 492,
"width": 48,
"height": 96,
"_mouseState": 2,
"centerX": -505,
"_$comp": [
{
"_$type": "a541bdfc-e8e1-4795-b68e-7138c5190f17",
"scriptPath": "../src/views/common/CommonHover.ts",
"hoverAlpha": true
}
],
"_$child": [
{
"_$id": "wmm7xhim",
"_$type": "Image",
"name": "Image",
"width": 48,
"height": 97,
"mouseThrough": true,
"skin": "res://535f9c82-7994-4fd9-a6b5-e7d08199cd4f",
"useSourceSize": true,
"color": "#748290"
}
]
},
{
"_$id": "rp3gmpnp",
"_$type": "Box",
"name": "btn_right",
"x": 1021,
"y": 492,
"width": 48,
"height": 96,
"_mouseState": 2,
"centerX": 505,
"_$comp": [
{
"_$type": "a541bdfc-e8e1-4795-b68e-7138c5190f17",
"scriptPath": "../src/views/common/CommonHover.ts",
"hoverAlpha": true
}
],
"_$child": [
{
"_$id": "hxt6cgnk",
"_$type": "Image",
"name": "Image",
"width": 48,
"height": 97,
"mouseThrough": true,
"skin": "res://25320e1c-b60c-45af-9122-cdc433872fa7",
"useSourceSize": true,
"color": "#748290"
}
]
},
{ {
"_$id": "waobo8h4", "_$id": "waobo8h4",
"_$type": "Box", "_$type": "Box",
@@ -7181,66 +7243,6 @@
"valign": "middle", "valign": "middle",
"padding": "0,0,0,0" "padding": "0,0,0,0"
}, },
{
"_$id": "ybbojil0",
"_$type": "Box",
"name": "btn_left",
"x": -61,
"y": -490,
"width": 48,
"height": 96,
"_mouseState": 2,
"_$comp": [
{
"_$type": "a541bdfc-e8e1-4795-b68e-7138c5190f17",
"scriptPath": "../src/views/common/CommonHover.ts",
"hoverAlpha": true
}
],
"_$child": [
{
"_$id": "wmm7xhim",
"_$type": "Image",
"name": "Image",
"width": 48,
"height": 97,
"mouseThrough": true,
"skin": "res://535f9c82-7994-4fd9-a6b5-e7d08199cd4f",
"useSourceSize": true,
"color": "#5b86b1"
}
]
},
{
"_$id": "rp3gmpnp",
"_$type": "Box",
"name": "btn_right",
"x": 951,
"y": -490,
"width": 48,
"height": 96,
"_mouseState": 2,
"_$comp": [
{
"_$type": "a541bdfc-e8e1-4795-b68e-7138c5190f17",
"scriptPath": "../src/views/common/CommonHover.ts",
"hoverAlpha": true
}
],
"_$child": [
{
"_$id": "hxt6cgnk",
"_$type": "Image",
"name": "Image",
"width": 48,
"height": 97,
"mouseThrough": true,
"skin": "res://25320e1c-b60c-45af-9122-cdc433872fa7",
"useSourceSize": true,
"color": "#5b86b1"
}
]
},
{ {
"_$id": "mv2bgo4b", "_$id": "mv2bgo4b",
"_$type": "HBox", "_$type": "HBox",

View File

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