增加方法:获取 在聊天中,触发技师图片的id

This commit is contained in:
chen wei bo
2025-09-10 20:59:12 +08:00
parent 24b9942110
commit 532a279088
5 changed files with 42 additions and 3 deletions
+3 -2
View File
@@ -27,8 +27,9 @@ export enum InnerMsgCode {
Chat_EmotionUpdated,
SimplePlayVide,
LanguageChange,
BalanceChange, // 余额发生变化
VipExpireChange, // vip失效时间戳发生变化
BalanceChange, // 余额发生变化
VipExpireChange, // vip失效时间戳发生变化
ChatTotalCountChange, // 总聊天次数发生变化
}
export enum InnerEventCode {
@@ -3,6 +3,8 @@
*/
import { BaseData } from "./BaseData";
import proto from 'db://assets/Scripts/proto/proto.pb.js';
import Utils from "../../Main/Common/Utils";
import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
export class GirlChatData extends BaseData {
// id
@@ -67,6 +69,12 @@ export class GirlChatData extends BaseData {
/** 保存总聊天次数 */
public setChatTotalCount(value: number): void {
this.chatTotalCount = value;
// 发出事件
let msgData = {
girlId: this.id,
chatTotalCount: this.chatTotalCount,
};
Utils.sendInnerMsg(InnerMsgCode.ChatTotalCountChange, msgData);
console.log("当前技师 ", this.id, " ,总聊天次数:", this.chatTotalCount);
}
+16
View File
@@ -386,6 +386,22 @@ export class GirlData extends BaseData {
return false;
}
/** 获取 在聊天中,触发技师图片的id */
public getTriggerGrilPhotoId(categoryId: string, girlId: number): number {
let oneData = this.getGrilDetail(categoryId, girlId);
if (!oneData) return 0;
// 所有图片 id,展示类型属于在聊天中触发
let allId = oneData.getAllTriggerGrilPhotoId();
// 总聊天次数
let chatTotalCount = this.getChatTotalCount(categoryId, girlId);
// 遍历
for (let id of allId) {
let count = this.getGrilPhotoUnlockCounts(categoryId, girlId, id);
if (chatTotalCount >= count) return id;
}
return 0;
}
/** 获取第一个技师图片的资源路径 */
public getFirstGrilPhotoPath(categoryId: string, girlId: number): string {
let oneData = this.getGrilDetail(categoryId, girlId);
@@ -107,7 +107,21 @@ export class GirlDetailData extends BaseData {
}
return allId;
}
/** 获取所有技师图片数据的id,展示类型属于在聊天中触发 */
public getAllTriggerGrilPhotoId(): number[] {
if (!this.photoData) return [];
// 筛选出类型为 2 的图片
let triggerPhotos = this.photoData.filter(photo => photo.imageType === 2);
// 按 unlockCounts 从大到小排序
triggerPhotos.sort((a, b) => b.unlockCounts - a.unlockCounts);
// 返回排序后的 id 数组
return triggerPhotos.map(photo => photo.id);
}
/** 获取技师图片数据,通过 id */
private getGrilPhotoData(id: number): proto.cs.IPurchaseCommercialImage | null {
if (!this.photoData) return null;