228 lines
6.5 KiB
TypeScript
228 lines
6.5 KiB
TypeScript
/**
|
|||
|
|
* 技师的详细数据
|
||
|
|
*/
|
||
|
|
import { BaseData } from "./BaseData";
|
||
|
|
import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
||
|
|
|
||
|
|
export class GirlDetailData extends BaseData {
|
||
|
|
// id
|
||
|
|
private id: number;
|
||
|
|
// 自我介绍
|
||
|
|
private detailDesc: string;
|
||
|
|
// 图片数据
|
||
|
|
private photoData: proto.cs.IPurchaseCommercialImage[];
|
||
|
|
// 视频数据
|
||
|
|
private videoData: proto.cs.IPurchaseCommercialVideo[];
|
||
|
|
|
||
|
|
constructor() {
|
||
|
|
super();
|
||
|
|
this.id = 0;
|
||
|
|
this.detailDesc = "";
|
||
|
|
this.photoData = [];
|
||
|
|
this.videoData = [];
|
||
|
|
}
|
||
|
|
|
||
|
|
public reset(): void {
|
||
|
|
this.id = 0;
|
||
|
|
this.detailDesc = "";
|
||
|
|
this.photoData = [];
|
||
|
|
this.videoData = [];
|
||
|
|
}
|
||
|
|
|
||
|
|
public clear(): void {
|
||
|
|
this.id = 0;
|
||
|
|
this.detailDesc = "";
|
||
|
|
this.photoData = [];
|
||
|
|
this.videoData = [];
|
||
|
|
}
|
||
|
|
|
||
|
|
public destroy(): void {
|
||
|
|
super.destroy();
|
||
|
|
this.id = null;
|
||
|
|
this.detailDesc = null;
|
||
|
|
this.photoData = null;
|
||
|
|
this.videoData = null;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 保存数据 */
|
||
|
|
public setData(data: proto.cs.IGirlsDetail): void {
|
||
|
|
if (!data) return;
|
||
|
|
this.id = data.id;
|
||
|
|
this.detailDesc = data.detailDesc;
|
||
|
|
this.photoData = this.parseAllGirlPhoto(data.commercialImages);
|
||
|
|
this.videoData = this.parseAllGirlVideo(data.commercialVideos);
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取 id */
|
||
|
|
public getId(): number {
|
||
|
|
return this.id;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取自我介绍 */
|
||
|
|
public getGirlDesc(): string {
|
||
|
|
return this.detailDesc;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** --------------------------------------------------------- 图片数据 --------------------------------------------------------- */
|
||
|
|
|
||
|
|
// 解析技师图片数据,一个
|
||
|
|
private parseOneGirlPhoto(data: proto.cs.IPurchaseCommercialImage): proto.cs.IPurchaseCommercialImage | null {
|
||
|
|
if (!data) return null;
|
||
|
|
const oneData: proto.cs.IPurchaseCommercialImage = {
|
||
|
|
id: data.id, // 图片 id
|
||
|
|
imageType: data.imageType, // 图片类型
|
||
|
|
unlockCounts: data.unlockCounts, // 聊天触发次数
|
||
|
|
imagePrice: data.imagePrice, // 图片价格
|
||
|
|
path: data.path, // 图片资源路径
|
||
|
|
};
|
||
|
|
return oneData;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 解析技师图片数据,多个
|
||
|
|
private parseAllGirlPhoto(data: proto.cs.IPurchaseCommercialImage[]): proto.cs.IPurchaseCommercialImage[] {
|
||
|
|
if (!data) return [];
|
||
|
|
let allData = [];
|
||
|
|
for (const value of data) {
|
||
|
|
const oneData: proto.cs.IPurchaseCommercialImage = this.parseOneGirlPhoto(value);
|
||
|
|
if (oneData) {
|
||
|
|
allData.push(oneData);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return allData;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取所有技师图片数据的数量 */
|
||
|
|
public getAllGrilPhotoDataCount(): number {
|
||
|
|
if (!this.photoData) return 0;
|
||
|
|
return this.photoData.length;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取所有技师图片数据的id */
|
||
|
|
public getAllGrilPhotoDataId(): number[] {
|
||
|
|
if (!this.photoData) return [];
|
||
|
|
// 获取所有 id
|
||
|
|
let allId = [];
|
||
|
|
for (let one of this.photoData) {
|
||
|
|
allId.push(one.id);
|
||
|
|
}
|
||
|
|
return allId;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取技师图片数据,通过 id */
|
||
|
|
private getGrilPhotoData(id: number): proto.cs.IPurchaseCommercialImage | null {
|
||
|
|
if (!this.photoData) return null;
|
||
|
|
// 遍历数组找到匹配的资源
|
||
|
|
for (let oneData of this.photoData) {
|
||
|
|
if (oneData.id === id) {
|
||
|
|
return oneData;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取技师图片的类型 */
|
||
|
|
public getGrilPhotoType(id: number): number {
|
||
|
|
let oneData = this.getGrilPhotoData(id);
|
||
|
|
if (!oneData) return 0;
|
||
|
|
return oneData.imageType;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取技师图片的聊天触发次数 */
|
||
|
|
public getGrilPhotoUnlockCounts(id: number): number {
|
||
|
|
let oneData = this.getGrilPhotoData(id);
|
||
|
|
if (!oneData) return 0;
|
||
|
|
return oneData.unlockCounts;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取技师图片的价格 */
|
||
|
|
public getGrilPhotoPrice(id: number): number {
|
||
|
|
let oneData = this.getGrilPhotoData(id);
|
||
|
|
if (!oneData) return 0;
|
||
|
|
return oneData.imagePrice;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取技师图片的资源路径 */
|
||
|
|
public getGrilPhotoPath(id: number): string {
|
||
|
|
let oneData = this.getGrilPhotoData(id);
|
||
|
|
if (!oneData) return "";
|
||
|
|
return oneData.path;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** --------------------------------------------------------- 视频数据 --------------------------------------------------------- */
|
||
|
|
|
||
|
|
// 解析技师视频数据,一个
|
||
|
|
private parseOneGirlVideo(data: proto.cs.IPurchaseCommercialVideo): proto.cs.IPurchaseCommercialVideo | null {
|
||
|
|
if (!data) return null;
|
||
|
|
const oneData: proto.cs.IPurchaseCommercialVideo = {
|
||
|
|
id: data.id, // 视频 id
|
||
|
|
path: data.path, // 视频资源路径
|
||
|
|
emotion: data.emotion, // 关联情绪
|
||
|
|
videoPrice: data.videoPrice, // 价格
|
||
|
|
};
|
||
|
|
return oneData;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 解析技师视频数据,多个
|
||
|
|
private parseAllGirlVideo(data: proto.cs.IPurchaseCommercialVideo[]): proto.cs.IPurchaseCommercialVideo[] {
|
||
|
|
if (!data) return [];
|
||
|
|
let allData = [];
|
||
|
|
for (const value of data) {
|
||
|
|
const oneData: proto.cs.IPurchaseCommercialVideo = this.parseOneGirlVideo(value);
|
||
|
|
if (oneData) {
|
||
|
|
allData.push(oneData);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return allData;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取所有技师视频数据的数量 */
|
||
|
|
public getAllGrilVideoDataCount(): number {
|
||
|
|
if (!this.videoData) return 0;
|
||
|
|
return this.videoData.length;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取所有技师视频数据的id */
|
||
|
|
public getAllGrilVideoDataId(): number[] {
|
||
|
|
if (!this.videoData) return [];
|
||
|
|
// 获取所有 id
|
||
|
|
let allId = [];
|
||
|
|
for (let one of this.videoData) {
|
||
|
|
allId.push(one.id);
|
||
|
|
}
|
||
|
|
return allId;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取技师视频数据,通过 id */
|
||
|
|
private getGrilVideoData(id: number): proto.cs.IPurchaseCommercialVideo | null {
|
||
|
|
if (!this.videoData) return null;
|
||
|
|
// 遍历数组找到匹配的资源
|
||
|
|
for (let oneData of this.videoData) {
|
||
|
|
if (oneData.id === id) {
|
||
|
|
return oneData;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取技师视频的资源路径 */
|
||
|
|
public getGrilVideoPath(id: number): string {
|
||
|
|
let oneData = this.getGrilVideoData(id);
|
||
|
|
if (!oneData) return "";
|
||
|
|
return oneData.path;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取技师视频的关联情绪 */
|
||
|
|
public getGrilVideoEmotion(id: number): number {
|
||
|
|
let oneData = this.getGrilVideoData(id);
|
||
|
|
if (!oneData) return 0;
|
||
|
|
return oneData.emotion;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取技师视频的价格 */
|
||
|
|
public getGrilVideoPrice(id: number): number {
|
||
|
|
let oneData = this.getGrilVideoData(id);
|
||
|
|
if (!oneData) return 0;
|
||
|
|
return oneData.videoPrice;
|
||
|
|
}
|
||
|
|
}
|