This commit is contained in:
2025-09-19 11:10:20 +08:00
parent ad0e80ecda
commit a5859af3b4
14 changed files with 3596 additions and 881 deletions
@@ -25,6 +25,7 @@ import LanguageUtils from "../../../Main/Common/LanguageUtils";
import { ViewManager } from "../../../Main/Manager/ViewManager";
import { TipsPanel } from "./TipsPanel";
import ResManager from "../../../Main/Manager/ResManager";
import { InnerMsgCode } from "../../../Main/Config/InnerMsgCode";
const { ccclass, property } = _decorator;
@ccclass("GirlListPopupPanel")
@@ -36,6 +37,7 @@ export class GirlListPopupPanel extends li_BaseView {
private girlName: Label;
private girlTag: Label;
private balanceCount: Label;
base: GirlListItem;
img: Sprite;
@@ -56,6 +58,7 @@ export class GirlListPopupPanel extends li_BaseView {
this.uitransform = this._nodeTab.Img_Frame.getComponent(UITransform);
this.girlName = this._nodeTab.Name.getComponent(Label);
this.girlTag = this._nodeTab.Tag.getComponent(Label);
this.balanceCount = this._nodeTab.balanceCount.getComponent(Label);
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
// 价格
this.priceLabel = this._nodeTab.Price.getComponent(Label);
@@ -72,11 +75,11 @@ export class GirlListPopupPanel extends li_BaseView {
);
const path = girlData.getGrilAvatar(this.category.toString(), this.girlId);
this.refreshCoinNum();
//console.log(path);
// 加载远程资源
const envData = DataManager.I.getDataById<EnvData>(DataId.Env);
let newPath = envData.cdn + "/" + "Girls/" + path + ".png";
let newPath = envData.cdn + "/" + "Girls/" + path + ".png";
ResManager.I.changeRemoteSpriteFrame(this.img, newPath, () => {
this.scaleToFillItem();
});
@@ -84,10 +87,15 @@ export class GirlListPopupPanel extends li_BaseView {
registerListener() {
GButton.BandClick(this._nodeTab.BuyBtn, this.buyCharacter, this);
GButton.BandClick(this._nodeTab.CloseBtn, this.Close, this);
Utils.addInnerEL(InnerMsgCode.BalanceChange, this, this.onBalanceChange);
}
Close() {
this.close();
}
onDestroy(): void {
Utils.removeInnerEL(InnerMsgCode.BalanceChange, this, this.onBalanceChange);
}
async buyCharacter() {
// 购买id为girlId的女生
console.log(this.girlId);
@@ -116,6 +124,15 @@ export class GirlListPopupPanel extends li_BaseView {
// TipsPanel.show("Insufficient balance, need to purchase");
}
// 刷新余额
private refreshCoinNum() {
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
const balance = walletData.getOriginalBalance();
this.balanceCount.string = balance.toString();
}
onBalanceChange = () => {
this.refreshCoinNum();
};
scaleToFillItem() {
if (!this.img || !this.img.spriteFrame) return;