import { _decorator, Button, Component, Node, Label } from "cc"; import li_BaseView from "../../../Main/Common/li_BaseView"; import Utils from "../../../Main/Common/Utils"; import { GButton } from "../../../Main/Common/GButton"; import { PopupGirlDetailPanel } from "./PopupGirlDetailPanel"; import { GirlListItem } from "../../uiitems/GirlListItem"; 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"; import LanguageUtils from "../../../Main/Common/LanguageUtils"; const { ccclass, property } = _decorator; @ccclass("GirlListPopupPanel") export class GirlListPopupPanel extends li_BaseView { private _nodeTab: any = {}; private priceLabel: Label; private category: number; private girlId: number; private girlName: Label; private girlTag: Label; base: GirlListItem; openUIDataCT(data) { this.category = data.category; this.girlId = data.id; this.base = data.base; } onLoadCT() { Utils.parseNode(this.node, this._nodeTab); this.girlName = this._nodeTab.Name.getComponent(Label); this.girlTag = this._nodeTab.Tag.getComponent(Label); const girlData = DataManager.I.getDataById(DataId.Girl); // 价格 this.priceLabel = this._nodeTab.Price.getComponent(Label); this.priceLabel.string = girlData .getGrilOriginalPrice(this.category.toString(), this.girlId) .toString(); this.registerListener(); this.girlName.string = LanguageUtils.getText( girlData.getGrilName(this.category.toString(), this.girlId) ); this.girlTag.string = LanguageUtils.getText( girlData.getGrilTagKey(this.category.toString(), this.girlId) ); } registerListener() { GButton.BandClick(this._nodeTab.BuyBtn, this.buyCharacter, this); GButton.BandClick(this._nodeTab.CloseBtn, this.Close, this); } Close() { this.close(); } async buyCharacter() { // 购买id为girlId的女生 console.log(this.girlId); // 请求解锁 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(DataId.Girl); girlData.setIsRelease(this.category.toString(), this.girlId, true); const walletData = DataManager.I.getDataById(DataId.Wallet); walletData.balance = Number(resData.balance); walletData.vipExpire = Number(resData.vipExpire); // 刷新界面 this.base.refreshBuy(true); this.close(); } } }