From bfa55f52dac49c103b3aa627bf6c3187ffec4ec8 Mon Sep 17 00:00:00 2001 From: chen wei bo <1025839511@qq.com> Date: Mon, 22 Sep 2025 18:41:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=8F=AF=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E7=9A=84=E6=8A=80=E5=B8=88=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Scripts/chat18x/data/GirlData.ts | 47 +++++++++++++++++-- .../chat18x/ui/panels/PastGirlListPanel.ts | 16 +++++++ 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/assets/Scripts/chat18x/data/GirlData.ts b/assets/Scripts/chat18x/data/GirlData.ts index 01d49951..00f5d278 100644 --- a/assets/Scripts/chat18x/data/GirlData.ts +++ b/assets/Scripts/chat18x/data/GirlData.ts @@ -1014,15 +1014,52 @@ export class GirlData extends BaseData { for (const [categoryId, bucket] of cats.entries()) { for (const girlId of bucket.girlIds) { - - - - - if (this.getIsRelease(categoryId, girlId)) { + if (this.isCanChat(categoryId, girlId)) { result.push(girlId); } } } + // 排序 + // 1,都存在聊天记录,按照聊天时间从近到远,否则,有聊天记录的排在前面 + // 2,都没有聊天记录 + // 2.1,付费类型角色排在前面,免费类型角色排在后面 + // 2.2,如果角色都是付费类型,则角色id越大,排在前面 + // 2.3,如果角色都是免费类型,则角色id越大,排在前面 + result.sort((a, b) => { + const categoryIdA = this.getGrilCategoryById(a); + const categoryIdB = this.getGrilCategoryById(b); + // 先取最新聊天时间戳 + const tsA = this.getLatestChatRecordTimestamp(categoryIdA.toString(), a); + const tsB = this.getLatestChatRecordTimestamp(categoryIdB.toString(), b); + + if (tsA && tsB) { + // 都有聊天记录,按时间倒序 + return tsB - tsA; + } else if (tsA && !tsB) { + // a 有聊天记录,优先 + return -1; + } else if (!tsA && tsB) { + // b 有聊天记录,优先 + return 1; + } else { + // 都没有聊天记录 → 解锁排前,最后是免费类型 + const isPayTypeA = this.isGirlPayType(categoryIdA.toString(), a); + const isFreeTypeA = this.isGirlFreeType(categoryIdA.toString(), a); + const isPayTypeB = this.isGirlPayType(categoryIdB.toString(), b); + const isFreeTypeB = this.isGirlFreeType(categoryIdB.toString(), b); + if (isPayTypeA && isFreeTypeB) { + // A 付费,B 免费 → A 前 + return -1; + } else if (isFreeTypeA && isPayTypeB) { + // B 付费,A 免费 → B 前 + return 1; + } else { + // 都是付费 or 都是免费 → 按 id 倒序 + return b - a; + } + } + }); + // 返回结果 return result; } diff --git a/assets/Scripts/chat18x/ui/panels/PastGirlListPanel.ts b/assets/Scripts/chat18x/ui/panels/PastGirlListPanel.ts index 70f61427..9ce0b30b 100644 --- a/assets/Scripts/chat18x/ui/panels/PastGirlListPanel.ts +++ b/assets/Scripts/chat18x/ui/panels/PastGirlListPanel.ts @@ -7,6 +7,8 @@ import { DataManager, DataId } from "../../data/DataManager"; import { GirlData } from "../../data/GirlData"; import { ChatHistoryManager } from "../../manager/ChatHistoryManager"; import { logger } from "db://assets/Scripts/Main/Common/Logger"; +import { GirlService } from "db://assets/Scripts/chat18x/network/services/GirlService"; +import proto from "db://assets/Scripts/proto/proto.pb.js"; const { ccclass, property } = _decorator; @@ -128,6 +130,20 @@ export class PastGirlListPanel extends li_BaseView { this.node.active = false; } + // 获取可聊天的技师数据 + private async reqCanChatGirlData() { + const reqData = { + page: 1, + limit: 20, + }; + let res = await GirlService.I.reqCanChatGirlData(reqData); + if (res && res.code === proto.cs.EnmRetCode.SUCCESS) { + const resData = res.data; + const girlData = DataManager.I.getDataById(DataId.Girl); + girlData.setCanChatGirlData(resData); + } + } + onDestroy() { // 清理缓存池,销毁所有缓存的节点 for (let item of this.itemPool) {