Merge branch 'main' of 47.107.44.202:xionglijia/18xchat
This commit is contained in:
@@ -6,6 +6,7 @@ import li_EventManager from "../../Main/Common/li_EventManager";
|
||||
import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
|
||||
import { ThemePanel } from "../ui/panels/ThemePanel";
|
||||
import { GirlListPanel } from "../ui/panels/GirlListPanel";
|
||||
import li_BaseView from "../../Main/Common/li_BaseView";
|
||||
|
||||
/**
|
||||
* 页面过渡动画类型枚举
|
||||
@@ -23,7 +24,7 @@ export enum PanelType {
|
||||
THEME = "ThemePanel",
|
||||
GIRL_DETAIL = "GirlDetailPanel",
|
||||
CHAT = "ChatPanel",
|
||||
SETTING = "SettingPanel",
|
||||
PERSONAL = "PersonalPanel",
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +51,8 @@ export class NavigationManager {
|
||||
|
||||
// NavigationPanel相关属性
|
||||
private navigationPanel: any = null; // NavigationPanel实例引用
|
||||
private currentActivePanel: PanelType = PanelType.THEME;
|
||||
private currentActivePanelType: PanelType = PanelType.THEME;
|
||||
private currentActivePanel: Node;
|
||||
private panelCache: Map<PanelType, Node> = new Map(); // 面板缓存
|
||||
private currentVisiblePanel: Node = null;
|
||||
|
||||
@@ -117,7 +119,7 @@ export class NavigationManager {
|
||||
* @param panelType 目标面板类型
|
||||
*/
|
||||
public switchToPanel(panelType: PanelType, force: boolean = false): void {
|
||||
if (this.currentActivePanel === panelType && !force) {
|
||||
if (this.currentActivePanelType === panelType && !force) {
|
||||
if (panelType === PanelType.THEME) {
|
||||
this.girlListPanel.hide();
|
||||
}
|
||||
@@ -137,7 +139,7 @@ export class NavigationManager {
|
||||
this.navigationPanel.showLoading?.();
|
||||
|
||||
// 计算动画方向
|
||||
const currentIndex = this.getPanelIndex(this.currentActivePanel);
|
||||
const currentIndex = this.getPanelIndex(this.currentActivePanelType);
|
||||
const targetIndex = this.getPanelIndex(panelType);
|
||||
const isMovingRight = currentIndex < targetIndex;
|
||||
|
||||
@@ -149,19 +151,40 @@ export class NavigationManager {
|
||||
|
||||
// 加载并显示目标面板
|
||||
this.loadOrGetPanel(panelType, (panel: Node) => {
|
||||
this.currentActivePanel = panelType;
|
||||
this.currentActivePanelType = panelType;
|
||||
this.currentVisiblePanel = panel;
|
||||
|
||||
if (this.subPanelDic.has(this.currentActivePanel)) {
|
||||
//如果有子页面,关闭掉
|
||||
let subs = this.subPanelDic.get(this.currentActivePanel);
|
||||
subs.forEach((n) => {
|
||||
n.getComponent(li_BaseView).close();
|
||||
});
|
||||
this.subPanelDic.delete(this.currentActivePanel);
|
||||
}
|
||||
// 更新NavigationPanel按钮状态
|
||||
this.navigationPanel.updateButtonStates?.(panelType);
|
||||
|
||||
// 显示面板
|
||||
this.showPanelWithAnimation(panel, showDirection, () => {
|
||||
this.currentActivePanel = panel;
|
||||
this.navigationPanel.hideLoading?.();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private subPanelDic: Map<Node, Node[]> = new Map();
|
||||
public openSubPanel(panelName: string, basePanel: Node, data: any = null) {
|
||||
const callback = (n: Node) => {
|
||||
if (!this.subPanelDic.has(basePanel)) {
|
||||
this.subPanelDic.set(basePanel, []);
|
||||
}
|
||||
this.subPanelDic.get(basePanel).push(n);
|
||||
};
|
||||
|
||||
ViewManager.I.openBundlesView(panelName, data, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取面板索引(用于动画方向计算)
|
||||
*/
|
||||
@@ -173,7 +196,7 @@ export class NavigationManager {
|
||||
return 1;
|
||||
case PanelType.CHAT:
|
||||
return 2;
|
||||
case PanelType.SETTING:
|
||||
case PanelType.PERSONAL:
|
||||
return 3;
|
||||
default:
|
||||
return 0;
|
||||
@@ -257,7 +280,7 @@ export class NavigationManager {
|
||||
}
|
||||
|
||||
// 如果当前是ThemePanel,需要同时处理可能的子页面(GirlListPanel)
|
||||
if (this.currentActivePanel === PanelType.THEME) {
|
||||
if (this.currentActivePanelType === PanelType.THEME) {
|
||||
// 查找并隐藏GirlListPanel子页面
|
||||
this.hideThemePanelChildren(direction);
|
||||
|
||||
@@ -373,7 +396,7 @@ export class NavigationManager {
|
||||
* 获取当前激活的面板类型
|
||||
*/
|
||||
public getCurrentActivePanel(): PanelType {
|
||||
return this.currentActivePanel;
|
||||
return this.currentActivePanelType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,7 +62,7 @@ export class NavigationPanel extends li_BaseView {
|
||||
);
|
||||
GButton.BandClick(
|
||||
this.settingBtn.node,
|
||||
() => NavigationManager.Instance.switchToPanel(PanelType.SETTING),
|
||||
() => NavigationManager.Instance.switchToPanel(PanelType.PERSONAL),
|
||||
this
|
||||
);
|
||||
}
|
||||
@@ -95,7 +95,7 @@ export class NavigationPanel extends li_BaseView {
|
||||
this.currentActivePanel === PanelType.GIRL_DETAIL
|
||||
);
|
||||
this.chatBtn.setFocus(this.currentActivePanel === PanelType.CHAT);
|
||||
this.settingBtn.setFocus(this.currentActivePanel === PanelType.SETTING);
|
||||
this.settingBtn.setFocus(this.currentActivePanel === PanelType.PERSONAL);
|
||||
}
|
||||
|
||||
private initializeFirstPanel() {
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
import {
|
||||
_decorator,
|
||||
Component,
|
||||
Node,
|
||||
Label,
|
||||
Sprite,
|
||||
Button,
|
||||
tween,
|
||||
Vec3,
|
||||
} from "cc";
|
||||
import Utils from "../../../Main/Common/Utils";
|
||||
import li_BaseView from "../../../Main/Common/li_BaseView";
|
||||
import { GButton } from "../../../Main/Common/GButton";
|
||||
import PlayerDataManager from "../../../Main/Manager/PlayerDataManager";
|
||||
import { DataManager, DataId } from "../../data/DataManager";
|
||||
import { PlayerData } from "../../data/PlayerData";
|
||||
import { AccountData } from "../../data/AccountData";
|
||||
import { WalletData } from "../../data/WalletData";
|
||||
import LanguageUtils, {
|
||||
LanguageType,
|
||||
} from "../../../Main/Common/LanguageUtils";
|
||||
import AudioManager from "../../../Main/Manager/AudioManager";
|
||||
import { NavigationManager } from "../../manager/NavigationManager";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("PersonalPanel")
|
||||
export class PersonalPanel extends li_BaseView {
|
||||
private _nodeTab: any = {};
|
||||
|
||||
@property(Label)
|
||||
private userNameLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
private userIdLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
private balanceLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
private vipStatusLabel: Label = null;
|
||||
|
||||
@property(Sprite)
|
||||
private avatarSprite: Sprite = null;
|
||||
|
||||
private playerData: PlayerData = null;
|
||||
private accountData: AccountData = null;
|
||||
private walletData: WalletData = null;
|
||||
|
||||
protected start(): void {
|
||||
Utils.parseNode(this.node, this._nodeTab);
|
||||
this.initUI();
|
||||
this.registerListener();
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
onEnable() {
|
||||
this.initData();
|
||||
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
private initData(): void {
|
||||
this.playerData = DataManager.I.getDataById<PlayerData>(DataId.Player);
|
||||
this.accountData = DataManager.I.getDataById<AccountData>(DataId.Account);
|
||||
this.walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
||||
}
|
||||
|
||||
private initUI(): void {}
|
||||
|
||||
private registerListener(): void {
|
||||
// 注册关闭按钮
|
||||
if (this._nodeTab.closeBtn) {
|
||||
GButton.BandClick(this._nodeTab.closeBtn, this.close, this);
|
||||
}
|
||||
if (this._nodeTab.WalletBtn) {
|
||||
GButton.BandClick(this._nodeTab.WalletBtn, this.openPurchase, this);
|
||||
}
|
||||
|
||||
// 注册设置按钮
|
||||
if (this._nodeTab.settingBtn) {
|
||||
GButton.BandClick(this._nodeTab.settingBtn, this.openSettings, this);
|
||||
}
|
||||
}
|
||||
|
||||
private refresh(): void {
|
||||
this.updateUserInfo();
|
||||
this.updateBalance();
|
||||
this.updateVipStatus();
|
||||
}
|
||||
|
||||
private updateUserInfo(): void {
|
||||
// 更新用户名
|
||||
if (this.userNameLabel && this.playerData) {
|
||||
const userName = this.playerData.name || "未设置";
|
||||
this.userNameLabel.string = userName;
|
||||
}
|
||||
|
||||
// 更新用户ID
|
||||
if (this.userIdLabel && this.accountData) {
|
||||
const userId = this.accountData.accId || "游客";
|
||||
this.userIdLabel.string = `uid: ${userId}`;
|
||||
}
|
||||
|
||||
// 头像暂时留空,等待资源配置
|
||||
if (this.avatarSprite) {
|
||||
// TODO: 设置默认头像或从数据中获取头像
|
||||
}
|
||||
}
|
||||
|
||||
private updateBalance(): void {
|
||||
if (this.balanceLabel && this.walletData) {
|
||||
const balance = this.walletData.getOriginalBalance();
|
||||
this.balanceLabel.string = `余额: ${balance}`;
|
||||
}
|
||||
}
|
||||
|
||||
private updateVipStatus(): void {
|
||||
if (this.vipStatusLabel && this.walletData) {
|
||||
const vipExpire = this.walletData.vipExpire;
|
||||
if (vipExpire && vipExpire > Date.now()) {
|
||||
const expireDate = new Date(vipExpire);
|
||||
this.vipStatusLabel.string = `VIP至: ${expireDate.toLocaleDateString()}`;
|
||||
} else {
|
||||
this.vipStatusLabel.string = "普通用户";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private openSettings(): void {
|
||||
// TODO: 打开设置面板
|
||||
NavigationManager.Instance.openSubPanel("SettingPanel", this.node);
|
||||
}
|
||||
private openPurchase() {
|
||||
NavigationManager.Instance.openSubPanel("PurchasePanel", this.node);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "a12352fe-e052-4f12-b1d0-59763379c145",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -331,8 +331,8 @@ export class ThemePanel extends li_BaseView {
|
||||
}
|
||||
|
||||
openSetting() {
|
||||
// 通过NavigationManager切换到设置面板,保持动画和状态同步
|
||||
NavigationManager.Instance.switchToPanel(PanelType.SETTING);
|
||||
// 通过NavigationManager切换到个人信息面板,保持动画和状态同步
|
||||
NavigationManager.Instance.switchToPanel(PanelType.PERSONAL);
|
||||
}
|
||||
|
||||
openMsgBox() {
|
||||
|
||||
Reference in New Issue
Block a user