This commit is contained in:
2025-10-10 18:21:33 +08:00
parent ea914bd167
commit 4d730fe9cb
19 changed files with 2118 additions and 1239 deletions
+4 -4
View File
@@ -394,14 +394,14 @@ export default class Utils {
minutes
);
if (days > 0) {
return `${days}${LanguageUtils.getText("purchasepanel.day")}`;
return `${days} ${LanguageUtils.getText("purchasepanel.day")}`;
}
if (hours > 0) {
return `${hours}${LanguageUtils.getText(
return `${hours} ${LanguageUtils.getText(
"purchasepanel.hour"
)}:${minutes}${LanguageUtils.getText("purchasepanel.minute")}`;
)}:${minutes} ${LanguageUtils.getText("purchasepanel.minute")}`;
}
return `${minutes}${LanguageUtils.getText("purchasepanel.minute")}`;
return `${minutes} ${LanguageUtils.getText("purchasepanel.minute")}`;
}
/**
@@ -27,7 +27,7 @@ export enum PageTransitionType {
*/
export enum PanelType {
THEME = "ThemePanel",
GIRL_DETAIL = "GirlDetailPanel",
RANK = "RankPanel",
PAST_GIRL_LIST = "PastGirlListPanel",
PERSONAL = "PersonalPanel",
}
@@ -49,6 +49,7 @@ export interface SubPanelAnimationConfig {
openAnimation: PageTransitionType;
closeAnimation: PageTransitionType;
duration?: number;
hideBasePanel?: boolean; // 是否隐藏basePanel,用于全屏子面板
}
/**
@@ -195,6 +196,9 @@ export class NavigationManager {
private subPanelAnimationConfigs: Map<Node, SubPanelAnimationConfig> =
new Map();
// 隐藏的basePanel映射:subPanel -> basePanel
private hiddenBasePanels: Map<Node, Node> = new Map();
// 弹窗管理相关属性
private popupPanels: Set<Node> = new Set(); // 管理所有打开的弹窗
@@ -330,9 +334,16 @@ export class NavigationManager {
openAnimation: PageTransitionType.SCALE,
closeAnimation: PageTransitionType.SCALE,
duration: 0.3,
hideBasePanel: false,
};
const config = animationConfig || defaultConfig;
// 如果需要隐藏basePanel,在打开动画前隐藏
if (config.hideBasePanel && basePanel.active) {
logger.log(`[NavigationManager] 隐藏basePanel: ${basePanel.name}`);
basePanel.active = false;
}
const callback = (n: Node) => {
if (!n || !n.isValid) {
logger.error(
@@ -359,6 +370,12 @@ export class NavigationManager {
// 存储动画配置
this.subPanelAnimationConfigs.set(n, config);
// 如果配置了隐藏basePanel,记录映射关系
if (config.hideBasePanel) {
this.hiddenBasePanels.set(n, basePanel);
logger.log(`[NavigationManager] 记录隐藏映射: ${n.name} -> ${basePanel.name}`);
}
// 执行打开动画
this.playSubPanelOpenAnimation(n, config);
};
@@ -592,11 +609,22 @@ export class NavigationManager {
openAnimation: PageTransitionType.SCALE,
closeAnimation: PageTransitionType.SCALE,
duration: 0.3,
hideBasePanel: false,
};
}
// 执行关闭动画
this.playSubPanelCloseAnimation(panelNode, config, () => {
// 如果隐藏了basePanel,需要恢复显示
if (this.hiddenBasePanels.has(panelNode)) {
const basePanel = this.hiddenBasePanels.get(panelNode);
if (basePanel && basePanel.isValid) {
logger.log(`[NavigationManager] 恢复显示basePanel: ${basePanel.name}`);
basePanel.active = true;
}
this.hiddenBasePanels.delete(panelNode);
}
// 从管理映射中移除
this.removeSubPanelFromMappings(panelNode);
@@ -643,6 +671,11 @@ export class NavigationManager {
if (this.subPanelAnimationConfigs.has(panelNode)) {
this.subPanelAnimationConfigs.delete(panelNode);
}
// 移除隐藏映射
if (this.hiddenBasePanels.has(panelNode)) {
this.hiddenBasePanels.delete(panelNode);
}
}
/**
@@ -652,7 +685,7 @@ export class NavigationManager {
switch (panelType) {
case PanelType.THEME:
return 0;
case PanelType.GIRL_DETAIL:
case PanelType.RANK:
return 1;
case PanelType.PAST_GIRL_LIST:
return 2;
@@ -671,8 +704,8 @@ export class NavigationManager {
switch (node.name) {
case "ThemePanel":
return PanelType.THEME;
case "GirlDetailPanel":
return PanelType.GIRL_DETAIL;
case "RankPanel":
return PanelType.RANK;
case "PastGirlListPanel":
return PanelType.PAST_GIRL_LIST;
case "PersonalPanel":
@@ -696,12 +729,8 @@ export class NavigationManager {
* 获取面板数据
*/
private getPanelData(panelType: PanelType): any {
switch (panelType) {
case PanelType.GIRL_DETAIL:
return this.selectedGirlId; // 使用当前选中的角色ID
default:
return null;
}
// 所有主页面都不需要特殊数据
return null;
}
/**
@@ -349,7 +349,8 @@ export class GirlDetailPanel extends li_BaseView {
}
returnBtn() {
NavigationManager.Instance.switchToPanel(PanelType.THEME);
// GirlDetailPanel现在是subpanel,关闭自己即可
NavigationManager.Instance.closeSubPanel(this);
}
/**
@@ -445,9 +446,9 @@ export class GirlDetailPanel extends li_BaseView {
}
// 回收所有使用中的节点到对象池
for (let i = this.imgsLayout.children.length - 1; i >= 0; i--) {
DetailImageItemPool.Instance.put(this.imgsLayout.children[i]);
}
// for (let i = this.imgsLayout.children.length - 1; i >= 0; i--) {
// DetailImageItemPool.Instance.put(this.imgsLayout.children[i]);
// }
super.onDestroy();
}
@@ -16,7 +16,7 @@ export class NavigationPanel extends li_BaseView {
private currentActivePanel: PanelType = PanelType.THEME;
private themeBtn: NavigationBtn;
private girlDetailBtn: NavigationBtn;
private rankBtn: NavigationBtn;
private pastGirlListBtn: NavigationBtn;
private settingBtn: NavigationBtn;
@@ -26,8 +26,7 @@ export class NavigationPanel extends li_BaseView {
Utils.parseNode(this.node, this._nodeTab);
this.themeBtn = this._nodeTab.themeBtn.getComponent(NavigationBtn);
this.girlDetailBtn =
this._nodeTab.girlDetailBtn.getComponent(NavigationBtn);
this.rankBtn = this._nodeTab.rankBtn.getComponent(NavigationBtn);
this.pastGirlListBtn = this._nodeTab.chatBtn.getComponent(NavigationBtn);
this.settingBtn = this._nodeTab.settingBtn.getComponent(NavigationBtn);
this.loadingView = this._nodeTab.loadingView;
@@ -54,8 +53,8 @@ export class NavigationPanel extends li_BaseView {
this
);
GButton.BandClick(
this.girlDetailBtn.node,
() => NavigationManager.Instance.switchToPanel(PanelType.GIRL_DETAIL),
this.rankBtn.node,
() => NavigationManager.Instance.switchToPanel(PanelType.RANK),
this
);
GButton.BandClick(
@@ -108,9 +107,7 @@ export class NavigationPanel extends li_BaseView {
);
this.themeBtn.setFocus(this.currentActivePanel === PanelType.THEME);
this.girlDetailBtn.setFocus(
this.currentActivePanel === PanelType.GIRL_DETAIL
);
this.rankBtn.setFocus(this.currentActivePanel === PanelType.RANK);
this.pastGirlListBtn.setFocus(
this.currentActivePanel === PanelType.PAST_GIRL_LIST
);
@@ -1,8 +1,4 @@
import {
_decorator,
Label,
Sprite,
} from "cc";
import { _decorator, isCCObject, Label, Node, Sprite } from "cc";
import Utils from "../../../Main/Common/Utils";
import li_BaseView from "../../../Main/Common/li_BaseView";
import { GButton } from "../../../Main/Common/GButton";
@@ -10,8 +6,7 @@ import { DataManager, DataId } from "../../data/DataManager";
import { PlayerData } from "../../data/PlayerData";
import { AccountData } from "../../data/AccountData";
import { WalletData } from "../../data/WalletData";
import LanguageUtils, {
} from "../../../Main/Common/LanguageUtils";
import LanguageUtils from "../../../Main/Common/LanguageUtils";
import {
NavigationManager,
PageTransitionType,
@@ -19,6 +14,7 @@ import {
import { PlayerDataService } from "../../network/services/PlayerDataService";
import proto from "db://assets/Scripts/proto/proto.pb.js";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
import { TipsPanel } from "./TipsPanel";
const { ccclass, property } = _decorator;
@@ -41,6 +37,12 @@ export class PersonalPanel extends li_BaseView {
@property(Sprite)
private avatarSprite: Sprite = null;
@property([Node])
private vipStuff: Node[] = [];
@property([Node])
private notVipStuff: Node[] = [];
private playerData: PlayerData = null;
private accountData: AccountData = null;
private walletData: WalletData = null;
@@ -79,6 +81,11 @@ export class PersonalPanel extends li_BaseView {
if (this._nodeTab.settingBtn) {
GButton.BandClick(this._nodeTab.settingBtn, this.openSettings, this);
}
//
if (this._nodeTab.favoritesBtn) {
GButton.BandClick(this._nodeTab.favoritesBtn, this.openFavorites, this);
}
}
private async refresh() {
@@ -125,20 +132,25 @@ export class PersonalPanel extends li_BaseView {
}
private updateVipStatus(): void {
let isVip = false;
if (this.vipStatusLabel && this.walletData) {
const vipExpire = this.walletData.vipExpire;
if (vipExpire && vipExpire > Date.now()) {
const expireDate = new Date(vipExpire);
this.vipStatusLabel.string = `${LanguageUtils.getText(
"purchasepanel.vip_left"
)} ${expireDate.toLocaleDateString()}`;
if (vipExpire && this.walletData.isVip) {
const leftTime = Utils.formatVipLeftTime(vipExpire);
this.vipStatusLabel.string = leftTime;
isVip = true;
} else {
this.vipStatusLabel.string = LanguageUtils.getText(
"purchasepanel.notvip"
);
// this.vipStatusLabel.string = LanguageUtils.getText(
// "purchasepanel.notvip"
// );
}
}
this.vipStuff.forEach((n) => (n.active = isVip));
this.notVipStuff.forEach((n) => (n.active = !isVip));
}
private openSettings(): void {
@@ -156,4 +168,8 @@ export class PersonalPanel extends li_BaseView {
}
);
}
private openFavorites() {
TipsPanel.show("敬请期待~");
}
}
@@ -16,7 +16,7 @@ import { NavigationManager } from "../../manager/NavigationManager";
import { Web3PopPanel } from "./Web3PopPanel";
import { TipsPanel } from "./TipsPanel";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
import { PaymentMethod } from 'db://assets/Scripts/chat18x/payment/types';
import { PaymentMethod } from "db://assets/Scripts/chat18x/payment/types";
const { ccclass, property } = _decorator;
@@ -30,8 +30,6 @@ export class PurchasePanel extends li_BaseView {
private vipPrice30: Label;
private vipTime30: Label;
private ScrollView: ScrollView;
private currentPayType: proto.cs.EnmPayType =
proto.cs.EnmPayType.EPT_Cash_INR;
private defaultNetworkType: proto.cs.EnmNetworkType =
@@ -44,9 +42,7 @@ export class PurchasePanel extends li_BaseView {
}
cashBtnSelecting;
cashBtnNotSelect;
web3BtnSelecting;
web3BtnNotSelect;
base: Node;
openUIDataCT(data: any): void {
@@ -66,12 +62,8 @@ export class PurchasePanel extends li_BaseView {
this.vipPrice30 = this._nodeTab.vipPrice30.getComponent(Label);
this.vipTime30 = this._nodeTab.vipTime30.getComponent(Label);
this.ScrollView = this._nodeTab.ScrollView.getComponent(ScrollView);
this.cashBtnSelecting = this._nodeTab.cashBtn.getChildByName("selecting");
this.cashBtnNotSelect = this._nodeTab.cashBtn.getChildByName("notSelect");
this.web3BtnSelecting = this._nodeTab.web3Btn.getChildByName("selecting");
this.web3BtnNotSelect = this._nodeTab.web3Btn.getChildByName("notSelect");
this.bandBtn();
@@ -172,7 +164,6 @@ export class PurchasePanel extends li_BaseView {
const memberId30 = this.shopData.get30DayMemberId();
const price30 = this.shopData.getOriginalPriceById(memberId30);
this.vipPrice30.string = `$ ${price30}`;
this.ScrollView.scrollToBottom();
}
// 0:cash 1:web3
@@ -195,7 +186,12 @@ export class PurchasePanel extends li_BaseView {
const isRechargeId = shopData.isRechargeId(id);
if (isRechargeId) {
// 需要外部支付进行购买
this.startPayment(id, this.currentPayType, networkType, PaymentMethod.CashPay);
this.startPayment(
id,
this.currentPayType,
networkType,
PaymentMethod.CashPay
);
}
//测试用
// Utils.sendInnerMsg(InnerMsgCode.PayOrderCreateSucc, {
@@ -288,7 +284,12 @@ export class PurchasePanel extends li_BaseView {
}
// 创建订单
async startPayment(goodId: number, payType: number, network: number, payMethod: PaymentMethod) {
async startPayment(
goodId: number,
payType: number,
network: number,
payMethod: PaymentMethod
) {
// 请求数据
const reqData = {
goodId,
@@ -319,15 +320,15 @@ export class PurchasePanel extends li_BaseView {
onClickCashBtn() {
if (this.curPayType == 0) return;
this.curPayType = 0;
this.cashBtnSelecting.active = this.web3BtnNotSelect.active = true;
this.cashBtnNotSelect.active = this.web3BtnSelecting.active = false;
this.cashBtnSelecting.active = true;
this.web3BtnSelecting.active = false;
this.updateShops(0);
}
onClickWeb3Btn() {
if (this.curPayType == 1) return;
this.curPayType = 1;
this.cashBtnSelecting.active = this.web3BtnNotSelect.active = false;
this.cashBtnNotSelect.active = this.web3BtnSelecting.active = true;
this.cashBtnSelecting.active = false;
this.web3BtnSelecting.active = true;
this.updateShops(1);
}
@@ -372,9 +372,7 @@ export class ThemePanel extends li_BaseView {
if (leftTime == null) {
LanguageUtils.getText("purchasepanel.notvip");
} else {
this.vipLeftTime.string = LanguageUtils.getText(
"purchasepanel.vip_left"
).replace("${leftTime}", leftTime);
this.vipLeftTime.string = leftTime;
}
}
}
+42 -14
View File
@@ -10,7 +10,11 @@ import {
} from "cc";
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
import Utils from "db://assets/Scripts/Main/Common/Utils";
import { NavigationManager, PanelType } from "../manager/NavigationManager";
import {
NavigationManager,
PanelType,
PageTransitionType,
} from "../manager/NavigationManager";
import { PriceType } from "../../schema/schema";
import LanguageUtils from "../../Main/Common/LanguageUtils";
import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
@@ -172,22 +176,46 @@ export class GirlListItem extends Component {
onClickDetail() {
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
// 是否已经解锁
const isRelease = girlData.getIsRelease(this.category.toString(), this.id);
NavigationManager.Instance.setSelectedGirlId(this.id);
NavigationManager.Instance.setSelectedCategoryId(this.category);
// 通过switchToPanel切换到角色详情面板,保持动画和状态同步
NavigationManager.Instance.switchToPanel(PanelType.GIRL_DETAIL);
// 以subpanel方式打开GirlDetailPanel
const currentPanel = NavigationManager.Instance.getCurrentActivePanelNode();
if (currentPanel) {
NavigationManager.Instance.openSubPanel(
"GirlDetailPanel",
currentPanel,
this.id,
{
openAnimation: PageTransitionType.SLIDE_LEFT,
closeAnimation: PageTransitionType.SLIDE_RIGHT,
hideBasePanel: true, // 隐藏底层panel,实现全屏显示
}
);
} else {
logger.warn("[GirlListItem] 无法获取当前激活的主页面");
}
}
// if (isRelease) {
// // 先设置选中的角色ID
// } else {
// //未解锁
// NavigationManager.Instance.openPopupPanel("GirlListPopupPanel", {
// base: this,
// category: this.category,
// id: this.id,
// });
// }
onClickChat() {
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
NavigationManager.Instance.setSelectedGirlId(this.id);
NavigationManager.Instance.setSelectedCategoryId(
girlData.getGrilCategoryById(this.id)
);
NavigationManager.Instance.switchToPanel(
PanelType.PAST_GIRL_LIST,
false,
(base) => {
const chatData = { girlId: this.id, base: base };
NavigationManager.Instance.openSubPanel("ChatPanel", base, chatData, {
openAnimation: PageTransitionType.SLIDE_LEFT,
closeAnimation: PageTransitionType.SLIDE_RIGHT,
});
}
);
}
}
+37 -6
View File
@@ -6,7 +6,12 @@ import { GirlData } from "../data/GirlData";
import LanguageUtils from "../../Main/Common/LanguageUtils";
import ResManager from "../../Main/Manager/ResManager";
import { EnvData } from "../data/EnvData";
import { NavigationManager, PanelType } from "../manager/NavigationManager";
import {
NavigationManager,
PanelType,
PageTransitionType,
} from "../manager/NavigationManager";
import { logger } from "../../Main/Common/Logger";
const { ccclass, property } = _decorator;
@ccclass("RecomandItem")
@@ -39,7 +44,7 @@ export class RecomandItem extends Component {
this.chatBtn = this._nodeTab.chatBtn;
GButton.BandClick(this.chatBtn, this.chatToHer, this);
GButton.BandClick(this.chatBtn, this.gotoDetail, this);
GButton.BandClick(this._nodeTab.detailBtn, this.gotoDetail, this);
}
refresh(girlId: number) {
@@ -80,16 +85,42 @@ export class RecomandItem extends Component {
NavigationManager.Instance.setSelectedCategoryId(
girlData.getGrilCategoryById(this.id)
);
NavigationManager.Instance.switchToPanel(PanelType.GIRL_DETAIL);
NavigationManager.Instance.switchToPanel(
PanelType.PAST_GIRL_LIST,
false,
(base) => {
const chatData = { girlId: this.id, base: base };
NavigationManager.Instance.openSubPanel("ChatPanel", base, chatData, {
openAnimation: PageTransitionType.SLIDE_LEFT,
closeAnimation: PageTransitionType.SLIDE_RIGHT,
});
}
);
}
gotoDetail()
{
gotoDetail() {
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
NavigationManager.Instance.setSelectedGirlId(this.id);
NavigationManager.Instance.setSelectedCategoryId(
girlData.getGrilCategoryById(this.id)
);
NavigationManager.Instance.switchToPanel(PanelType.GIRL_DETAIL);
// 以subpanel方式打开GirlDetailPanel
const currentPanel = NavigationManager.Instance.getCurrentActivePanelNode();
if (currentPanel) {
NavigationManager.Instance.openSubPanel(
"GirlDetailPanel",
currentPanel,
this.id,
{
openAnimation: PageTransitionType.SLIDE_LEFT,
closeAnimation: PageTransitionType.SLIDE_RIGHT,
hideBasePanel: true, // 隐藏底层panel,实现全屏显示
}
);
} else {
logger.warn("[RecomandItem] 无法获取当前激活的主页面");
}
}
}