Merge branch 'main' of 47.107.44.202:xionglijia/18xchat
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { ViewManager } from "db://assets/Scripts/Main/Manager/ViewManager";
|
||||
import { UITransitionHelper } from "../utils/UITransitionHelper";
|
||||
import GameRootUI from "../../Main/Common/GameRootUI";
|
||||
import { Node } from "cc";
|
||||
import { Node, sys } from "cc";
|
||||
import li_EventManager from "../../Main/Common/li_EventManager";
|
||||
import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
|
||||
import { ThemePanel } from "../ui/panels/ThemePanel";
|
||||
@@ -55,12 +55,14 @@ export class NavigationManager {
|
||||
private currentVisiblePanel: Node = null;
|
||||
|
||||
// 选中的角色相关信息
|
||||
private selectedGirlId: number = 1; // 当前选中的角色ID
|
||||
private selectedThemeId: number = 1; // 当前选中的主题ID
|
||||
private selectedGirlId: number = 10002; // 当前选中的角色ID
|
||||
private selectedCategoryId: number = -1; // 当前选中的主题ID
|
||||
|
||||
private themePanel: ThemePanel = null;
|
||||
private girlListPanel: GirlListPanel = null;
|
||||
|
||||
private static LastSelectGirlID = "LastSelectGirlID";
|
||||
|
||||
/**
|
||||
* 获取NavigationManager的单例实例
|
||||
*
|
||||
@@ -70,6 +72,21 @@ export class NavigationManager {
|
||||
public static get Instance(): NavigationManager {
|
||||
if (!this._instance) {
|
||||
this._instance = new NavigationManager();
|
||||
|
||||
//初始化默认选的girl
|
||||
let cacheGirlId = sys.localStorage.getItem(this.LastSelectGirlID);
|
||||
if (!cacheGirlId) {
|
||||
cacheGirlId = 10002;
|
||||
sys.localStorage.setItem(this.LastSelectGirlID, cacheGirlId);
|
||||
}
|
||||
this._instance.selectedGirlId = Number(cacheGirlId);
|
||||
|
||||
let cacheCategoryId = sys.localStorage.getItem("LastSelectCategoryId");
|
||||
if (!cacheCategoryId) {
|
||||
cacheCategoryId = 0;
|
||||
sys.localStorage.setItem("LastSelectCategoryId", cacheCategoryId);
|
||||
}
|
||||
this._instance.selectedCategoryId = cacheCategoryId;
|
||||
}
|
||||
return this._instance;
|
||||
}
|
||||
@@ -101,6 +118,10 @@ export class NavigationManager {
|
||||
*/
|
||||
public switchToPanel(panelType: PanelType, force: boolean = false): void {
|
||||
if (this.currentActivePanel === panelType && !force) {
|
||||
if (panelType === PanelType.THEME) {
|
||||
this.girlListPanel.hide();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -361,6 +382,7 @@ export class NavigationManager {
|
||||
*/
|
||||
public setSelectedGirlId(girlId: number): void {
|
||||
this.selectedGirlId = girlId;
|
||||
sys.localStorage.setItem(NavigationManager.LastSelectGirlID, girlId);
|
||||
console.log("[NavigationManager] Selected girl ID set to:", girlId);
|
||||
}
|
||||
|
||||
@@ -377,7 +399,7 @@ export class NavigationManager {
|
||||
* @param themeId 主题ID
|
||||
*/
|
||||
public setSelectedCategoryId(themeId: number): void {
|
||||
this.selectedThemeId = themeId;
|
||||
this.selectedCategoryId = themeId;
|
||||
console.log("[NavigationManager] Selected theme ID set to:", themeId);
|
||||
}
|
||||
|
||||
@@ -385,8 +407,8 @@ export class NavigationManager {
|
||||
* 获取当前选中的主题ID
|
||||
* @returns 当前选中的主题ID
|
||||
*/
|
||||
public getSelectedThemeId(): number {
|
||||
return this.selectedThemeId;
|
||||
public getSelectedCategoryId(): number {
|
||||
return this.selectedCategoryId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -418,7 +440,7 @@ export class NavigationManager {
|
||||
if (existingGirlListPanel) {
|
||||
// 如果面板已存在,重新显示并刷新数据
|
||||
console.log("[NavigationManager] Reactivating existing GirlListPanel");
|
||||
this.reactivateGirlListPanel(existingGirlListPanel, themeId);
|
||||
this.reactivateGirlListPanel(existingGirlListPanel);
|
||||
} else {
|
||||
// 如果面板不存在,创建新的
|
||||
console.log("[NavigationManager] Creating new GirlListPanel");
|
||||
@@ -451,7 +473,7 @@ export class NavigationManager {
|
||||
/**
|
||||
* 重新激活已存在的GirlListPanel
|
||||
*/
|
||||
private reactivateGirlListPanel(panel: GirlListPanel, themeId: number): void {
|
||||
private reactivateGirlListPanel(panel: GirlListPanel): void {
|
||||
try {
|
||||
// 重新激活面板
|
||||
panel.node.active = true;
|
||||
@@ -460,10 +482,10 @@ export class NavigationManager {
|
||||
//const girlListComponent = panelNode.getComponent("GirlListPanel");
|
||||
if (panel) {
|
||||
// 如果有刷新方法,调用它来更新主题数据
|
||||
panel.refresh(themeId);
|
||||
panel.refresh();
|
||||
console.log(
|
||||
"[NavigationManager] GirlListPanel reactivated with theme:",
|
||||
themeId
|
||||
this.selectedCategoryId
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { _decorator, Component, Node, SpringJoint2D, Sprite } from "cc";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("NavigationBtn")
|
||||
export class NavigationBtn extends Component {
|
||||
focus: Node;
|
||||
unfocus: Node;
|
||||
|
||||
start() {
|
||||
this.focus = this.node.getChildByName("focus");
|
||||
this.unfocus = this.node.getChildByName("unfocus");
|
||||
}
|
||||
|
||||
setFocus(focus: boolean) {
|
||||
if (!this.focus) this.focus = this.node.getChildByName("focus");
|
||||
if (!this.unfocus) this.unfocus = this.node.getChildByName("unfocus");
|
||||
this.focus.active = focus;
|
||||
this.unfocus.active = !focus;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "54ca6f08-c166-47ca-a969-6a7cb141f29a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -25,12 +25,14 @@ import { ImagePopup } from "../components/ImagePopup";
|
||||
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
|
||||
import LanguageUtils from "../../../Main/Common/LanguageUtils";
|
||||
import { UITransitionHelper } from "../../utils/UITransitionHelper";
|
||||
import { VideoEmotion, purchase } from "../../../schema/schema";
|
||||
import { PriceType, VideoEmotion, purchase } from "../../../schema/schema";
|
||||
import { PayToTalkSubpanel } from "./PayToTalkSubpanel";
|
||||
import { DataId, DataManager } from "../../data/DataManager";
|
||||
import { GirlData } from "../../data/GirlData";
|
||||
import { SceneBgVideoLayer } from "../../../Sub/UI/SceneBgVideoLayer";
|
||||
import { NavigationManager, PanelType } from "../../manager/NavigationManager";
|
||||
import { GirlService } from "../../network/services/GirlService";
|
||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("ChatPanel")
|
||||
@@ -143,15 +145,33 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
||||
this.chatController = null;
|
||||
}
|
||||
}
|
||||
refresh() {
|
||||
async refresh() {
|
||||
const newRoleId = NavigationManager.Instance.getSelectedGirlId();
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
|
||||
// 检查是否是切换角色
|
||||
const isRoleSwitch = this.id && this.id !== newRoleId;
|
||||
|
||||
this.id = newRoleId;
|
||||
this.categoryId =
|
||||
NavigationManager.Instance.getSelectedThemeId().toString();
|
||||
NavigationManager.Instance.getSelectedCategoryId().toString();
|
||||
|
||||
const isFree =
|
||||
girlData.getGrilPriceType(this.categoryId.toString(), this.id) ==
|
||||
PriceType.free;
|
||||
const isRelease = girlData.getIsRelease(
|
||||
this.categoryId.toString(),
|
||||
this.id
|
||||
);
|
||||
if (!isFree && !isRelease) {
|
||||
//未解锁
|
||||
ViewManager.I.openBundlesPopupView("GirlListPopupPanel", {
|
||||
base: this,
|
||||
category: this.categoryId,
|
||||
id: this.id,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取ChatController单例并绑定当前Panel
|
||||
this.chatController = ChatController.Instance;
|
||||
@@ -177,9 +197,19 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
||||
}
|
||||
}
|
||||
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
|
||||
this.nameKey = girlData.getGrilName(this.categoryId, this.id);
|
||||
if (this.nameKey == "") {
|
||||
const reqData = {
|
||||
id: this.id,
|
||||
};
|
||||
let res = await GirlService.I.reqGetGirlDetail(reqData);
|
||||
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
||||
// 保存数据
|
||||
girlData.setGirlDetailData(this.categoryId.toString(), res.data);
|
||||
this.nameKey = girlData.getGrilName(this.categoryId, this.id);
|
||||
}
|
||||
}
|
||||
|
||||
this.girlName.string = LanguageUtils.getText(this.nameKey);
|
||||
|
||||
// 通过ChatController获取商业视频数据
|
||||
|
||||
@@ -137,7 +137,7 @@ export class GirlDetailPanel extends li_BaseView {
|
||||
category: number;
|
||||
async refresh() {
|
||||
this.id = NavigationManager.Instance.getSelectedGirlId();
|
||||
|
||||
this.category = NavigationManager.Instance.getSelectedCategoryId();
|
||||
this.imgItemInst.node.active = false;
|
||||
this.videoAreaPos = new Vec3(540, 1384);
|
||||
|
||||
@@ -162,7 +162,6 @@ export class GirlDetailPanel extends li_BaseView {
|
||||
}
|
||||
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
this.category = girlData.getGrilCategoryById(this.id);
|
||||
// 请求详细数据
|
||||
const reqData = {
|
||||
id: this.id,
|
||||
|
||||
@@ -30,25 +30,13 @@ export class GirlListPanel extends li_BaseView {
|
||||
category: number;
|
||||
private parentPanelName: string = null;
|
||||
|
||||
openUIDataCT(data) {
|
||||
console.log("[GirlListPanel] openUIDataCT called with data:", data);
|
||||
|
||||
// 支持新的数据格式:既可以是单纯的数字,也可以是包含主题ID和父页面信息的对象
|
||||
if (typeof data === "object") {
|
||||
this.category = data.themeId;
|
||||
this.parentPanelName = data.parentPanel;
|
||||
console.log("[GirlListPanel] Set parent panel:", this.parentPanelName);
|
||||
} else {
|
||||
this.category = data;
|
||||
}
|
||||
}
|
||||
onLoadCT() {
|
||||
Utils.parseNode(this.node, this._nodeTab);
|
||||
this.registerListener();
|
||||
this.itemInst = this._nodeTab.BubbleItem.getComponent(GirlListItem);
|
||||
this.itemInst.node.active = false;
|
||||
this.content = this._nodeTab.content;
|
||||
this.refresh(this.category);
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
cacheCategory: number = -1;
|
||||
@@ -68,7 +56,7 @@ export class GirlListPanel extends li_BaseView {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 没有可复用的节点,创建新节点
|
||||
let newNode = instantiate(this.itemInst.node);
|
||||
let item = newNode.getComponent(GirlListItem);
|
||||
@@ -88,7 +76,8 @@ export class GirlListPanel extends li_BaseView {
|
||||
}
|
||||
}
|
||||
|
||||
async refresh(category: number) {
|
||||
async refresh() {
|
||||
const category = NavigationManager.Instance.getSelectedCategoryId();
|
||||
if (category == this.cacheCategory) return;
|
||||
this.cacheCategory = category;
|
||||
|
||||
@@ -119,7 +108,7 @@ export class GirlListPanel extends li_BaseView {
|
||||
item.refreshData(category, id, this.node);
|
||||
item.node.active = true;
|
||||
this.cache.push(item);
|
||||
|
||||
|
||||
// 确保节点在 content 中(可能已经在了)
|
||||
if (item.node.parent !== this.content) {
|
||||
this.content.addChild(item.node);
|
||||
@@ -156,7 +145,7 @@ export class GirlListPanel extends li_BaseView {
|
||||
}
|
||||
}
|
||||
this.cache = [];
|
||||
|
||||
|
||||
// 清理 content 中所有的 GirlListItem 节点
|
||||
for (let i = this.content.children.length - 1; i >= 0; i--) {
|
||||
let child = this.content.children[i];
|
||||
|
||||
@@ -2,11 +2,8 @@ import { _decorator, Component, Label, Node } 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 {
|
||||
NavigationManager,
|
||||
PanelType,
|
||||
} from "../../manager/NavigationManager";
|
||||
|
||||
import { NavigationManager, PanelType } from "../../manager/NavigationManager";
|
||||
import { NavigationBtn } from "../items/NavigationBtn";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -15,20 +12,21 @@ export class NavigationPanel extends li_BaseView {
|
||||
private _nodeTab: any = {};
|
||||
private currentActivePanel: PanelType = PanelType.THEME;
|
||||
|
||||
private themeBtn: Node;
|
||||
private girlDetailBtn: Node;
|
||||
private chatBtn: Node;
|
||||
private settingBtn: Node;
|
||||
private themeBtn: NavigationBtn;
|
||||
private girlDetailBtn: NavigationBtn;
|
||||
private chatBtn: NavigationBtn;
|
||||
private settingBtn: NavigationBtn;
|
||||
|
||||
private loadingView: Node;
|
||||
|
||||
onLoadCT() {
|
||||
Utils.parseNode(this.node, this._nodeTab);
|
||||
|
||||
this.themeBtn = this._nodeTab.themeBtn;
|
||||
this.girlDetailBtn = this._nodeTab.girlDetailBtn;
|
||||
this.chatBtn = this._nodeTab.chatBtn;
|
||||
this.settingBtn = this._nodeTab.settingBtn;
|
||||
this.themeBtn = this._nodeTab.themeBtn.getComponent(NavigationBtn);
|
||||
this.girlDetailBtn =
|
||||
this._nodeTab.girlDetailBtn.getComponent(NavigationBtn);
|
||||
this.chatBtn = this._nodeTab.chatBtn.getComponent(NavigationBtn);
|
||||
this.settingBtn = this._nodeTab.settingBtn.getComponent(NavigationBtn);
|
||||
this.loadingView = this._nodeTab.loadingView;
|
||||
|
||||
this.hideLoading();
|
||||
@@ -46,22 +44,24 @@ export class NavigationPanel extends li_BaseView {
|
||||
private registerListener() {
|
||||
// 所有按钮点击都通过NavigationManager处理
|
||||
GButton.BandClick(
|
||||
this.themeBtn,
|
||||
() => NavigationManager.Instance.switchToPanel(PanelType.THEME),
|
||||
this.themeBtn.node,
|
||||
() => {
|
||||
NavigationManager.Instance.switchToPanel(PanelType.THEME);
|
||||
},
|
||||
this
|
||||
);
|
||||
GButton.BandClick(
|
||||
this.girlDetailBtn,
|
||||
this.girlDetailBtn.node,
|
||||
() => NavigationManager.Instance.switchToPanel(PanelType.GIRL_DETAIL),
|
||||
this
|
||||
);
|
||||
GButton.BandClick(
|
||||
this.chatBtn,
|
||||
this.chatBtn.node,
|
||||
() => NavigationManager.Instance.switchToPanel(PanelType.CHAT),
|
||||
this
|
||||
);
|
||||
GButton.BandClick(
|
||||
this.settingBtn,
|
||||
this.settingBtn.node,
|
||||
() => NavigationManager.Instance.switchToPanel(PanelType.SETTING),
|
||||
this
|
||||
);
|
||||
@@ -75,6 +75,7 @@ export class NavigationPanel extends li_BaseView {
|
||||
this.currentActivePanel = activePanel;
|
||||
this._nodeTab.CurrentPanel.getComponent(Label).string =
|
||||
this.currentActivePanel;
|
||||
|
||||
this.refreshButtonVisuals();
|
||||
}
|
||||
|
||||
@@ -88,6 +89,13 @@ export class NavigationPanel extends li_BaseView {
|
||||
"[NavigationPanel] Button states updated for:",
|
||||
this.currentActivePanel
|
||||
);
|
||||
|
||||
this.themeBtn.setFocus(this.currentActivePanel === PanelType.THEME);
|
||||
this.girlDetailBtn.setFocus(
|
||||
this.currentActivePanel === PanelType.GIRL_DETAIL
|
||||
);
|
||||
this.chatBtn.setFocus(this.currentActivePanel === PanelType.CHAT);
|
||||
this.settingBtn.setFocus(this.currentActivePanel === PanelType.SETTING);
|
||||
}
|
||||
|
||||
private initializeFirstPanel() {
|
||||
|
||||
Reference in New Issue
Block a user