From 90a986a79cf54f1e7c571c84a31f14e50600a63f Mon Sep 17 00:00:00 2001 From: xlj <543978819@qq.com> Date: Tue, 9 Sep 2025 19:21:05 +0800 Subject: [PATCH] update --- assets/Scripts/chat18x/data/GirlData.ts | 367 +++++++++++------- .../chat18x/ui/panels/GirlDetailPanel.ts | 12 +- .../chat18x/ui/panels/PopupGirlDetailPanel.ts | 10 +- .../chat18x/uiitems/DetailImageItem.ts | 51 ++- .../Scripts/chat18x/uiitems/GirlListItem.ts | 2 +- 5 files changed, 283 insertions(+), 159 deletions(-) diff --git a/assets/Scripts/chat18x/data/GirlData.ts b/assets/Scripts/chat18x/data/GirlData.ts index e417b5bc..62744bc4 100644 --- a/assets/Scripts/chat18x/data/GirlData.ts +++ b/assets/Scripts/chat18x/data/GirlData.ts @@ -8,7 +8,7 @@ import { GirlUnlockData } from "./GirlUnlockData"; import { GirlChatData } from "./GirlChatData"; import { GirlFavorabilityData } from "./GirlFavorabilityData"; import { DataId } from "./DataManager"; -import proto from 'db://assets/Scripts/proto/proto.pb.js'; +import proto from "db://assets/Scripts/proto/proto.pb.js"; // 分类的数据结构 interface CategoryBucket { @@ -19,15 +19,15 @@ interface CategoryBucket { // 技师的解锁数据 unlocks: Map; // 技师的聊天数据 - chats: Map; + chats: Map; // 技师的好感度数据 - favorability: Map; + favorability: Map; // 技师的id girlIds: number[]; } // 每日推荐专用分类 -const DAILY_BUCKET = "__daily__"; +const DAILY_BUCKET = "__daily__"; export class GirlData extends BaseData { // 大分类 @@ -44,7 +44,7 @@ export class GirlData extends BaseData { public destroy(): void { super.destroy(); this._categories = null; - } + } /** 保障 _categories 存在 */ private ensureCategories(): Map { @@ -70,16 +70,19 @@ export class GirlData extends BaseData { cats.set(categoryId, bucket); } return bucket; - } - + } + /** 取分类下的全部 girlIds(若分类不存在返回空数组) */ public getGirlIds(categoryId: string): number[] { const b = this.ensureCategories().get(categoryId); return b ? b.girlIds : []; - } + } /** 保存技师列表 */ - public setGirlList(categoryId: string, data: proto.cs.ICSGetGirlListRes): void { + public setGirlList( + categoryId: string, + data: proto.cs.ICSGetGirlListRes + ): void { if (!data) return; this.setGirlBrief(categoryId, data.girls); this.setGirlUnlock(categoryId, data.girls); @@ -87,12 +90,15 @@ export class GirlData extends BaseData { const bucket = this.ensureBucket(categoryId); console.log("保存类别 ", categoryId, " 的技师列表: ", bucket); - } + } /** 保存技师详细数据 */ - public setGirlDetailData(categoryId: string, data: proto.cs.ICSGetGirlDetailRes): void { + public setGirlDetailData( + categoryId: string, + data: proto.cs.ICSGetGirlDetailRes + ): void { if (!data) return; - let details = [] + let details = []; details.push(data.girl); this.setGirlBrief(categoryId, details); this.setGirlDetail(categoryId, details); @@ -101,11 +107,11 @@ export class GirlData extends BaseData { this.setGirlFavorability(categoryId, details); const bucket = this.ensureBucket(categoryId); - console.log("保存类别 ", categoryId, " 的详细数据: ", bucket); - } - + console.log("保存类别 ", categoryId, " 的详细数据: ", bucket); + } + /** --------------------------------------------------------- 技师的简要数据 --------------------------------------------------------- */ - + /** * 合并一个简要数据到指定分类;并维护 girlIds 顺序(去重追加) */ @@ -121,12 +127,15 @@ export class GirlData extends BaseData { if (!existed.has(id)) { bucket.girlIds.push(id); } - } + } /** * 合并一批简要数据到指定分类;并维护 girlIds 顺序(去重追加) */ - private mergeBriefs(categoryId: string, respOrList: proto.cs.IGirlData[]): void { + private mergeBriefs( + categoryId: string, + respOrList: proto.cs.IGirlData[] + ): void { if (!respOrList) return; const bucket = this.ensureBucket(categoryId); // 用一个临时 Set 保存已有的 id,加速去重 @@ -142,7 +151,7 @@ export class GirlData extends BaseData { existed.add(g.id); } } - } + } private parseOneGirlBrief(data: proto.cs.IGirls): GirlBriefData | null { if (!data) return null; @@ -155,10 +164,13 @@ export class GirlData extends BaseData { /** 保存技师的简要数据 */ private setGirlBrief(categoryId: string, data: proto.cs.IGirlData[]): void { this.mergeBriefs(categoryId, data); - } + } /** 取某分类 + girlId 的简要数据 */ - private getGrilBrief(categoryId: string, girlId: number): GirlBriefData | null { + private getGrilBrief( + categoryId: string, + girlId: number + ): GirlBriefData | null { const b = this.ensureCategories().get(categoryId); if (!b) return null; return b.briefs.get(girlId) ?? null; @@ -169,63 +181,63 @@ export class GirlData extends BaseData { let oneData = this.getGrilBrief(categoryId, girlId); if (!oneData) return ""; return oneData.getGrilName(); - } + } /** 获取年龄 */ public getGrilAge(categoryId: string, girlId: number): string { let oneData = this.getGrilBrief(categoryId, girlId); if (!oneData) return "0"; return oneData.getGrilAge(); - } + } /** 获取主题枚举 */ public getGrilCategory(categoryId: string, girlId: number): number { let oneData = this.getGrilBrief(categoryId, girlId); if (!oneData) return 0; return oneData.getGrilCategory(); - } + } /** 获取标签键 */ public getGrilTagKey(categoryId: string, girlId: number): string { let oneData = this.getGrilBrief(categoryId, girlId); if (!oneData) return ""; return oneData.getGrilTagKey(); - } + } /** 获取付费类型 */ public getGrilPriceType(categoryId: string, girlId: number): number { let oneData = this.getGrilBrief(categoryId, girlId); if (!oneData) return 0; return oneData.getGrilPriceType(); - } + } /** 获取价格 */ public getGrilPrice(categoryId: string, girlId: number): number { let oneData = this.getGrilBrief(categoryId, girlId); if (!oneData) return 0; return oneData.getGrilPrice(); - } + } /** 获取VIP能否解锁 */ public getGrilVipUnlock(categoryId: string, girlId: number): number { let oneData = this.getGrilBrief(categoryId, girlId); if (!oneData) return 0; return oneData.getGrilVipUnlock(); - } - + } + /** 获取头像路径 */ public getGrilAvatar(categoryId: string, girlId: number): string { let oneData = this.getGrilBrief(categoryId, girlId); if (!oneData) return ""; return oneData.getGrilAvatar(); - } - + } + /** 获取list头像路径 */ public getGrilListAvatar(categoryId: string, girlId: number): string { let oneData = this.getGrilBrief(categoryId, girlId); if (!oneData) return ""; return oneData.getGrilListAvatar(); - } + } /** 获取主题枚举,根据 id */ public getGrilCategoryById(girlId: number): number { @@ -240,12 +252,14 @@ export class GirlData extends BaseData { } // 未找到 return 0; - } + } /** --------------------------------------------------------- 技师的详细数据 --------------------------------------------------------- */ // 解析技师详细数据,一个 - private parseOneGirlDetail(data: proto.cs.IGirlsDetail): GirlDetailData | null { + private parseOneGirlDetail( + data: proto.cs.IGirlsDetail + ): GirlDetailData | null { if (!data) return null; let oneData = new GirlDetailData(); oneData.init?.(DataId.GirlDetail); @@ -262,68 +276,74 @@ export class GirlData extends BaseData { if (!one) continue; bucket.details.set(g.id, one); } - } + } /** 取某分类 + girlId 的详细数据 */ - public getGrilDetail(categoryId: string, girlId: number): GirlDetailData | null { + public getGrilDetail( + categoryId: string, + girlId: number + ): GirlDetailData | 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.getGirlDesc(); - } + } /** 获取所有技师图片数据的数量 */ public getAllGrilPhotoDataCount(categoryId: string, girlId: number): number { let oneData = this.getGrilDetail(categoryId, girlId); if (!oneData) return 0; - return oneData.getAllGrilPhotoDataCount(); - } + return oneData.getAllGrilPhotoDataCount(); + } /** 获取所有技师图片的id */ public getAllGrilPhotoId(categoryId: string, girlId: number): number[] { let oneData = this.getGrilDetail(categoryId, girlId); if (!oneData) return []; - return oneData.getAllGrilPhotoId(); - } - + return oneData.getAllGrilPhotoId(); + } + /** 获取所有用来展示在列表的技师图片的id */ - public getAllDisplayGrilPhotoId(categoryId: string, girlId: number): number[] { + public getAllDisplayGrilPhotoId( + categoryId: string, + girlId: number + ): number[] { let oneData = this.getGrilDetail(categoryId, girlId); if (!oneData) return []; // 所有id - let allId = oneData.getAllGrilPhotoId(); + let allId = oneData.getAllGrilPhotoId(); // 总聊天次数 let chatTotalCount = this.getChatTotalCount(categoryId, girlId); // 用来展示的id let displayIds = []; for (let id of allId) { - let unlockCounts = oneData.getGrilPhotoUnlockCounts(id); - let price = oneData.getGrilPhotoPrice(id); + let unlockCounts = oneData.getGrilPhotoUnlockCounts(id); + let price = oneData.getGrilPhotoPrice(id); if (price <= 0) { // 价格为0,代表免费 - displayIds.push(id); + displayIds.push({ id: id }); } else { // 价格大于0,代表付费 let isUnlock = this.isImageUnlock(categoryId, girlId, id); if (isUnlock) { // 已经解锁 - displayIds.push(id); + displayIds.push({ id: id }); } else { // 总聊天次数 大于等于 触发次数 if (chatTotalCount >= unlockCounts) { - displayIds.push(id); + displayIds.push({ id: id }); } } } } return displayIds; - } + } /** 获取第一个技师图片的资源路径 */ public getFirstGrilPhotoPath(categoryId: string, girlId: number): string { @@ -334,61 +354,80 @@ export class GirlData extends BaseData { const length = ids.length; if (length <= 0) return ""; // 返回数据 - return oneData.getGrilPhotoPath(ids[0]); - } + return oneData.getGrilPhotoPath(ids[0]); + } /** 获取技师图片的类型 */ - public getGrilPhotoType(categoryId: string, girlId: number, id: number): number { + public getGrilPhotoType( + categoryId: string, + girlId: number, + id: number + ): number { let oneData = this.getGrilDetail(categoryId, girlId); if (!oneData) return 0; - return oneData.getGrilPhotoType(id); - } + return oneData.getGrilPhotoType(id); + } /** 获取技师图片的聊天触发次数 */ - public getGrilPhotoUnlockCounts(categoryId: string, girlId: number, id: number): number { + public getGrilPhotoUnlockCounts( + categoryId: string, + girlId: number, + id: number + ): number { let oneData = this.getGrilDetail(categoryId, girlId); if (!oneData) return 0; - return oneData.getGrilPhotoUnlockCounts(id); - } - + return oneData.getGrilPhotoUnlockCounts(id); + } + /** 获取技师图片的价格 */ - public getGrilPhotoPrice(categoryId: string, girlId: number, id: number): number { + public getGrilPhotoPrice( + categoryId: string, + girlId: number, + id: number + ): number { let oneData = this.getGrilDetail(categoryId, girlId); if (!oneData) return 0; - return oneData.getGrilPhotoPrice(id); - } + return oneData.getGrilPhotoPrice(id); + } /** 获取技师图片的资源路径 */ - public getGrilPhotoPic(categoryId: string, girlId: number, id: number): string { + public getGrilPhotoPic( + categoryId: string, + girlId: number, + id: number + ): string { let oneData = this.getGrilDetail(categoryId, girlId); if (!oneData) return ""; - return oneData.getGrilPhotoPath(id); - } + return oneData.getGrilPhotoPath(id); + } /** 获取所有技师视频数据的数量 */ public getAllGrilVideoDataCount(categoryId: string, girlId: number): number { let oneData = this.getGrilDetail(categoryId, girlId); if (!oneData) return 0; - return oneData.getAllGrilVideoDataCount(); - } - + return oneData.getAllGrilVideoDataCount(); + } + /** 获取所有技师视频的id */ public getAllGrilVideoId(categoryId: string, girlId: number): number[] { let oneData = this.getGrilDetail(categoryId, girlId); if (!oneData) return []; - return oneData.getAllGrilVideoId(); - } + return oneData.getAllGrilVideoId(); + } /** 获取所有用来展示在列表的技师视频的id */ - public getAllDisplayGrilVideoId(categoryId: string, girlId: number): number[] { + public getAllDisplayGrilVideoId( + categoryId: string, + girlId: number + ): number[] { let oneData = this.getGrilDetail(categoryId, girlId); if (!oneData) return []; // 所有id - let allId = oneData.getAllGrilVideoId(); + let allId = oneData.getAllGrilVideoId(); // 用来展示的id let displayIds = []; for (let id of allId) { - let price = oneData.getGrilVideoPrice(id); + let price = oneData.getGrilVideoPrice(id); if (price <= 0) { // 价格为0,代表免费 displayIds.push(id); @@ -398,12 +437,35 @@ export class GirlData extends BaseData { if (isUnlock) { // 已经解锁 displayIds.push(id); - } + } } } return displayIds; - } - + } + + /** 获取所有用来展示在列表的技师视频的id */ + public getGirlVideosData(categoryId: string, girlId: number): any[] { + let oneData = this.getGrilDetail(categoryId, girlId); + if (!oneData) return []; + // 所有id + let allId = oneData.getAllGrilVideoId(); + // 用来展示的id + let displayIds = []; + for (let id of allId) { + let price = oneData.getGrilVideoPrice(id); + let isUnlock = true; + if (price <= 0) { + // 价格为0,代表免费 + //displayIds.push(id); + } else { + // 价格大于0,代表付费 + isUnlock = this.isVideoUnlock(categoryId, girlId, id); + } + displayIds.push({ id: id, isUnlock: isUnlock, price: price }); + } + return displayIds; + } + /** 获取第一个技师视频的资源路径 */ public getFirstGrilVideoPath(categoryId: string, girlId: number): string { let oneData = this.getGrilDetail(categoryId, girlId); @@ -413,30 +475,42 @@ export class GirlData extends BaseData { const length = ids.length; if (length <= 0) return ""; // 返回数据 - return oneData.getGrilVideoPath(ids[0]); - } - + return oneData.getGrilVideoPath(ids[0]); + } + /** 获取技师视频的资源路径 */ - public getGrilVideoPath(categoryId: string, girlId: number, id: number): string { + public getGrilVideoPath( + categoryId: string, + girlId: number, + id: number + ): string { let oneData = this.getGrilDetail(categoryId, girlId); if (!oneData) return ""; - return oneData.getGrilVideoPath(id); - } + return oneData.getGrilVideoPath(id); + } /** 获取技师视频的关联情绪 */ - public getGrilVideoEmotion(categoryId: string, girlId: number, id: number): number { + public getGrilVideoEmotion( + categoryId: string, + girlId: number, + id: number + ): number { let oneData = this.getGrilDetail(categoryId, girlId); if (!oneData) return 0; - return oneData.getGrilVideoEmotion(id); - } + return oneData.getGrilVideoEmotion(id); + } /** 获取技师视频的价格 */ - public getGrilVideoPrice(categoryId: string, girlId: number, id: number): number { + public getGrilVideoPrice( + categoryId: string, + girlId: number, + id: number + ): number { let oneData = this.getGrilDetail(categoryId, girlId); if (!oneData) return 0; - return oneData.getGrilVideoPrice(id); - } - + return oneData.getGrilVideoPrice(id); + } + /** --------------------------------------------------------- 技师的解锁数据 --------------------------------------------------------- */ // 解析技师解锁数据,一个 @@ -472,63 +546,74 @@ export class GirlData extends BaseData { if (!one) continue; bucket.unlocks.set(g.id, one); } - } - + } + /** 取某分类 + girlId 的解锁数据 */ - private getGrilUnlock(categoryId: string, girlId: number): GirlUnlockData | null { + private getGrilUnlock( + categoryId: string, + girlId: number + ): GirlUnlockData | null { const b = this.ensureCategories().get(categoryId); if (!b) return null; return b.unlocks.get(girlId) ?? null; - } + } /** 获取 付费技师是否已经解锁 */ public getIsRelease(categoryId: string, girlId: number): boolean { let oneData = this.getGrilUnlock(categoryId, girlId); if (!oneData) return false; return oneData.getIsRelease(); - } + } /** 判断图片是否解锁 */ - public isImageUnlock(categoryId: string, girlId: number, id: number): boolean { + public isImageUnlock( + categoryId: string, + girlId: number, + id: number + ): boolean { let oneData = this.getGrilUnlock(categoryId, girlId); if (!oneData) return false; return oneData.isImageUnlock(id); - } + } /** 解锁图片 */ public unlockImage(categoryId: string, girlId: number, id: number): void { let oneData = this.getGrilUnlock(categoryId, girlId); if (!oneData) return; return oneData.unlockImage(id); - } + } /** 获取所有解锁图片的 id */ public getUnlockedImageIds(categoryId: string, girlId: number): number[] { let oneData = this.getGrilUnlock(categoryId, girlId); if (!oneData) return []; return oneData.getUnlockedImageIds(); - } - + } + /** 判断视频是否解锁 */ - public isVideoUnlock(categoryId: string, girlId: number, id: number): boolean { + public isVideoUnlock( + categoryId: string, + girlId: number, + id: number + ): boolean { let oneData = this.getGrilUnlock(categoryId, girlId); if (!oneData) return false; return oneData.isVideoUnlock(id); - } - + } + /** 解锁视频 */ public unlockVideo(categoryId: string, girlId: number, id: number): void { let oneData = this.getGrilUnlock(categoryId, girlId); if (!oneData) return; return oneData.unlockVideo(id); - } - + } + /** 获取所有解锁视频的 id */ public getUnlockedVideoIds(categoryId: string, girlId: number): number[] { let oneData = this.getGrilUnlock(categoryId, girlId); if (!oneData) return []; return oneData.getUnlockedVideoIds(); - } + } /** --------------------------------------------------------- 技师的聊天数据 --------------------------------------------------------- */ @@ -552,64 +637,77 @@ export class GirlData extends BaseData { if (!one) continue; bucket.chats.set(g.id, one); } - } - + } + /** 取某分类 + girlId 的聊天数据 */ private getGrilChat(categoryId: string, girlId: number): GirlChatData | null { const b = this.ensureCategories().get(categoryId); if (!b) return null; return b.chats.get(girlId) ?? null; - } + } /** 获取总聊天次数 */ public getChatTotalCount(categoryId: string, girlId: number): number { let oneData = this.getGrilChat(categoryId, girlId); if (!oneData) return 0; return oneData.getChatTotalCount(); - } + } /** 保存总聊天次数 */ - public setChatTotalCount(categoryId: string, girlId: number, value: number): void { + public setChatTotalCount( + categoryId: string, + girlId: number, + value: number + ): void { let oneData = this.getGrilChat(categoryId, girlId); if (!oneData) return; return oneData.setChatTotalCount(value); - } - + } + /** 获取剩余聊天次数 */ public getChatRemainCount(categoryId: string, girlId: number): number { let oneData = this.getGrilChat(categoryId, girlId); if (!oneData) return 0; return oneData.getChatRemainCount(); - } - + } + /** 保存剩余聊天次数 */ - public setChatRemainCount(categoryId: string, girlId: number, value: number): void { + public setChatRemainCount( + categoryId: string, + girlId: number, + value: number + ): void { let oneData = this.getGrilChat(categoryId, girlId); if (!oneData) return; return oneData.setChatRemainCount(value); - } + } /** 更新剩余聊天次数 */ public useChat(categoryId: string, girlId: number, times: number = 1): void { let oneData = this.getGrilChat(categoryId, girlId); if (!oneData) return; return oneData.useChat(times); - } - + } + /** --------------------------------------------------------- 技师的好感度数据 --------------------------------------------------------- */ // 解析技师好感度数据,一个 - private parseOneGirlFavorability(data: proto.cs.IGirlData): GirlFavorabilityData | null { + private parseOneGirlFavorability( + data: proto.cs.IGirlData + ): GirlFavorabilityData | null { if (!data) return null; let oneData = new GirlFavorabilityData(); oneData.init?.(DataId.GirlFavorability); oneData.setId(data.id); oneData.setStar(data.star); return oneData; - } + } /** 保存技师的好感度数据 */ - private setGirlFavorability(categoryId: string, data: proto.cs.IGirlData[]): void { + private setGirlFavorability( + categoryId: string, + data: proto.cs.IGirlData[] + ): void { if (!data) return; const bucket = this.ensureBucket(categoryId); for (const g of data) { @@ -617,21 +715,24 @@ export class GirlData extends BaseData { if (!one) continue; bucket.favorability.set(g.id, one); } - } - + } + /** 取某分类 + girlId 的好感度数据 */ - private getGrilFavorability(categoryId: string, girlId: number): GirlFavorabilityData | null { + private getGrilFavorability( + categoryId: string, + girlId: number + ): GirlFavorabilityData | null { const b = this.ensureCategories().get(categoryId); if (!b) return null; return b.favorability.get(girlId) ?? null; - } - + } + /** 获取星级 */ public getStar(categoryId: string, girlId: number): number { let oneData = this.getGrilFavorability(categoryId, girlId); if (!oneData) return 0; return oneData.getStar(); - } + } /** --------------------------------------------------------- 每日推荐 --------------------------------------------------------- */ @@ -649,8 +750,8 @@ export class GirlData extends BaseData { const girlIds = bucket.girlIds; const length = girlIds.length; if (length <= 0) return 0; - return girlIds[length-1]; - } + return girlIds[length - 1]; + } /** 获取每日推荐的简要数据 */ private getRecommendGrilBrief(): GirlBriefData | null { @@ -658,19 +759,19 @@ export class GirlData extends BaseData { if (recId <= 0) return null; const data = this.getGrilBrief(DAILY_BUCKET, recId); return data; - } + } /** 获取名字 */ public getRecommendGrilName(): string { let oneData = this.getRecommendGrilBrief(); if (!oneData) return ""; return oneData.getGrilName(); - } + } /** 获取头像路径 */ public getRecommendGrilAvatar(): string { let oneData = this.getRecommendGrilBrief(); if (!oneData) return ""; return oneData.getGrilAvatar(); - } + } } diff --git a/assets/Scripts/chat18x/ui/panels/GirlDetailPanel.ts b/assets/Scripts/chat18x/ui/panels/GirlDetailPanel.ts index 1f531d68..75b942cb 100644 --- a/assets/Scripts/chat18x/ui/panels/GirlDetailPanel.ts +++ b/assets/Scripts/chat18x/ui/panels/GirlDetailPanel.ts @@ -188,26 +188,26 @@ export class GirlDetailPanel extends li_BaseView { bindVideoToggle() { const girlData = DataManager.I.getDataById(DataId.Girl); - let resIds = girlData.getAllDisplayGrilVideoId(this.category.toString(), this.id); - this.refreshImgs(2, this.category, this.id, resIds); + let videoDatas = girlData.getGirlVideosData(this.category.toString(), this.id); + this.refreshImgs(2, this.category, this.id, videoDatas); } refreshImgs( type: number, category: number, id: number, - resIds: number[] + datas: any[] ) { for (let i = this.imgsLayout.children.length - 1; i >= 0; i--) { this.imgsLayout.children[i].destroy(); } - let count = resIds.length; + let count = datas.length; for (let i = 0; i < count; i++) { let newNode = instantiate(this.imgItemInst.node); let item = newNode.getComponent(DetailImageItem); - let resId = resIds[i]; - item.refresh(this, type, category, id, resId); + let data = datas[i]; + item.refresh(this, type, category, id, data); newNode.active = true; this.imgsLayout.addChild(newNode); } diff --git a/assets/Scripts/chat18x/ui/panels/PopupGirlDetailPanel.ts b/assets/Scripts/chat18x/ui/panels/PopupGirlDetailPanel.ts index aa101ef3..d44c03d3 100644 --- a/assets/Scripts/chat18x/ui/panels/PopupGirlDetailPanel.ts +++ b/assets/Scripts/chat18x/ui/panels/PopupGirlDetailPanel.ts @@ -2,6 +2,7 @@ import { _decorator, Component, Node } from "cc"; import li_BaseView from "../../../Main/Common/li_BaseView"; import { GButton } from "../../../Main/Common/GButton"; import Utils from "../../../Main/Common/Utils"; +import { DetailImageItem } from "../../uiitems/DetailImageItem"; const { ccclass, property } = _decorator; @ccclass("PopupGirlDetailPanel") @@ -10,10 +11,11 @@ export class PopupGirlDetailPanel extends li_BaseView { private girlId: number; private resId: number; - + private base: DetailImageItem; openUIDataCT(data) { this.resId = data.resId; this.girlId = data.girlId; + this.base = data.base; } onLoadCT() { Utils.parseNode(this.node, this._nodeTab); @@ -29,5 +31,11 @@ export class PopupGirlDetailPanel extends li_BaseView { buyCharacter() { // 购买id为girlId的女生 console.log(this.girlId + "---" + this.resId); + + const success = true; + if (success) { + this.close(); + this.base.refreshVideoBuy(true); + } } } diff --git a/assets/Scripts/chat18x/uiitems/DetailImageItem.ts b/assets/Scripts/chat18x/uiitems/DetailImageItem.ts index 63a69cd7..e717aaa7 100644 --- a/assets/Scripts/chat18x/uiitems/DetailImageItem.ts +++ b/assets/Scripts/chat18x/uiitems/DetailImageItem.ts @@ -4,6 +4,7 @@ import { Label, math, Node, + randomRange, Sprite, UITransform, View, @@ -60,18 +61,26 @@ export class DetailImageItem extends Component { }, }; - //判断是否已经解锁此资源 - const isRelease = false; - if (isRelease) { + if (!this.isImage) { + //判断是否已经解锁此资源 + const isRelease = randomRange(0, 1) > 0.5; + if (isRelease) { + if (this.url) { + ViewManager.I.openBundlesView("ShowPanel", data); + this.base.setVideEnable(false); + } + } else { + ViewManager.I.openBundlesView("PopupGirlDetailPanel", { + resId: this.resId, + girlId: this.girlId, + base: this, + }); + } + } else { if (this.url) { ViewManager.I.openBundlesView("ShowPanel", data); this.base.setVideEnable(false); } - } else { - ViewManager.I.openBundlesView("PopupGirlDetailPanel", { - resId: this.resId, - girlId: this.girlId, - }); } } @@ -114,19 +123,20 @@ export class DetailImageItem extends Component { ); } } + refresh( base: GirlDetailPanel, type: number, category: number, id: number, - resId: number + data: any ) { this.base = base; this.type = type; this.category = category; this.girlId = id; - this.resId = resId; + this.resId = data.id; this.question.active = true; // 显示问号,表示加载中 const girlData = DataManager.I.getDataById(DataId.Girl); @@ -150,25 +160,20 @@ export class DetailImageItem extends Component { this.girlId, this.resId ); - let videoPrice = girlData.getGrilVideoPrice( - this.category.toString(), - this.girlId, - this.resId - ); this.url = girlData.getGrilVideoPath( this.category.toString(), this.girlId, this.resId ); - if (videoPrice > 0) { + if (!data.isUnlock) { imgPath = this.url + "_thumbnail_blur"; } else { imgPath = this.url + "_thumbnail"; } - this.priceFrame.active = videoPrice > 0; + this.priceFrame.active = data.price > 0; - this.videoPrice.string = videoPrice.toString(); + this.videoPrice.string = data.price.toString(); } ResManager.I.changeBundleSpriteFrame(this.img, imgPath, "Chat18x", () => { @@ -176,4 +181,14 @@ export class DetailImageItem extends Component { this.scaleToFillItem(); }); } + + refreshVideoBuy(success: boolean) { + if (success) { + const imgPath = this.url + "_thumbnail"; + ResManager.I.changeBundleSpriteFrame(this.img, imgPath, "Chat18x", () => { + this.question.active = false; // 图片加载成功后隐藏问号 + this.scaleToFillItem(); + }); + } + } } diff --git a/assets/Scripts/chat18x/uiitems/GirlListItem.ts b/assets/Scripts/chat18x/uiitems/GirlListItem.ts index 3e0b69cd..69c65332 100644 --- a/assets/Scripts/chat18x/uiitems/GirlListItem.ts +++ b/assets/Scripts/chat18x/uiitems/GirlListItem.ts @@ -148,7 +148,7 @@ export class GirlListItem extends Component { } onClickDetail() { - if (false) { + if (true) { NavigationManager.Instance.navigateToGirlDetail(this.id); ViewManager.I.closeView(this.baseNode); } else {