update PastGirlListPanel.prefab

This commit is contained in:
2025-09-22 19:31:50 +08:00
parent bfa55f52da
commit 556194f24a
8 changed files with 560 additions and 284 deletions
+2 -2
View File
@@ -416,7 +416,7 @@ export default class Utils {
*/
public static formatChatTime(timestamp: number | null): string {
if (!timestamp) {
return "暂无聊天记录";
return LanguageUtils.getText("pastgirllistpanel.nomemory");
}
const now = new Date();
@@ -431,7 +431,7 @@ export default class Utils {
return `${hours}:${minutes}`;
} else if (diffDays < 7) {
// 一周内:显示x天前
return `${diffDays}${LanguageUtils.getText("purchasepanel.day")}}`;
return `${diffDays}${LanguageUtils.getText("purchasepanel.day")}`;
} else if (diffDays < 30) {
// 一个月内:显示x周前
const weeks = Math.floor(diffDays / 7);
@@ -27,6 +27,7 @@ import { TipsPanel } from "./TipsPanel";
import ResManager from "../../../Main/Manager/ResManager";
import { InnerMsgCode } from "../../../Main/Config/InnerMsgCode";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
import { GirlDetailPanel } from "./GirlDetailPanel";
const { ccclass, property } = _decorator;
@@ -41,7 +42,7 @@ export class GirlListPopupPanel extends li_BaseView {
private girlTag: Label;
private balanceCount: Label;
base: GirlListItem;
base: GirlDetailPanel;
img: Sprite;
uitransform: UITransform;
openUIDataCT(data) {
@@ -119,7 +120,7 @@ export class GirlListPopupPanel extends li_BaseView {
walletData.balance = Number(resData.balance);
walletData.vipExpire = Number(resData.vipExpire);
// 刷新界面
this.base.refreshBuy(true);
this.base.refresh();
this.close();
TipsPanel.show("Buy Succeed");
} else {
@@ -68,17 +68,21 @@ export class PastGirlListPanel extends li_BaseView {
item.reset();
}
}
protected onEnable(): void {
this.refresh();
}
// TODO: 实现获取已解锁女孩列表的逻辑
// 这个方法需要遍历所有分类,找出 isRelease === true 的女孩
private getUnlockedGirls(): number[] {
private async getUnlockedGirls(): Promise<number[]> {
await this.reqCanChatGirlData();
const GirlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
const allids = GirlData.getAllReleaseGirlIds();
const allids = GirlData.getAllCanChatGirlIds();
logger.log(allids);
return allids;
}
refresh() {
async refresh() {
// 回收当前显示的节点到缓存池
if (this.cache) {
for (let i = this.cache.length - 1; i >= 0; i--) {
@@ -89,24 +93,12 @@ export class PastGirlListPanel extends li_BaseView {
}
// 获取已解锁女孩列表
const ids = this.getUnlockedGirls();
// 创建带时间戳的数组用于排序
const girlsWithTime: { id: number; lastTime: number }[] = [];
// 收集每个女孩的最后聊天时间
for (let id of ids) {
const lastTime = ChatHistoryManager.Instance.getLastChatTime(id) || 0;
girlsWithTime.push({ id, lastTime });
}
// 按最后聊天时间降序排序(最近的在前)
girlsWithTime.sort((a, b) => b.lastTime - a.lastTime);
const ids = await this.getUnlockedGirls();
// 根据排序后的数据刷新界面
for (let girlData of girlsWithTime) {
for (let id of ids) {
let item = this.getItemFromPool();
item.refreshData(girlData.id, this.node);
item.refreshData(id, this.node);
item.node.active = true;
this.cache.push(item);
@@ -142,7 +134,7 @@ export class PastGirlListPanel extends li_BaseView {
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
girlData.setCanChatGirlData(resData);
}
}
}
onDestroy() {
// 清理缓存池,销毁所有缓存的节点
@@ -13,6 +13,7 @@ import { DataManager, DataId } from "../data/DataManager";
import { GirlData } from "../data/GirlData";
import { EnvData } from "../data/EnvData";
import { ChatHistoryManager } from "../manager/ChatHistoryManager";
import { ThemeData } from "../data/ThemeData";
const { ccclass, property } = _decorator;
@@ -29,6 +30,15 @@ export class PastGirlListItem extends Component {
@property(Node)
starParent: Node;
@property(Node)
freeTag: Node;
@property(UITransform)
categoryBg: UITransform;
@property(Label)
categoryTxt: Label;
@property(Node)
loading: Node;
stars: Sprite[];
@@ -83,6 +93,10 @@ export class PastGirlListItem extends Component {
this.girlName.string = LanguageUtils.getText(this.nameKey);
this.tagKey = girlData.getGrilTagKey(this.category.toString(), this.id);
this.freeTag.active = girlData.isGirlFreeType(
this.category.toString(),
this.id
);
// 标签显示
let desc = "";
const tags = LanguageUtils.getText(this.tagKey).split("|");
@@ -121,12 +135,28 @@ export class PastGirlListItem extends Component {
}
}
const themeData = DataManager.I.getDataById<ThemeData>(DataId.Theme);
const cat = girlData.getGrilCategoryById(this.id);
let key = themeData.getLanKeyById(1001 + cat);
this.categoryTxt.string = LanguageUtils.getText(key);
this.scheduleOnce(() => {
const size = this.categoryTxt.getComponent(UITransform).contentSize;
this.categoryBg.setContentSize(
size.x + 60,
this.categoryBg.contentSize.y
);
}, 0);
// 显示最近聊天时间
return this.updateLastChatTime();
}
private getLastChatTime(id: number): number | null {
return ChatHistoryManager.Instance.getLastChatTime(id);
const GirlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
return GirlData.getLatestChatRecordTimestamp(
this.category.toString(),
this.id
);
}
// 更新最近聊天时间显示
@@ -174,7 +204,7 @@ export class PastGirlListItem extends Component {
NavigationManager.Instance.setSelectedGirlId(this.id);
// 通过openSubPanel打开ChatPanel作为子面板
const chatData = { girlId: this.id };
const chatData = { base: this.baseNode };
NavigationManager.Instance.openSubPanel(
"ChatPanel",
this.baseNode,