2025-08-26 11:10:15 +08:00
|
|
|
/**
|
|
|
|
|
* 技师数据
|
|
|
|
|
*/
|
|
|
|
|
import { BaseData } from "./BaseData";
|
|
|
|
|
import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
|
|
|
|
|
2025-08-28 17:22:04 +08:00
|
|
|
// 分类的数据结构
|
|
|
|
|
interface CategoryBucket {
|
|
|
|
|
// 技师的简要数据
|
|
|
|
|
briefs: Map<number, proto.cs.IGirlBrief>;
|
|
|
|
|
// 技师的详细数据
|
|
|
|
|
details: Map<number, proto.cs.IGirlDetail>;
|
|
|
|
|
// 技师的id
|
|
|
|
|
girlIds: number[];
|
2025-08-26 11:10:15 +08:00
|
|
|
}
|
|
|
|
|
|
2025-08-29 11:29:21 +08:00
|
|
|
// 每日推荐专用分类
|
|
|
|
|
const DAILY_BUCKET = "__daily__";
|
|
|
|
|
|
2025-08-26 11:10:15 +08:00
|
|
|
export class GirlData extends BaseData {
|
2025-08-28 17:22:04 +08:00
|
|
|
// 大分类
|
|
|
|
|
private _categories = new Map<string, CategoryBucket>();
|
2025-08-29 11:29:21 +08:00
|
|
|
// 每日推荐(存放在 DAILY_BUCKET 中,同时保留 id 索引便于 UI 使用)
|
|
|
|
|
private _dailyRecommendIds: number[] = [];
|
2025-08-26 11:10:15 +08:00
|
|
|
|
|
|
|
|
public reset(): void {
|
2025-08-28 17:22:04 +08:00
|
|
|
this._categories.clear();
|
2025-08-26 11:10:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public clear(): void {
|
2025-08-28 17:22:04 +08:00
|
|
|
this._categories.clear();
|
2025-08-26 11:10:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public destroy(): void {
|
|
|
|
|
super.destroy();
|
2025-08-28 17:22:04 +08:00
|
|
|
this._categories = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 保障 _categories 存在 */
|
|
|
|
|
private ensureCategories(): Map<string, CategoryBucket> {
|
|
|
|
|
if (!this._categories) {
|
|
|
|
|
this._categories = new Map<string, CategoryBucket>();
|
|
|
|
|
}
|
|
|
|
|
return this._categories;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取或创建分类桶 */
|
|
|
|
|
private ensureBucket(categoryId: string): CategoryBucket {
|
|
|
|
|
const cats = this.ensureCategories();
|
|
|
|
|
let bucket = cats.get(categoryId);
|
|
|
|
|
if (!bucket) {
|
|
|
|
|
bucket = {
|
|
|
|
|
briefs: new Map<number, proto.cs.IGirlBrief>(),
|
|
|
|
|
details: new Map<number, proto.cs.IGirlDetail>(),
|
|
|
|
|
girlIds: [],
|
|
|
|
|
};
|
|
|
|
|
cats.set(categoryId, bucket);
|
|
|
|
|
}
|
|
|
|
|
return bucket;
|
|
|
|
|
}
|
2025-08-29 11:29:21 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 合并一批简要信息到指定分类;并维护 girlIds 顺序(去重追加)
|
|
|
|
|
*/
|
|
|
|
|
public mergeBriefs(categoryId: string, respOrList: proto.cs.IGirlBrief[]): void {
|
|
|
|
|
if (!respOrList) return;
|
|
|
|
|
let allData = this.parseAllGirlBrief(respOrList);
|
|
|
|
|
if (!allData) return;
|
|
|
|
|
const bucket = this.ensureBucket(categoryId);
|
2025-09-05 10:56:26 +08:00
|
|
|
// 用一个临时 Set 保存已有的 id,加速去重
|
|
|
|
|
const existed = new Set<number>(bucket.girlIds);
|
2025-08-29 11:29:21 +08:00
|
|
|
for (const g of allData) {
|
|
|
|
|
const id = g.id;
|
|
|
|
|
bucket.briefs.set(id, g);
|
2025-09-05 10:56:26 +08:00
|
|
|
// 去重
|
|
|
|
|
if (!existed.has(id)) {
|
|
|
|
|
bucket.girlIds.push(id);
|
|
|
|
|
existed.add(id);
|
|
|
|
|
}
|
2025-08-29 11:29:21 +08:00
|
|
|
}
|
|
|
|
|
console.log("保存技师的简要数据: ", bucket);
|
|
|
|
|
}
|
2025-08-28 17:22:04 +08:00
|
|
|
|
|
|
|
|
/** 取分类下的全部 girlIds(若分类不存在返回空数组) */
|
|
|
|
|
public getGirlIds(categoryId: string): number[] {
|
|
|
|
|
const b = this.ensureCategories().get(categoryId);
|
|
|
|
|
return b ? b.girlIds : [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** --------------------------------------------------------- 技师的简要数据 --------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
// 解析技师简要数据,一个
|
|
|
|
|
private parseOneGirlBrief(data: proto.cs.IGirlBrief): proto.cs.IGirlBrief | null {
|
|
|
|
|
if (!data) return null;
|
|
|
|
|
const oneData: proto.cs.IGirlBrief = {
|
2025-09-03 17:35:27 +08:00
|
|
|
id: data.id, // id
|
|
|
|
|
name: data.name, // 名字
|
|
|
|
|
age: data.age, // 年龄
|
|
|
|
|
tagKey: data.tagKey, // 标签
|
|
|
|
|
priceType: data.priceType, // 付费类型
|
|
|
|
|
price: data.price, // 价格
|
|
|
|
|
avatar: data.avatar, // 头像
|
|
|
|
|
star: data.star, // 星级
|
|
|
|
|
category: data.category, // 主题枚举
|
|
|
|
|
listAvatarPath: data.listAvatarPath, // list头像路径
|
2025-08-28 17:22:04 +08:00
|
|
|
};
|
|
|
|
|
return oneData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 解析技师简要数据,多个
|
|
|
|
|
private parseAllGirlBrief(data: proto.cs.IGirlBrief[]): proto.cs.IGirlBrief[] | null {
|
|
|
|
|
if (!data) return null;
|
|
|
|
|
let allData = [];
|
|
|
|
|
for (const value of data) {
|
|
|
|
|
const oneData: proto.cs.IGirlBrief = this.parseOneGirlBrief(value);
|
|
|
|
|
if (oneData) {
|
|
|
|
|
allData.push(oneData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return allData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 保存技师的简要数据 */
|
|
|
|
|
public setGirlBriefs(categoryId: string, data: proto.cs.ICSGetGirlListRes): void {
|
2025-08-29 11:29:21 +08:00
|
|
|
this.mergeBriefs(categoryId, data.girls);
|
2025-08-28 17:22:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 取某分类 + girlId 的简要信息 */
|
|
|
|
|
private getGrilBrief(categoryId: string, girlId: number): proto.cs.IGirlBrief | null {
|
|
|
|
|
const b = this.ensureCategories().get(categoryId);
|
|
|
|
|
if (!b) return null;
|
|
|
|
|
return b.briefs.get(girlId) ?? null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取名字 */
|
|
|
|
|
public getGrilName(categoryId: string, girlId: number): string {
|
|
|
|
|
let oneData = this.getGrilBrief(categoryId, girlId);
|
|
|
|
|
if (!oneData) return "";
|
|
|
|
|
return oneData.name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取年龄 */
|
|
|
|
|
public getGrilAge(categoryId: string, girlId: number): number {
|
|
|
|
|
let oneData = this.getGrilBrief(categoryId, girlId);
|
|
|
|
|
if (!oneData) return 0;
|
|
|
|
|
return oneData.age;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取标签 */
|
|
|
|
|
public getGrilTagKey(categoryId: string, girlId: number): string {
|
|
|
|
|
let oneData = this.getGrilBrief(categoryId, girlId);
|
|
|
|
|
if (!oneData) return "";
|
|
|
|
|
return oneData.tagKey;
|
2025-08-26 11:10:15 +08:00
|
|
|
}
|
|
|
|
|
|
2025-08-28 17:22:04 +08:00
|
|
|
/** 获取付费类型 */
|
|
|
|
|
public getGrilPriceType(categoryId: string, girlId: number): number {
|
|
|
|
|
let oneData = this.getGrilBrief(categoryId, girlId);
|
|
|
|
|
if (!oneData) return 0;
|
|
|
|
|
return oneData.priceType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取价格 */
|
|
|
|
|
public getGrilPrice(categoryId: string, girlId: number): number {
|
|
|
|
|
let oneData = this.getGrilBrief(categoryId, girlId);
|
|
|
|
|
if (!oneData) return 0;
|
|
|
|
|
return oneData.price;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取头像 */
|
|
|
|
|
public getGrilAvatar(categoryId: string, girlId: number): string {
|
|
|
|
|
let oneData = this.getGrilBrief(categoryId, girlId);
|
|
|
|
|
if (!oneData) return "";
|
|
|
|
|
return oneData.avatar;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取星级 */
|
|
|
|
|
public getGrilStar(categoryId: string, girlId: number): number {
|
|
|
|
|
let oneData = this.getGrilBrief(categoryId, girlId);
|
|
|
|
|
if (!oneData) return 0;
|
|
|
|
|
return oneData.star;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-03 17:35:27 +08:00
|
|
|
/** 获取主题枚举 */
|
|
|
|
|
public getGrilCategory(categoryId: string, girlId: number): number {
|
|
|
|
|
let oneData = this.getGrilBrief(categoryId, girlId);
|
|
|
|
|
if (!oneData) return 0;
|
|
|
|
|
return oneData.category;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-05 09:42:22 +08:00
|
|
|
/** 获取主题枚举,根据 id */
|
|
|
|
|
public getGrilCategoryById(girlId: number): number {
|
|
|
|
|
const cats = this.ensureCategories();
|
|
|
|
|
|
|
|
|
|
for (const bucket of cats.values()) {
|
|
|
|
|
// 先查简要信息
|
|
|
|
|
const brief = bucket.briefs.get(girlId);
|
|
|
|
|
if (brief && brief.category) {
|
|
|
|
|
return brief.category;
|
|
|
|
|
}
|
|
|
|
|
// 兜底:若只缓存了详情,也从详情里的 brief 取
|
|
|
|
|
const detail = bucket.details.get(girlId);
|
|
|
|
|
if (detail?.brief && typeof detail.brief.category) {
|
|
|
|
|
return detail.brief.category;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 未找到
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-03 17:35:27 +08:00
|
|
|
/** 获取list头像路径 */
|
|
|
|
|
public getGrilListAvatar(categoryId: string, girlId: number): string {
|
|
|
|
|
let oneData = this.getGrilBrief(categoryId, girlId);
|
|
|
|
|
if (!oneData) return "";
|
|
|
|
|
return oneData.listAvatarPath;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-28 17:22:04 +08:00
|
|
|
/** --------------------------------------------------------- 技师的详细数据 --------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
// 解析技师图片数据,一个
|
2025-09-03 17:35:27 +08:00
|
|
|
private parseOneGirlPhoto(data: proto.cs.IPurchaseCommercialImage): proto.cs.IPurchaseCommercialImage | null {
|
2025-08-28 17:22:04 +08:00
|
|
|
if (!data) return null;
|
2025-09-03 17:35:27 +08:00
|
|
|
const oneData: proto.cs.IPurchaseCommercialImage = {
|
|
|
|
|
imageType: data.imageType, // 图片类型
|
|
|
|
|
imagePrice: data.imagePrice, // 图片价格
|
|
|
|
|
path: data.path, // 图片资源路径
|
2025-08-28 17:22:04 +08:00
|
|
|
isRelease: data.isRelease, // 是否解锁
|
|
|
|
|
};
|
|
|
|
|
return oneData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 解析技师图片数据,多个
|
2025-09-03 17:35:27 +08:00
|
|
|
private parseAllGirlPhoto(data: proto.cs.IPurchaseCommercialImage[]): proto.cs.IPurchaseCommercialImage[] | null {
|
2025-08-28 17:22:04 +08:00
|
|
|
if (!data) return null;
|
|
|
|
|
let allData = [];
|
|
|
|
|
for (const value of data) {
|
2025-09-03 17:35:27 +08:00
|
|
|
const oneData: proto.cs.IPurchaseCommercialImage = this.parseOneGirlPhoto(value);
|
2025-08-28 17:22:04 +08:00
|
|
|
if (oneData) {
|
|
|
|
|
allData.push(oneData);
|
|
|
|
|
}
|
2025-08-26 11:10:15 +08:00
|
|
|
}
|
2025-08-28 17:22:04 +08:00
|
|
|
return allData;
|
2025-08-26 11:10:15 +08:00
|
|
|
}
|
|
|
|
|
|
2025-09-03 17:35:27 +08:00
|
|
|
// 解析技师视频数据,一个
|
|
|
|
|
private parseOneGirlVideo(data: proto.cs.IPurchaseCommercialVideo): proto.cs.IPurchaseCommercialVideo | null {
|
|
|
|
|
if (!data) return null;
|
|
|
|
|
const oneData: proto.cs.IPurchaseCommercialVideo = {
|
|
|
|
|
path: data.path, // 视频资源路径
|
|
|
|
|
emotion: data.emotion, // 关联情绪
|
|
|
|
|
videoPrice: data.videoPrice, // 价格
|
|
|
|
|
isRelease: data.isRelease, // 是否解锁
|
|
|
|
|
};
|
|
|
|
|
return oneData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 解析技师视频数据,多个
|
|
|
|
|
private parseAllGirlVideo(data: proto.cs.IPurchaseCommercialVideo[]): proto.cs.IPurchaseCommercialVideo[] | null {
|
|
|
|
|
if (!data) return null;
|
|
|
|
|
let allData = [];
|
|
|
|
|
for (const value of data) {
|
|
|
|
|
const oneData: proto.cs.IPurchaseCommercialVideo = this.parseOneGirlVideo(value);
|
|
|
|
|
if (oneData) {
|
|
|
|
|
allData.push(oneData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return allData;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-28 17:22:04 +08:00
|
|
|
// 解析技师详细数据,一个
|
|
|
|
|
private parseOneGirlDetail(data: proto.cs.IGirlDetail): proto.cs.IGirlDetail | null {
|
|
|
|
|
if (!data) return null;
|
2025-09-03 17:35:27 +08:00
|
|
|
const photoData = this.parseAllGirlPhoto(data.images);
|
|
|
|
|
const videoData = this.parseAllGirlVideo(data.videos);
|
2025-08-28 17:22:04 +08:00
|
|
|
const briefData = this.parseOneGirlBrief(data.brief);
|
|
|
|
|
const oneData: proto.cs.IGirlDetail = {
|
|
|
|
|
brief: briefData, // 技师简要数据
|
2025-09-03 17:35:27 +08:00
|
|
|
desc: data.desc, // 技师描述
|
2025-08-28 17:22:04 +08:00
|
|
|
isRelease: data.isRelease, // 技师是否解锁
|
|
|
|
|
chatCount: data.chatCount, // 剩余聊天次数
|
2025-09-03 17:35:27 +08:00
|
|
|
images: photoData, // 技师图片列表
|
|
|
|
|
videos: videoData, // 技师视频列表
|
2025-08-28 17:22:04 +08:00
|
|
|
};
|
|
|
|
|
return oneData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 解析技师详细数据,多个
|
|
|
|
|
private parseAllGirlDetail(data: proto.cs.IGirlDetail[]): proto.cs.IGirlDetail[] | null {
|
|
|
|
|
if (!data) return null;
|
|
|
|
|
let allData = [];
|
|
|
|
|
for (const value of data) {
|
|
|
|
|
const oneData: proto.cs.IGirlDetail = this.parseOneGirlDetail(value);
|
|
|
|
|
if (oneData) {
|
|
|
|
|
allData.push(oneData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return allData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 保存技师的详细数据 */
|
|
|
|
|
public setGirlDetails(categoryId: string, data: proto.cs.ICSGetGirlDetailRes): void {
|
2025-08-29 11:29:21 +08:00
|
|
|
const d = data?.detail;
|
2025-08-28 17:22:04 +08:00
|
|
|
if (!d) return;
|
2025-08-29 11:29:21 +08:00
|
|
|
// 合并简要信息
|
|
|
|
|
if (d.brief) this.mergeBriefs(categoryId, [d.brief]);
|
|
|
|
|
const oneDetail = this.parseOneGirlDetail(d);
|
2025-08-28 17:22:04 +08:00
|
|
|
const bucket = this.ensureBucket(categoryId);
|
|
|
|
|
// id
|
|
|
|
|
const id = d.brief?.id ?? 0;
|
|
|
|
|
// 写入详情
|
2025-08-29 11:29:21 +08:00
|
|
|
bucket.details.set(id, oneDetail);
|
2025-08-28 17:22:04 +08:00
|
|
|
console.log("保存技师的详细数据: ", bucket);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 取某分类 + girlId 的详细信息 */
|
|
|
|
|
public getGrilDetail(categoryId: string, girlId: number): proto.cs.IGirlDetail | null {
|
|
|
|
|
const b = this.ensureCategories().get(categoryId);
|
|
|
|
|
if (!b) return null;
|
|
|
|
|
return b.details.get(girlId) ?? null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取技师描述 */
|
|
|
|
|
public getGrilDesc(categoryId: string, girlId: number): string {
|
|
|
|
|
let oneData = this.getGrilDetail(categoryId, girlId);
|
|
|
|
|
if (!oneData) return "";
|
|
|
|
|
return oneData.desc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取技师是否解锁 */
|
|
|
|
|
public getGrilIsRelease(categoryId: string, girlId: number): boolean {
|
|
|
|
|
let oneData = this.getGrilDetail(categoryId, girlId);
|
|
|
|
|
if (!oneData) return false;
|
|
|
|
|
return oneData.isRelease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取技师剩余聊天次数 */
|
|
|
|
|
public getGrilChatCount(categoryId: string, girlId: number): number {
|
|
|
|
|
let oneData = this.getGrilDetail(categoryId, girlId);
|
|
|
|
|
if (!oneData) return 0;
|
|
|
|
|
return oneData.chatCount;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-03 17:35:27 +08:00
|
|
|
/** 获取所有技师图片数据 */
|
|
|
|
|
private getAllGrilPhotoData(categoryId: string, girlId: number): proto.cs.IPurchaseCommercialImage[] | null {
|
2025-08-28 17:22:04 +08:00
|
|
|
let oneData = this.getGrilDetail(categoryId, girlId);
|
2025-09-03 17:35:27 +08:00
|
|
|
if (!oneData || !oneData.images) return null;
|
|
|
|
|
return oneData.images;
|
2025-08-28 17:22:04 +08:00
|
|
|
}
|
|
|
|
|
|
2025-09-03 17:35:27 +08:00
|
|
|
/** 获取所有技师图片数据的数量 */
|
|
|
|
|
public getAllGrilPhotoDataCount(categoryId: string, girlId: number): number {
|
|
|
|
|
let allData = this.getAllGrilPhotoData(categoryId, girlId);
|
|
|
|
|
if (!allData) return 0;
|
|
|
|
|
return allData.length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取技师图片数据,通过 index */
|
|
|
|
|
private getGrilPhotoData(categoryId: string, girlId: number, index: number): proto.cs.IPurchaseCommercialImage | null {
|
|
|
|
|
let allData = this.getAllGrilPhotoData(categoryId, girlId);
|
|
|
|
|
if (!allData) return null;
|
|
|
|
|
// 下标越界保护
|
|
|
|
|
if (index < 0 || index >= allData.length) return null;
|
|
|
|
|
|
|
|
|
|
return allData[index] ?? null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取技师图片的类型 */
|
|
|
|
|
public getGrilPhotoType(categoryId: string, girlId: number, index: number): number {
|
|
|
|
|
let oneData = this.getGrilPhotoData(categoryId, girlId, index);
|
|
|
|
|
if (!oneData) return 0;
|
|
|
|
|
return oneData.imageType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取技师图片的价格 */
|
|
|
|
|
public getGrilPhotoPrice(categoryId: string, girlId: number, index: number): number {
|
|
|
|
|
let oneData = this.getGrilPhotoData(categoryId, girlId, index);
|
|
|
|
|
if (!oneData) return 0;
|
|
|
|
|
return oneData.imagePrice;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-28 17:22:04 +08:00
|
|
|
/** 获取技师图片的路径 */
|
|
|
|
|
public getGrilPhotoPic(categoryId: string, girlId: number, index: number): string {
|
|
|
|
|
let oneData = this.getGrilPhotoData(categoryId, girlId, index);
|
|
|
|
|
if (!oneData) return "";
|
2025-09-03 17:35:27 +08:00
|
|
|
return oneData.path;
|
2025-08-28 17:22:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取技师图片是否解锁 */
|
|
|
|
|
public getGrilPhotoIsRelease(categoryId: string, girlId: number, index: number): boolean {
|
|
|
|
|
let oneData = this.getGrilPhotoData(categoryId, girlId, index);
|
|
|
|
|
if (!oneData) return false;
|
|
|
|
|
return oneData.isRelease;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-03 17:35:27 +08:00
|
|
|
/** 获取所有技师视频数据 */
|
|
|
|
|
private getAllGrilVideoData(categoryId: string, girlId: number): proto.cs.IPurchaseCommercialVideo[] | null {
|
|
|
|
|
let oneData = this.getGrilDetail(categoryId, girlId);
|
|
|
|
|
if (!oneData || !oneData.videos) return null;
|
|
|
|
|
|
|
|
|
|
return oneData.videos ?? null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取所有技师视频数据的数量 */
|
|
|
|
|
public getAllGrilVideoDataCount(categoryId: string, girlId: number): number {
|
|
|
|
|
let allData = this.getAllGrilVideoData(categoryId, girlId);
|
|
|
|
|
if (!allData) return 0;
|
|
|
|
|
return allData.length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取技师视频数据,通过 index */
|
|
|
|
|
private getGrilVideoData(categoryId: string, girlId: number, index: number): proto.cs.IPurchaseCommercialVideo | null {
|
|
|
|
|
let allData = this.getAllGrilVideoData(categoryId, girlId);
|
|
|
|
|
if (!allData) return null;
|
|
|
|
|
// 下标越界保护
|
|
|
|
|
if (index < 0 || index >= allData.length) return null;
|
|
|
|
|
|
|
|
|
|
return allData[index] ?? null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取技师视频的路径 */
|
|
|
|
|
public getGrilVideoPath(categoryId: string, girlId: number, index: number): string {
|
|
|
|
|
let oneData = this.getGrilVideoData(categoryId, girlId, index);
|
|
|
|
|
if (!oneData) return "";
|
|
|
|
|
return oneData.path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取技师视频的关联情绪 */
|
|
|
|
|
public getGrilVideoEmotion(categoryId: string, girlId: number, index: number): number {
|
|
|
|
|
let oneData = this.getGrilVideoData(categoryId, girlId, index);
|
2025-08-28 17:22:04 +08:00
|
|
|
if (!oneData) return 0;
|
2025-09-03 17:35:27 +08:00
|
|
|
return oneData.emotion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取技师视频的价格 */
|
|
|
|
|
public getGrilVideoPrice(categoryId: string, girlId: number, index: number): number {
|
|
|
|
|
let oneData = this.getGrilVideoData(categoryId, girlId, index);
|
|
|
|
|
if (!oneData) return 0;
|
|
|
|
|
return oneData.videoPrice;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取技师视频是否解锁 */
|
|
|
|
|
public getGrilVideoIsRelease(categoryId: string, girlId: number, index: number): boolean {
|
|
|
|
|
let oneData = this.getGrilVideoData(categoryId, girlId, index);
|
|
|
|
|
if (!oneData) return false;
|
|
|
|
|
return oneData.isRelease;
|
2025-08-28 17:22:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** --------------------------------------------------------- 每日推荐 --------------------------------------------------------- */
|
|
|
|
|
|
2025-08-29 11:29:21 +08:00
|
|
|
/** 保存每日推荐:放入特殊分类 DAILY_BUCKET,并维护 id 索引 */
|
|
|
|
|
public setDailyRecommend(res: proto.cs.ICSDailyRecommendRes): void {
|
|
|
|
|
this.mergeBriefs(DAILY_BUCKET, res.girls);
|
|
|
|
|
this._dailyRecommendIds = res.girls.map(g => g.id ?? 0);
|
2025-09-02 15:07:53 +08:00
|
|
|
console.log("保存每日推荐: ", this._dailyRecommendIds);
|
2025-08-26 11:10:15 +08:00
|
|
|
}
|
|
|
|
|
|
2025-08-29 11:29:21 +08:00
|
|
|
/** 获取每日推荐的简要信息 */
|
|
|
|
|
private getRecommendGrilBrief(categoryId: string, index: number): proto.cs.IGirlBrief | null {
|
|
|
|
|
const b = this.ensureCategories().get(categoryId);
|
|
|
|
|
if (!b) return null;
|
|
|
|
|
if (index < 0 || index >= b.girlIds.length) return null;
|
|
|
|
|
return b.briefs.get(b.girlIds[index]) ?? null;
|
|
|
|
|
}
|
2025-08-26 11:10:15 +08:00
|
|
|
|
2025-09-02 15:07:53 +08:00
|
|
|
/** 获取 id */
|
|
|
|
|
public getRecommendGrilId(index: number): number {
|
|
|
|
|
let oneData = this.getRecommendGrilBrief(DAILY_BUCKET, index);
|
|
|
|
|
if (!oneData) return 0;
|
|
|
|
|
return oneData.id;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-29 11:29:21 +08:00
|
|
|
/** 获取名字 */
|
|
|
|
|
public getRecommendGrilName(index: number): string {
|
|
|
|
|
let oneData = this.getRecommendGrilBrief(DAILY_BUCKET, index);
|
|
|
|
|
if (!oneData) return "";
|
|
|
|
|
return oneData.name;
|
|
|
|
|
}
|
2025-09-02 15:07:53 +08:00
|
|
|
|
|
|
|
|
/** 获取头像 */
|
|
|
|
|
public getRecommendGrilAvatar(index: number): string {
|
|
|
|
|
let oneData = this.getRecommendGrilBrief(DAILY_BUCKET, index);
|
|
|
|
|
if (!oneData) return "";
|
|
|
|
|
return oneData.avatar;
|
|
|
|
|
}
|
2025-08-26 11:10:15 +08:00
|
|
|
}
|