Files
18xchat/assets/Scripts/chat18x/ui/panels/GirlListPopupPanel.ts
T

65 lines
2.3 KiB
TypeScript
Raw Normal View History

2025-09-09 19:16:46 +08:00
import { _decorator, Button, Component, Node, Label } from "cc";
2025-09-09 15:33:44 +08:00
import li_BaseView from "../../../Main/Common/li_BaseView";
import Utils from "../../../Main/Common/Utils";
import { GButton } from "../../../Main/Common/GButton";
2025-09-09 16:09:10 +08:00
import { PopupGirlDetailPanel } from "./PopupGirlDetailPanel";
import { GirlListItem } from "../../uiitems/GirlListItem";
2025-09-09 18:16:13 +08:00
import { GirlService } from "db://assets/Scripts/chat18x/network/services/GirlService";
import { DataManager, DataId } from "../../data/DataManager";
import { GirlData } from "../../data/GirlData";
import { WalletData } from "../../data/WalletData";
import proto from "db://assets/Scripts/proto/proto.pb.js";
2025-09-09 15:33:44 +08:00
const { ccclass, property } = _decorator;
2025-09-09 16:09:10 +08:00
@ccclass("GirlListPopupPanel")
export class GirlListPopupPanel extends li_BaseView {
2025-09-09 15:33:44 +08:00
private _nodeTab: any = {};
2025-09-09 19:16:46 +08:00
private priceLabel: Label;
2025-09-09 18:16:13 +08:00
private category: number;
2025-09-09 15:33:44 +08:00
private girlId: number;
2025-09-09 16:09:10 +08:00
base: GirlListItem;
2025-09-09 15:33:44 +08:00
openUIDataCT(data) {
2025-09-09 18:16:13 +08:00
this.category = data.category;
2025-09-09 16:09:10 +08:00
this.girlId = data.id;
this.base = data.base;
2025-09-09 15:33:44 +08:00
}
onLoadCT() {
Utils.parseNode(this.node, this._nodeTab);
2025-09-09 19:16:46 +08:00
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
// 价格
this.priceLabel = this._nodeTab.Price.getComponent(Label);
this.priceLabel.string = girlData.getGrilOriginalPrice(this.category.toString(), this.girlId).toString();
2025-09-09 15:45:50 +08:00
this.registerListener();
2025-09-09 15:33:44 +08:00
}
registerListener() {
GButton.BandClick(this._nodeTab.BuyBtn, this.buyCharacter, this);
2025-09-09 15:45:50 +08:00
GButton.BandClick(this._nodeTab.CloseBtn, this.Close, this);
}
Close() {
this.close();
2025-09-09 15:33:44 +08:00
}
2025-09-09 18:16:13 +08:00
async buyCharacter() {
2025-09-09 15:33:44 +08:00
// 购买id为girlId的女生
console.log(this.girlId);
2025-09-09 18:16:13 +08:00
// 请求解锁
const reqData = {
id: this.girlId,
};
let res = await GirlService.I.reqUnlockGirl(reqData);
console.log("请求解锁响应数据:", res);
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
const resData = res.data;
// 保存数据
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
girlData.setIsRelease(this.category.toString(), this.girlId, true);
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
walletData.balance = Number(resData.balance);
walletData.vipExpire = Number(resData.vipExpire);
// 刷新界面
2025-09-09 16:09:10 +08:00
this.base.refreshBuy(true);
2025-09-09 18:16:13 +08:00
this.close();
2025-09-09 16:09:10 +08:00
}
2025-09-09 15:33:44 +08:00
}
}