2025-08-11 16:08:59 +08:00
|
|
|
import {
|
|
|
|
|
_decorator,
|
|
|
|
|
Component,
|
|
|
|
|
Node,
|
|
|
|
|
instantiate,
|
|
|
|
|
Label,
|
|
|
|
|
Sprite,
|
|
|
|
|
UITransform,
|
|
|
|
|
} from "cc";
|
|
|
|
|
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
|
|
|
|
|
import Utils from "db://assets/Scripts/Main/Common/Utils";
|
|
|
|
|
import { GButton } from "db://assets/Scripts/Main/Common/GButton";
|
|
|
|
|
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
|
2025-08-13 11:31:21 +08:00
|
|
|
import { ThemeItem } from "../../uiitems/ThemeItem";
|
2025-08-11 16:08:59 +08:00
|
|
|
import { NavigationManager } from "../../manager/NavigationManager";
|
2025-08-13 11:31:21 +08:00
|
|
|
import { GirlListItem } from "../../uiitems/GirlListItem";
|
2025-08-12 19:49:50 +08:00
|
|
|
import LanguageUtils from "../../../Main/Common/LanguageUtils";
|
2025-08-12 20:22:54 +08:00
|
|
|
import { ViewManager } from "../../../Main/Manager/ViewManager";
|
|
|
|
|
import { InnerMsgCode } from "../../../Main/Config/InnerMsgCode";
|
2025-09-02 11:33:44 +08:00
|
|
|
import { ThemeService } from "db://assets/Scripts/chat18x/network/services/ThemeService";
|
2025-09-02 15:07:53 +08:00
|
|
|
import { GirlService } from "db://assets/Scripts/chat18x/network/services/GirlService";
|
2025-09-10 17:37:24 +08:00
|
|
|
import { ShopService } from "db://assets/Scripts/chat18x/network/services/ShopService";
|
2025-09-02 11:33:44 +08:00
|
|
|
import { DataManager, DataId } from "../../data/DataManager";
|
|
|
|
|
import { ThemeData } from "../../data/ThemeData";
|
2025-09-02 15:07:53 +08:00
|
|
|
import { GirlData } from "../../data/GirlData";
|
2025-09-09 20:33:43 +08:00
|
|
|
import { WalletData } from "../../data/WalletData";
|
|
|
|
|
import { AccountData } from "../../data/AccountData";
|
2025-09-10 18:13:39 +08:00
|
|
|
|
2025-09-10 17:37:24 +08:00
|
|
|
import { ShopData } from "../../data/ShopData";
|
2025-09-10 18:12:26 +08:00
|
|
|
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
2025-09-11 00:03:22 +08:00
|
|
|
import GameRootUI from "../../../Main/Common/GameRootUI";
|
2025-08-11 16:08:59 +08:00
|
|
|
|
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
|
|
|
|
@ccclass("ThemePanel")
|
|
|
|
|
export class ThemePanel extends li_BaseView {
|
|
|
|
|
private _nodeTab: any = {};
|
|
|
|
|
|
|
|
|
|
coinNum: Label;
|
2025-09-09 20:33:43 +08:00
|
|
|
uid: Label;
|
2025-08-11 16:08:59 +08:00
|
|
|
itemInst: GirlListItem;
|
|
|
|
|
content: Node;
|
2025-09-10 15:26:56 +08:00
|
|
|
private vipLeftTime: Label;
|
2025-08-11 16:08:59 +08:00
|
|
|
recId: number;
|
|
|
|
|
recName: Label;
|
|
|
|
|
recSprite: Sprite;
|
|
|
|
|
|
|
|
|
|
cache: ThemeItem[] = [];
|
|
|
|
|
|
|
|
|
|
onLoadCT() {
|
|
|
|
|
Utils.parseNode(this.node, this._nodeTab);
|
|
|
|
|
|
|
|
|
|
this.coinNum = this._nodeTab.coinNum.getComponent(Label);
|
2025-09-09 20:33:43 +08:00
|
|
|
this.uid = this._nodeTab.uid.getComponent(Label);
|
2025-08-11 16:08:59 +08:00
|
|
|
this.recName = this._nodeTab.characterNameText.getComponent(Label);
|
2025-09-11 15:01:03 +08:00
|
|
|
this.recSprite = this._nodeTab.recPic.getComponent(Sprite);
|
2025-09-10 15:26:56 +08:00
|
|
|
this.vipLeftTime = this._nodeTab.vipText.getComponent(Label);
|
2025-08-11 16:08:59 +08:00
|
|
|
|
|
|
|
|
this.registerListener();
|
|
|
|
|
this.itemInst = this._nodeTab.ThemeItem.getComponent(ThemeItem);
|
|
|
|
|
this.itemInst.node.active = false;
|
2025-08-13 15:37:15 +08:00
|
|
|
this.content = this._nodeTab.allThemecontent;
|
2025-08-12 19:49:50 +08:00
|
|
|
|
2025-08-11 16:08:59 +08:00
|
|
|
this.Show();
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-12 20:22:54 +08:00
|
|
|
rectNameKey: string;
|
2025-09-02 11:33:44 +08:00
|
|
|
async Show() {
|
2025-09-11 15:01:03 +08:00
|
|
|
this._nodeTab.loadingRec.active = true;
|
2025-08-11 16:08:59 +08:00
|
|
|
//some temp data
|
2025-09-09 20:33:43 +08:00
|
|
|
this.refreshCoinNum();
|
2025-09-10 15:26:56 +08:00
|
|
|
this.refreshVipExpire();
|
2025-09-09 20:33:43 +08:00
|
|
|
const accountData = DataManager.I.getDataById<AccountData>(DataId.Account);
|
|
|
|
|
this.uid.string = "uid: " + accountData.accId;
|
2025-08-11 16:08:59 +08:00
|
|
|
this.recId = 1;
|
|
|
|
|
if (this.cache) {
|
|
|
|
|
for (let i = this.cache.length - 1; i >= 0; i--) {
|
|
|
|
|
this.cache[i].node.destroy();
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-02 11:33:44 +08:00
|
|
|
// 请求主题数据
|
2025-09-10 18:12:26 +08:00
|
|
|
const reqData = {};
|
2025-09-02 11:33:44 +08:00
|
|
|
let res = await ThemeService.I.reqHallTheme(reqData);
|
2025-09-02 15:11:52 +08:00
|
|
|
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
|
|
|
|
// 保存数据
|
|
|
|
|
const themeData = DataManager.I.getDataById<ThemeData>(DataId.Theme);
|
|
|
|
|
themeData.themes = res.data;
|
2025-09-02 16:38:01 +08:00
|
|
|
// 根据数据,刷新界面
|
2025-09-02 15:11:52 +08:00
|
|
|
const themeIds = themeData.themeIds;
|
|
|
|
|
for (let id of themeIds) {
|
|
|
|
|
let newNode = instantiate(this.itemInst.node);
|
|
|
|
|
let item = newNode.getComponent(ThemeItem);
|
|
|
|
|
item.refresh(id);
|
|
|
|
|
newNode.active = true;
|
|
|
|
|
this.cache.push(item);
|
2025-09-10 18:12:26 +08:00
|
|
|
this.content.addChild(newNode);
|
2025-09-02 15:11:52 +08:00
|
|
|
}
|
2025-08-11 16:08:59 +08:00
|
|
|
}
|
2025-09-02 15:07:53 +08:00
|
|
|
|
|
|
|
|
// 请求每日推荐
|
2025-09-10 18:12:26 +08:00
|
|
|
const reqData2 = {};
|
2025-09-02 15:07:53 +08:00
|
|
|
let res2 = await GirlService.I.reqDailyRecommend(reqData2);
|
2025-09-02 15:11:52 +08:00
|
|
|
if (res2 && res2.code === proto.cs.EnmRetCode.SUCCESS) {
|
|
|
|
|
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
|
|
|
|
girlData.setDailyRecommend(res2.data);
|
2025-09-02 16:38:01 +08:00
|
|
|
// 根据数据,刷新界面
|
2025-09-08 15:10:51 +08:00
|
|
|
this.recId = girlData.getRecommendGirlId();
|
|
|
|
|
this.rectNameKey = girlData.getRecommendGrilName();
|
|
|
|
|
let avatarPath = girlData.getRecommendGrilAvatar();
|
2025-09-09 10:30:46 +08:00
|
|
|
this.recName.string = LanguageUtils.getText(this.rectNameKey);
|
2025-09-02 15:11:52 +08:00
|
|
|
ResManager.I.changeBundleSpriteFrame(
|
|
|
|
|
this.recSprite,
|
|
|
|
|
avatarPath,
|
2025-09-11 00:03:22 +08:00
|
|
|
"Girls",
|
2025-09-02 15:11:52 +08:00
|
|
|
() => {
|
|
|
|
|
let sizeTran = this.recSprite.node.parent.getComponent(UITransform);
|
|
|
|
|
Utils.adjustBgPixelRatioToSize(
|
|
|
|
|
sizeTran.contentSize,
|
|
|
|
|
this.recSprite.node,
|
|
|
|
|
1
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-09-11 15:01:03 +08:00
|
|
|
this._nodeTab.loadingRec.active = false;
|
2025-09-10 17:37:24 +08:00
|
|
|
|
|
|
|
|
// 获取商品列表,提前把数据拿下来
|
|
|
|
|
this.reqShopList();
|
2025-08-11 16:08:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private registerListener() {
|
|
|
|
|
GButton.BandClick(this._nodeTab.settingBtn, this.openSetting, this);
|
|
|
|
|
GButton.BandClick(this._nodeTab.msgBoxBtn, this.openMsgBox, this);
|
|
|
|
|
|
|
|
|
|
GButton.BandClick(this._nodeTab.ChatWithRecBtn, this.chatWithRec, this);
|
2025-08-12 20:22:54 +08:00
|
|
|
|
2025-08-15 13:55:26 +08:00
|
|
|
GButton.BandClick(this._nodeTab.ShopPanelEntry, this.enterShop, this);
|
|
|
|
|
|
2025-08-12 20:22:54 +08:00
|
|
|
Utils.addInnerEL(InnerMsgCode.LanguageChange, this, () => {
|
|
|
|
|
this.recName.string = LanguageUtils.getText(this.rectNameKey);
|
|
|
|
|
});
|
2025-09-09 18:51:12 +08:00
|
|
|
Utils.addInnerEL(InnerMsgCode.BalanceChange, this, () => {
|
2025-09-09 20:33:43 +08:00
|
|
|
this.refreshCoinNum();
|
2025-09-10 18:12:26 +08:00
|
|
|
});
|
2025-09-09 18:51:12 +08:00
|
|
|
Utils.addInnerEL(InnerMsgCode.VipExpireChange, this, () => {
|
2025-09-09 20:33:43 +08:00
|
|
|
this.refreshVipExpire();
|
2025-09-10 18:12:26 +08:00
|
|
|
});
|
2025-08-11 16:08:59 +08:00
|
|
|
}
|
|
|
|
|
|
2025-08-15 13:55:26 +08:00
|
|
|
enterShop() {
|
|
|
|
|
ViewManager.I.openBundlesView("PurchasePanel");
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-11 16:08:59 +08:00
|
|
|
chatWithRec() {
|
2025-09-10 18:12:26 +08:00
|
|
|
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
|
|
|
|
|
|
|
|
|
// 是否已经解锁
|
|
|
|
|
const isRelease = girlData.getIsRelease(
|
|
|
|
|
girlData.getGrilCategoryById(this.recId).toString(),
|
|
|
|
|
this.recId
|
|
|
|
|
);
|
|
|
|
|
const isFree =
|
|
|
|
|
girlData.getGrilPrice(
|
|
|
|
|
girlData.getGrilCategoryById(this.recId).toString(),
|
|
|
|
|
this.recId
|
|
|
|
|
) == 0;
|
|
|
|
|
if (isRelease || isFree) {
|
|
|
|
|
NavigationManager.Instance.navigateToGirlDetail(this.recId);
|
2025-09-11 00:03:22 +08:00
|
|
|
GameRootUI.I.hideDefaultView();
|
2025-09-10 18:12:26 +08:00
|
|
|
} else {
|
|
|
|
|
//未解锁
|
|
|
|
|
ViewManager.I.openBundlesPopupView("GirlListPopupPanel", {
|
|
|
|
|
base: this,
|
|
|
|
|
category: girlData.getGrilCategoryById(this.recId),
|
|
|
|
|
id: this.recId,
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-08-11 16:08:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openSetting() {
|
2025-09-10 19:37:12 +08:00
|
|
|
ViewManager.I.openBundlesView("SettingPanel");
|
2025-08-11 16:08:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openMsgBox() {
|
|
|
|
|
console.log("打开信箱");
|
|
|
|
|
}
|
2025-08-12 20:22:54 +08:00
|
|
|
|
2025-09-09 20:33:43 +08:00
|
|
|
// 刷新余额
|
|
|
|
|
private refreshCoinNum() {
|
|
|
|
|
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
|
|
|
|
const balance = walletData.getOriginalBalance();
|
|
|
|
|
this.coinNum.string = balance.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 刷新 vip失效时间戳
|
|
|
|
|
private refreshVipExpire() {
|
|
|
|
|
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
|
|
|
|
const vipExpire = walletData.vipExpire;
|
2025-09-10 15:26:56 +08:00
|
|
|
const leftTime = Utils.formatVipLeftTime(vipExpire);
|
|
|
|
|
this.vipLeftTime.string = LanguageUtils.getText(
|
|
|
|
|
"purchasepanel.vip_left"
|
2025-09-10 18:12:26 +08:00
|
|
|
).replace("${leftTime}", leftTime);
|
|
|
|
|
}
|
2025-09-09 20:33:43 +08:00
|
|
|
|
2025-09-10 17:37:24 +08:00
|
|
|
// 获取商品列表
|
|
|
|
|
async reqShopList() {
|
|
|
|
|
// 请求购买商品
|
2025-09-10 18:13:39 +08:00
|
|
|
const reqData = {};
|
2025-09-10 17:37:24 +08:00
|
|
|
let res = await ShopService.I.reqShopList(reqData);
|
|
|
|
|
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
|
|
|
|
const resData = res.data;
|
|
|
|
|
// 保存数据
|
|
|
|
|
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
|
|
|
|
shopData.goods = res.data;
|
|
|
|
|
}
|
2025-09-10 18:13:39 +08:00
|
|
|
}
|
2025-09-10 17:37:24 +08:00
|
|
|
|
2025-08-12 20:22:54 +08:00
|
|
|
onDestroy(): void {
|
|
|
|
|
Utils.removeInnerEL(InnerMsgCode.LanguageChange, this, () => {
|
|
|
|
|
this.recName.string = LanguageUtils.getText(this.rectNameKey);
|
|
|
|
|
});
|
2025-09-10 18:12:26 +08:00
|
|
|
Utils.removeInnerEL(InnerMsgCode.BalanceChange, this, () => {});
|
|
|
|
|
Utils.removeInnerEL(InnerMsgCode.VipExpireChange, this, () => {});
|
2025-08-12 20:22:54 +08:00
|
|
|
}
|
2025-08-11 16:08:59 +08:00
|
|
|
}
|