2025-05-20 21:05:30 +08:00
|
|
|
import { config } from "../constants/config";
|
2025-05-21 11:08:50 +08:00
|
|
|
import { respath } from "../constants/respath";
|
2025-05-20 21:05:30 +08:00
|
|
|
import { StorageManager } from "../models/StorageManager";
|
|
|
|
|
|
|
|
|
|
const { regClass, property } = Laya;
|
|
|
|
|
|
|
|
|
|
@regClass()
|
|
|
|
|
export class TrophyUnit extends Laya.Script {
|
|
|
|
|
declare owner : Laya.Box;
|
|
|
|
|
|
2025-05-21 11:08:50 +08:00
|
|
|
@property(Laya.Image)
|
|
|
|
|
public bg_light: Laya.Image;
|
2025-05-20 21:05:30 +08:00
|
|
|
@property(Laya.Image)
|
|
|
|
|
public icon: Laya.Image;
|
|
|
|
|
@property(Laya.Label)
|
|
|
|
|
public label_count: Laya.Label;
|
|
|
|
|
@property(Laya.Label)
|
|
|
|
|
public label_month: Laya.Label;
|
|
|
|
|
|
2025-05-21 10:15:23 +08:00
|
|
|
public onInit(info: any): void {
|
2025-05-20 21:05:30 +08:00
|
|
|
var user = StorageManager.getInstance().getUser()
|
2025-05-21 10:15:23 +08:00
|
|
|
var starCount = user.get_doneCountBydate(info.year, info.month)
|
|
|
|
|
this.icon.skin = info.icon_res
|
|
|
|
|
this.label_count.text = `${starCount}/${info.dayCount}`
|
|
|
|
|
this.label_month.text = config.MONTH_ABBRS[info.month-1]
|
|
|
|
|
if (starCount >= info.dayCount) {
|
2025-05-21 11:08:50 +08:00
|
|
|
this.bg_light.skin = respath.trophy_bg_light_gold
|
2025-05-21 10:15:23 +08:00
|
|
|
this.icon.gray = false
|
|
|
|
|
this.label_month.color = "#2d3138"
|
|
|
|
|
}
|
|
|
|
|
else {
|
2025-05-21 11:08:50 +08:00
|
|
|
this.bg_light.skin = respath.trophy_bg_light_grey
|
2025-05-21 10:15:23 +08:00
|
|
|
this.icon.gray = true
|
|
|
|
|
this.label_month.color = "#a7abb3"
|
|
|
|
|
}
|
2025-05-20 21:05:30 +08:00
|
|
|
}
|
|
|
|
|
}
|