获取可聊天的技师数据

This commit is contained in:
chen wei bo
2025-09-22 18:42:28 +08:00
parent 4712f853e3
commit bfa55f52da
2 changed files with 58 additions and 5 deletions
+42 -5
View File
@@ -1014,15 +1014,52 @@ export class GirlData extends BaseData {
for (const [categoryId, bucket] of cats.entries()) { for (const [categoryId, bucket] of cats.entries()) {
for (const girlId of bucket.girlIds) { for (const girlId of bucket.girlIds) {
if (this.isCanChat(categoryId, girlId)) {
if (this.getIsRelease(categoryId, girlId)) {
result.push(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; return result;
} }
@@ -7,6 +7,8 @@ import { DataManager, DataId } from "../../data/DataManager";
import { GirlData } from "../../data/GirlData"; import { GirlData } from "../../data/GirlData";
import { ChatHistoryManager } from "../../manager/ChatHistoryManager"; import { ChatHistoryManager } from "../../manager/ChatHistoryManager";
import { logger } from "db://assets/Scripts/Main/Common/Logger"; 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; const { ccclass, property } = _decorator;
@@ -128,6 +130,20 @@ export class PastGirlListPanel extends li_BaseView {
this.node.active = false; 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<GirlData>(DataId.Girl);
girlData.setCanChatGirlData(resData);
}
}
onDestroy() { onDestroy() {
// 清理缓存池,销毁所有缓存的节点 // 清理缓存池,销毁所有缓存的节点
for (let item of this.itemPool) { for (let item of this.itemPool) {