Files

38 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

2025-08-15 13:55:26 +08:00
import { _decorator, Component, Label, Node } from "cc";
import { PurchasePanel } from "../ui/panels/PurchasePanel";
import { PurchaseConfig } from "../../schema/schema";
2025-09-10 11:37:30 +08:00
import { DataManager, DataId } from "../data/DataManager";
import { ShopData } from "../data/ShopData";
2025-09-10 15:26:56 +08:00
import { GButton } from "db://assets/Scripts/Main/Common/GButton";
2025-08-15 13:55:26 +08:00
const { ccclass, property } = _decorator;
@ccclass("PurchasePanelItem")
export class PurchasePanelItem extends Component {
@property(Label)
count: Label;
@property(Label)
price: Label;
baseView: PurchasePanel;
2025-09-10 11:37:30 +08:00
goodId: number;
public init(base: PurchasePanel, goodId: number) {
2025-08-15 13:55:26 +08:00
this.baseView = base;
2025-09-10 11:37:30 +08:00
this.goodId = goodId;
2025-09-10 15:26:56 +08:00
GButton.BandClick(this.node, this.onClickThis, this);
2025-08-15 13:55:26 +08:00
}
public show() {
2025-09-10 11:37:30 +08:00
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
const count = shopData.getCountById(this.goodId);
this.count.string = count.toString();
const price = shopData.getOriginalPriceById(this.goodId);
this.price.string = price.toString();
2025-08-15 13:55:26 +08:00
}
2025-09-10 15:26:56 +08:00
async onClickThis() {
2025-09-10 11:37:30 +08:00
this.baseView.setDiamondTag(this.goodId);
2025-08-15 13:55:26 +08:00
}
}