This commit is contained in:
2025-10-10 16:09:14 +08:00
parent 561b3c5eee
commit df9ca6bfaa
66 changed files with 7433 additions and 7779 deletions
@@ -0,0 +1,35 @@
import { _decorator, Component, Node } from "cc";
import li_BaseView from "../../../Main/Common/li_BaseView";
import Utils from "../../../Main/Common/Utils";
import { GButton } from "../../../Main/Common/GButton";
import {
NavigationManager,
PageTransitionType,
} from "../../manager/NavigationManager";
const { ccclass, property } = _decorator;
@ccclass("ChargePopPanel")
export class ChargePopPanel extends li_BaseView {
private _nodeTab: any = {};
onLoad(): void {
Utils.parseNode(this.node, this._nodeTab);
GButton.BandClick(this._nodeTab.chargeBtn, this.gotoCharge, this);
GButton.BandClick(this._nodeTab.closeBtn, this.close, this);
}
gotoCharge() {
NavigationManager.Instance.openSubPanel(
"PurchasePanel",
NavigationManager.Instance.getCurrentActivePanelNode(),
{ base: NavigationManager.Instance.getCurrentActivePanelNode() },
{
openAnimation: PageTransitionType.SLIDE_LEFT,
closeAnimation: PageTransitionType.SLIDE_RIGHT,
}
);
this.close();
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "cf896a69-cffb-42e9-88fe-f2772f2f7fd5",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -78,8 +78,7 @@ export class GirlDetailPanel extends li_BaseView {
imgsLayout: Node;
videoAreaPos: Vec3;
@property(Label)
girlPrice: Label;
@property(Node)
sendMsgText: Node;
@@ -113,12 +112,12 @@ export class GirlDetailPanel extends li_BaseView {
Utils.addInnerEL(InnerMsgCode.LanguageChange, this, () => {
this.girlName.string = LanguageUtils.getText(this.nameKey);
let desc = "";
const tags = LanguageUtils.getText(this.tagKey).split("|");
for (let i = 0; i < tags.length; i++) {
if (i != 0) desc += "\n";
desc += tags[i];
}
this.tags.string = desc;
const tags = LanguageUtils.getText(this.tagKey);
// for (let i = 0; i < tags.length; i++) {
// if (i != 0) desc += "\n";
// desc += tags[i];
// }
this.tags.string = tags;
this.desc.string = LanguageUtils.getText(this.descKey);
});
@@ -190,20 +189,7 @@ export class GirlDetailPanel extends li_BaseView {
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
const isRelease = girlData.getIsRelease(this.category.toString(), this.id);
const isFree = girlData.isGirlFreeType(this.category.toString(), this.id);
//if (isRelease || isFree) {
// 先设置选中的角色ID
this.girlPrice.node.active = false;
this.sendMsgText.active = true;
// } else {
// this.girlPrice.node.active = true;
// this.sendMsgText.active = false;
// this.girlPrice.string = girlData
// .getGrilOriginalPrice(this.category.toString(), this.id)
// .toString();
// }
// 请求详细数据
const reqData = {
@@ -27,7 +27,7 @@ export class PastGirlListPanel extends li_BaseView {
onLoadCT() {
Utils.parseNode(this.node, this._nodeTab);
this.registerListener();
this.itemInst = this._nodeTab.BubbleItem.getComponent(PastGirlListItem);
this.itemInst = this._nodeTab.recItem.getComponent(PastGirlListItem);
this.itemInst.node.active = false;
this.content = this._nodeTab.content;
//this.refresh();
@@ -23,6 +23,7 @@ import { ImagePopup } from "../components/ImagePopup";
import { TipsPanel } from "./TipsPanel";
import ResManager from "../../../Main/Manager/ResManager";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
import { NavigationManager } from "../../manager/NavigationManager";
const { ccclass, property } = _decorator;
@@ -35,9 +36,6 @@ export class PopupGirlDetailPanel extends li_BaseView {
private resId: number;
private type: proto.cs.EnmResType;
private base: DetailImageItem | ImagePopup;
private balanceCount: Label;
private desc: Label;
img: Sprite;
uitransform: UITransform;
@@ -55,11 +53,8 @@ export class PopupGirlDetailPanel extends li_BaseView {
.start();
Utils.parseNode(this.node, this._nodeTab);
this.desc = this._nodeTab.content.getComponent(Label);
this.uitransform = this._nodeTab.Img_Frame.getComponent(UITransform);
this.img = this._nodeTab.img.getComponent(Sprite);
let descText = LanguageUtils.getText("popupgirldetailpanel.content");
this.balanceCount = this._nodeTab.balanceCount.getComponent(Label);
this.refreshCoinNum();
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
@@ -104,18 +99,17 @@ export class PopupGirlDetailPanel extends li_BaseView {
ResManager.I.changeRemoteSpriteFrame(this.img, newPath, () => {
this.scaleToFillItem();
});
this.desc.string = descText.replace("{price}", this.priceLabel.string);
this.registerListener();
}
registerListener() {
GButton.BandClick(this._nodeTab.BuyBtn, this.buyCharacter, this);
GButton.BandClick(this._nodeTab.BuyBtn, this.buyAsset, this);
GButton.BandClick(this._nodeTab.CloseBtn, this.Close, this);
}
Close() {
this.close();
}
async buyCharacter() {
async buyAsset() {
// 购买id为girlId的女生
logger.log(this.girlId + "---" + this.resId);
@@ -147,17 +141,16 @@ export class PopupGirlDetailPanel extends li_BaseView {
} else {
this.base.refreshSelf();
}
this.close();
TipsPanel.show("Buy Succeed");
NavigationManager.Instance.openPopupPanel("ReleasePanel");
} else {
TipsPanel.show("Insufficient balance, need to purchase");
NavigationManager.Instance.openPopupPanel("ChargePopPanel");
}
this.close();
}
// 刷新余额
private refreshCoinNum() {
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
const balance = walletData.getOriginalBalance();
this.balanceCount.string = balance.toString();
}
scaleToFillItem() {
if (!this.img || !this.img.spriteFrame) return;
@@ -0,0 +1,6 @@
import { _decorator, Component, Node } from "cc";
import li_BaseView from "../../../Main/Common/li_BaseView";
const { ccclass, property } = _decorator;
@ccclass("RankPanel")
export class RankPanel extends li_BaseView {}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "b738c201-567f-4b37-b10c-a3036032875d",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,18 @@
import { _decorator, Component, Node, tween, UIOpacity, Vec3 } from "cc";
import li_BaseView from "../../../Main/Common/li_BaseView";
const { ccclass, property } = _decorator;
@ccclass("ReleasePanel")
export class ReleasePanel extends li_BaseView {
onLoadCT(): void {
this.scheduleOnce(this.autoClose, 1);
}
private autoClose() {
this.closePanel();
}
private closePanel() {
this.close();
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "561267a1-b596-4747-af9d-438197888777",
"files": [],
"subMetas": {},
"userData": {}
}
+84 -74
View File
@@ -32,6 +32,7 @@ import { EnvData } from "../../data/EnvData";
import proto from "db://assets/Scripts/proto/proto.pb.js";
import { MainController } from "../../core/MainController";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
import { RecomandItem } from "../../uiitems/RecomandItem";
const { ccclass, property } = _decorator;
@@ -40,15 +41,20 @@ export class ThemePanel extends li_BaseView {
private _nodeTab: any = {};
coinNum: Label;
itemInst: ThemeItem;
content: Node;
recItemInst: RecomandItem;
themeContent: Node;
recGirlContent: Node;
private vipLeftTime: Label;
recId: number;
recName: Label;
recSprite: Sprite;
//recName: Label;
//recSprite: Sprite;
cache: ThemeItem[] = [];
recItemCache: RecomandItem[] = [];
// 子页面管理
// 加载状态保护
@@ -56,23 +62,38 @@ export class ThemePanel extends li_BaseView {
private loadingPromise: Promise<void> | null = null;
private abortController: AbortController | null = null;
private recomandListBtn: Node;
private moreThemeBtn: Node;
private themeScroll: Node;
private recomandScroll: Node;
onLoadCT() {
Utils.parseNode(this.node, this._nodeTab);
this.coinNum = this._nodeTab.coinNum.getComponent(Label);
this.recName = this._nodeTab.characterNameText.getComponent(Label);
this.recSprite = this._nodeTab.recPic.getComponent(Sprite);
//this.recName = this._nodeTab.characterNameText.getComponent(Label);
//this.recSprite = this._nodeTab.recPic.getComponent(Sprite);
this.vipLeftTime = this._nodeTab.vipText.getComponent(Label);
this.recomandListBtn = this._nodeTab.recomandList;
this.moreThemeBtn = this._nodeTab.moreTheme;
this.themeScroll = this._nodeTab.themeScroll;
this.recomandScroll = this._nodeTab.recomandScroll;
this.registerListener();
this.itemInst = this._nodeTab.ThemeItem.getComponent(ThemeItem);
this.itemInst.node.active = false;
this.content = this._nodeTab.allThemecontent;
this.recItemInst = this._nodeTab.recItem.getComponent(RecomandItem);
this.recItemInst.node.active = false;
this.themeContent = this._nodeTab.allThemecontent;
this.recGirlContent = this._nodeTab.allRecGirlContent;
this.Show();
}
rectNameKey: string;
async Show(forceRefresh: boolean = false) {
// 防止重复加载
if (this.isLoading) {
@@ -84,7 +105,7 @@ export class ThemePanel extends li_BaseView {
}
this.isLoading = true;
this.loadingPromise = this._showInternal(forceRefresh);
this.loadingPromise = this._refreshDataInternal(forceRefresh);
try {
await this.loadingPromise;
@@ -92,9 +113,11 @@ export class ThemePanel extends li_BaseView {
this.isLoading = false;
this.loadingPromise = null;
}
this.openRecomandList();
}
private async _showInternal(forceRefresh: boolean = false) {
private async _refreshDataInternal(forceRefresh: boolean = false) {
// 创建新的AbortController用于取消操作
this.abortController = new AbortController();
const signal = this.abortController.signal;
@@ -108,7 +131,6 @@ export class ThemePanel extends li_BaseView {
DataId.Account
);
//this.uid.string = "uid: " + accountData.accId;
this.recId = 1;
// 检查是否已被取消
if (signal.aborted) {
@@ -146,7 +168,7 @@ export class ThemePanel extends li_BaseView {
}
// 处理每日推荐数据
await this.handleDailyRecommendData(preloadStatus.dailyRecommend);
await this.handleRecommendData(preloadStatus.dailyRecommend);
// 检查是否已被取消
if (signal.aborted) {
@@ -180,7 +202,6 @@ export class ThemePanel extends li_BaseView {
// 直接使用预加载的数据渲染界面
const themeData = DataManager.I.getDataById<ThemeData>(DataId.Theme);
if (themeData && themeData.themes) {
this.renderThemeData(themeData);
return;
}
}
@@ -193,14 +214,16 @@ export class ThemePanel extends li_BaseView {
// 保存数据
const themeData = DataManager.I.getDataById<ThemeData>(DataId.Theme);
themeData.themes = res.data;
this.renderThemeData(themeData);
}
}
/**
* 渲染主题数据
*/
private renderThemeData(themeData: ThemeData): void {
private renderThemeData(): void {
if (this.cache.length > 0) return;
const themeData = DataManager.I.getDataById<ThemeData>(DataId.Theme);
const themeIds = themeData.themeIds;
for (let id of themeIds) {
let newNode = instantiate(this.itemInst.node);
@@ -208,20 +231,19 @@ export class ThemePanel extends li_BaseView {
item.refresh(id, this.node);
newNode.active = true;
this.cache.push(item);
this.content.addChild(newNode);
this.themeContent.addChild(newNode);
}
}
/**
* 处理每日推荐数据
* 处理推荐数据
*/
private async handleDailyRecommendData(isPreloaded: boolean): Promise<void> {
private async handleRecommendData(isPreloaded: boolean): Promise<void> {
if (isPreloaded) {
logger.log("[ThemePanel] 使用预加载的每日推荐数据");
// 直接使用预加载的数据渲染界面
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
if (girlData) {
this.renderDailyRecommendData(girlData);
return;
}
}
@@ -233,29 +255,30 @@ export class ThemePanel extends li_BaseView {
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
girlData.setDailyRecommend(res.data);
this.renderDailyRecommendData(girlData);
}
}
/**
* 渲染每日推荐数据
*/
private renderDailyRecommendData(girlData: GirlData): void {
this.recId = girlData.getRecommendGirlId();
this.rectNameKey = girlData.getRecommendGrilName();
let avatarPath = girlData.getRecommendGrilAvatar();
this.recName.string = LanguageUtils.getText(this.rectNameKey);
// 加载远程资源
const envData = DataManager.I.getDataById<EnvData>(DataId.Env);
let newPath = envData.cdn + "/" + "Girls/" + avatarPath + ".png";
ResManager.I.changeRemoteSpriteFrame(this.recSprite, newPath, () => {
let sizeTran = this.recSprite.node.parent.getComponent(UITransform);
Utils.adjustBgPixelRatioToSize(
sizeTran.contentSize,
this.recSprite.node,
1
);
});
private renderRecommendData(): void {
if (this.recItemCache.length > 0) return;
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
let girlIDs = [];
girlIDs.push(girlData.getRecommendGirlId());
for (let id of girlIDs) {
let newNode = instantiate(this.recItemInst.node);
let item = newNode.getComponent(RecomandItem);
item.init();
item.refresh(id);
newNode.active = true;
this.recItemCache.push(item);
this.recGirlContent.addChild(newNode);
}
console.error("未实现每日推荐数据渲染");
}
/**
@@ -274,13 +297,11 @@ export class ThemePanel extends li_BaseView {
}
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);
GButton.BandClick(this._nodeTab.ShopPanelEntry, this.enterShop, this);
GButton.BandClick(this.recomandListBtn, this.openRecomandList, this);
GButton.BandClick(this.moreThemeBtn, this.openMoreTheme, this);
Utils.addInnerEL(InnerMsgCode.LanguageChange, this, this.onLanguageChange);
Utils.addInnerEL(InnerMsgCode.BalanceChange, this, this.onBalanceChange);
Utils.addInnerEL(
@@ -302,43 +323,32 @@ export class ThemePanel extends li_BaseView {
);
}
chatWithRec() {
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
openRecomandList() {
this.themeScroll.active = false;
this.recomandScroll.active = true;
// 是否已经解锁
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.setSelectedGirlId(this.recId);
NavigationManager.Instance.setSelectedCategoryId(
girlData.getGrilCategoryById(this.recId)
);
NavigationManager.Instance.switchToPanel(PanelType.GIRL_DETAIL);
// } else {
// //未解锁
//todo:是否需要刷新数据
this.renderRecommendData();
// NavigationManager.Instance.openPopupPanel("GirlListPopupPanel", {
// base: this,
// category: girlData.getGrilCategoryById(this.recId),
// id: this.recId,
// });
// }
this.updateTagState(true);
}
openMoreTheme() {
this.themeScroll.active = true;
this.recomandScroll.active = false;
//todo:是否需要刷新数据
this.renderThemeData();
this.updateTagState(false);
}
openSetting() {
// 通过NavigationManager切换到个人信息面板,保持动画和状态同步
NavigationManager.Instance.openSubPanel("SettingPanel", this.node);
}
updateTagState(isRecomnend: boolean) {
this.recomandListBtn.children[0].active = !isRecomnend;
this.recomandListBtn.children[1].active = isRecomnend;
openMsgBox() {
logger.log("打开信箱");
this.moreThemeBtn.children[0].active = isRecomnend;
this.moreThemeBtn.children[1].active = !isRecomnend;
}
// 刷新余额
@@ -445,7 +455,7 @@ export class ThemePanel extends li_BaseView {
// 事件回调函数(避免匿名函数导致的内存泄漏)
private onLanguageChange = () => {
this.recName.string = LanguageUtils.getText(this.rectNameKey);
//this.recName.string = LanguageUtils.getText(this.rectNameKey);
this.refreshVipExpire();
};