Files
18xchat/assets/Scripts/chat18x/uiitems/PurchasePanelItem.ts
T
2025-09-10 15:27:07 +08:00

38 lines
1.1 KiB
TypeScript

import { _decorator, Component, Label, Node } from "cc";
import { PurchasePanel } from "../ui/panels/PurchasePanel";
import { PurchaseConfig } from "../../schema/schema";
import { DataManager, DataId } from "../data/DataManager";
import { ShopData } from "../data/ShopData";
import { GButton } from "db://assets/Scripts/Main/Common/GButton";
const { ccclass, property } = _decorator;
@ccclass("PurchasePanelItem")
export class PurchasePanelItem extends Component {
@property(Label)
count: Label;
@property(Label)
price: Label;
baseView: PurchasePanel;
goodId: number;
public init(base: PurchasePanel, goodId: number) {
this.baseView = base;
this.goodId = goodId;
GButton.BandClick(this.node, this.onClickThis, this);
}
public show() {
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();
}
async onClickThis() {
this.baseView.setDiamondTag(this.goodId);
}
}