测试反馈修复

This commit is contained in:
2025-09-23 11:23:17 +08:00
parent e5c2c4f7ed
commit 568d360f49
7 changed files with 938 additions and 701 deletions
+159 -64
View File
@@ -127,7 +127,7 @@ export class GirlData extends BaseData {
}
const cats = this.ensureCategories();
logger.log("保存可聊天的技师数据: ", cats);
}
}
/** --------------------------------------------------------- 技师的简要数据 --------------------------------------------------------- */
@@ -200,7 +200,7 @@ export class GirlData extends BaseData {
const b = this.ensureCategories().get(categoryId);
if (!b) return false;
return b.briefs.has(girlId);
}
}
/** 获取名字键 */
public getGrilName(categoryId: string, girlId: number): string {
@@ -241,13 +241,13 @@ export class GirlData extends BaseData {
public isGirlFreeType(categoryId: string, girlId: number): boolean {
let priceType = this.getGrilPriceType(categoryId, girlId);
return priceType == PriceType.free;
}
}
/** 技师是否付费类型 */
public isGirlPayType(categoryId: string, girlId: number): boolean {
let priceType = this.getGrilPriceType(categoryId, girlId);
return priceType == PriceType.pay;
}
}
/** 获取原来的价格,除100 */
public getGrilOriginalPrice(categoryId: string, girlId: number): number {
@@ -329,7 +329,7 @@ export class GirlData extends BaseData {
const b = this.ensureCategories().get(categoryId);
if (!b) return false;
return b.details.has(girlId);
}
}
/** 取某分类 + girlId 的详细数据 */
public getGrilDetail(
@@ -365,7 +365,7 @@ export class GirlData extends BaseData {
/** 获取所有用来展示在列表的技师图片的id,可展示的有以下几种情况
* 1,图片类型为在详情页展示的(不管免费,付费,是否解锁)
* 2,图片类型为在聊天触发的,并且已经达到了触发次数的(不管是否已经解锁)
*/
*/
public getAllDisplayGrilPhotoId(
categoryId: string,
girlId: number
@@ -390,7 +390,7 @@ export class GirlData extends BaseData {
const isShowInChat = this.isGirlPhotoShowInChat(categoryId, girlId, id);
if (isShowInList) {
displayIds.push(id);
displayIds.push(id);
} else if (isShowInChat) {
// 总聊天次数 大于等于 触发次数
if (chatTotalCount >= unlockCounts) {
@@ -402,7 +402,11 @@ export class GirlData extends BaseData {
}
/** 用来展示在列表的技师图片是否可见 */
public isGirlPhotoVisible(categoryId: string, girlId: number, id: number): boolean {
public isGirlPhotoVisible(
categoryId: string,
girlId: number,
id: number
): boolean {
// 免费
const isFreeType = this.isGirlPhotoFreeType(categoryId, girlId, id);
// 付费
@@ -425,7 +429,7 @@ export class GirlData extends BaseData {
// 总聊天次数 大于等于 触发次数
const isUnlock = this.isImageUnlock(categoryId, girlId, id);
// 已经解锁,可见
if (isUnlock) return true;
if (isUnlock) return true;
}
// 其他情况,不可见
return false;
@@ -442,7 +446,7 @@ export class GirlData extends BaseData {
// 遍历
for (let id of allId) {
let count = this.getGrilPhotoUnlockCounts(categoryId, girlId, id);
if (chatTotalCount >= count) return id;
if (chatTotalCount == count) return id;
}
return 0;
}
@@ -460,36 +464,52 @@ export class GirlData extends BaseData {
}
/** 图片展示类型:在详情页展示 */
public isGirlPhotoShowInList(categoryId: string, girlId: number, id: number): boolean {
public isGirlPhotoShowInList(
categoryId: string,
girlId: number,
id: number
): boolean {
let oneData = this.getGrilDetail(categoryId, girlId);
if (!oneData) return false;
return oneData.isGirlPhotoShowInList(id);
}
}
/** 图片展示类型:在聊天触发 */
public isGirlPhotoShowInChat(categoryId: string, girlId: number, id: number): boolean {
public isGirlPhotoShowInChat(
categoryId: string,
girlId: number,
id: number
): boolean {
let oneData = this.getGrilDetail(categoryId, girlId);
if (!oneData) return false;
return oneData.isGirlPhotoShowInChat(id);
}
}
/** 图片是否免费 */
public isGirlPhotoFreeType(categoryId: string, girlId: number, id: number): boolean {
public isGirlPhotoFreeType(
categoryId: string,
girlId: number,
id: number
): boolean {
let oneData = this.getGrilDetail(categoryId, girlId);
if (!oneData) return false;
// 价格
const price = oneData.getGrilPhotoPrice(id);
return price <= 0;
}
}
/** 图片是否需要付费 */
public isGirlPhotoPayType(categoryId: string, girlId: number, id: number): boolean {
public isGirlPhotoPayType(
categoryId: string,
girlId: number,
id: number
): boolean {
let oneData = this.getGrilDetail(categoryId, girlId);
if (!oneData) return true;
// 价格
const price = oneData.getGrilPhotoPrice(id);
return price > 0;
}
}
/** 获取技师图片的类型 */
public getGrilPhotoType(
@@ -571,7 +591,11 @@ export class GirlData extends BaseData {
}
/** 用来展示在列表的技师视频是否可见 */
public isGirlVideoVisible(categoryId: string, girlId: number, id: number): boolean {
public isGirlVideoVisible(
categoryId: string,
girlId: number,
id: number
): boolean {
// 免费
const isFreeType = this.isGirlVideoFreeType(categoryId, girlId, id);
// 付费
@@ -583,29 +607,37 @@ export class GirlData extends BaseData {
} else if (isPayType) {
// 付费,并且已经解锁,可见
const isUnlock = this.isVideoUnlock(categoryId, girlId, id);
if (isUnlock) return true;
if (isUnlock) return true;
}
// 其他情况,不可见
return false;
}
/** 视频是否免费 */
public isGirlVideoFreeType(categoryId: string, girlId: number, id: number): boolean {
public isGirlVideoFreeType(
categoryId: string,
girlId: number,
id: number
): boolean {
let oneData = this.getGrilDetail(categoryId, girlId);
if (!oneData) return false;
// 价格
const price = oneData.getGrilVideoPrice(id);
return price <= 0;
}
}
/** 视频是否需要付费 */
public isGirlVideoPayType(categoryId: string, girlId: number, id: number): boolean {
public isGirlVideoPayType(
categoryId: string,
girlId: number,
id: number
): boolean {
let oneData = this.getGrilDetail(categoryId, girlId);
if (!oneData) return true;
// 价格
const price = oneData.getGrilVideoPrice(id);
return price > 0;
}
}
/** 获取第一个技师视频的资源路径 */
public getFirstGrilVideoPath(categoryId: string, girlId: number): string {
@@ -667,7 +699,13 @@ export class GirlData extends BaseData {
/** --------------------------------------------------------- 技师的解锁数据 --------------------------------------------------------- */
// 创建一个技师解锁数据
private createOneGirlUnlock(id: number, isRelease: boolean, unlockTime: number, unlockedImageIds: number[], unlockedVideoIds: number[]): GirlUnlockData {
private createOneGirlUnlock(
id: number,
isRelease: boolean,
unlockTime: number,
unlockedImageIds: number[],
unlockedVideoIds: number[]
): GirlUnlockData {
let oneData = new GirlUnlockData();
oneData.init?.(DataId.GirlUnlock);
oneData.setId(id);
@@ -697,9 +735,15 @@ export class GirlData extends BaseData {
unlockedVideoIds.push(one.resId);
}
}
let oneData = this.createOneGirlUnlock(data.id, data.isRelease, Number(data.unlockTime), unlockedImageIds, unlockedVideoIds);
let oneData = this.createOneGirlUnlock(
data.id,
data.isRelease,
Number(data.unlockTime),
unlockedImageIds,
unlockedVideoIds
);
return oneData;
}
}
/** 保存技师的解锁数据 */
private setGirlUnlock(categoryId: string, data: proto.cs.IGirlData[]): void {
@@ -726,12 +770,18 @@ export class GirlData extends BaseData {
} else {
// 不存在数据,创建
const bucket = this.ensureBucket(categoryId.toString());
let oneData = this.createOneGirlUnlock(data.id, data.isRelease, Number(data.unlockTime), [], []);
let oneData = this.createOneGirlUnlock(
data.id,
data.isRelease,
Number(data.unlockTime),
[],
[]
);
if (oneData) {
bucket.unlocks.set(data.id, oneData);
}
}
}
}
/** 取某分类 + girlId 的解锁数据 */
private getGrilUnlock(
@@ -748,7 +798,7 @@ export class GirlData extends BaseData {
const b = this.ensureCategories().get(categoryId);
if (!b) return false;
return b.unlocks.has(girlId);
}
}
/** 获取 付费技师是否已经解锁 */
public getIsRelease(categoryId: string, girlId: number): boolean {
@@ -776,11 +826,15 @@ export class GirlData extends BaseData {
}
/** 保存 角色解锁时间,时间戳,秒 */
public setUnlockTime(categoryId: string, girlId: number, value: number): void {
public setUnlockTime(
categoryId: string,
girlId: number,
value: number
): void {
let oneData = this.getGrilUnlock(categoryId, girlId);
if (!oneData) return;
oneData.setUnlockTime(value);
}
}
/** 判断图片是否解锁 */
public isImageUnlock(
@@ -848,12 +902,16 @@ export class GirlData extends BaseData {
}
// 返回结果
return result;
}
}
/** --------------------------------------------------------- 技师的聊天数据 --------------------------------------------------------- */
// 创建一个技师聊天数据
private createOneGirlChat(id: number, chatTotalCount: number, chatRemainCount: number): GirlChatData {
private createOneGirlChat(
id: number,
chatTotalCount: number,
chatRemainCount: number
): GirlChatData {
let oneData = new GirlChatData();
oneData.init?.(DataId.GirlChat);
oneData.setId(id);
@@ -865,7 +923,11 @@ export class GirlData extends BaseData {
// 解析技师聊天数据,一个
private parseOneGirlChat(data: proto.cs.IGirlData): GirlChatData | null {
if (!data) return null;
let oneData = this.createOneGirlChat(data.id, data.chatTotalCount, data.chatRemainCount);
let oneData = this.createOneGirlChat(
data.id,
data.chatTotalCount,
data.chatRemainCount
);
return oneData;
}
@@ -895,13 +957,17 @@ export class GirlData extends BaseData {
} else {
// 不存在数据,创建
const bucket = this.ensureBucket(categoryId.toString());
let oneData = this.createOneGirlChat(data.id, data.chatTotalCount, data.chatRemainCount);
let oneData = this.createOneGirlChat(
data.id,
data.chatTotalCount,
data.chatRemainCount
);
if (oneData) {
oneData.setChatRecord(data.msgs);
bucket.chats.set(data.id, oneData);
}
}
}
}
/** 取某分类 + girlId 的聊天数据 */
private getGrilChat(categoryId: string, girlId: number): GirlChatData | null {
@@ -915,7 +981,7 @@ export class GirlData extends BaseData {
const b = this.ensureCategories().get(categoryId);
if (!b) return false;
return b.chats.has(girlId);
}
}
/** 获取总聊天次数 */
public getChatTotalCount(categoryId: string, girlId: number): number {
@@ -965,50 +1031,68 @@ export class GirlData extends BaseData {
let oneData = this.getGrilChat(categoryId, girlId);
if (!oneData) return false;
return oneData.isCanChat();
}
}
/** 保存聊天记录 */
public setChatRecord(categoryId: string, girlId: number, data: proto.cs.IChatMsg[]): void {
public setChatRecord(
categoryId: string,
girlId: number,
data: proto.cs.IChatMsg[]
): void {
let oneData = this.getGrilChat(categoryId, girlId);
if (!oneData) return;
oneData.setChatRecord(data);
}
}
/** 获取聊天记录的所有 id */
public getChatRecordIds(categoryId: string, girlId: number): number[] {
let oneData = this.getGrilChat(categoryId, girlId);
if (!oneData) return [];
return oneData.getChatRecordIds();
}
}
/** 获取最新的聊天记录的id */
public getLatestChatRecordId(categoryId: string, girlId: number): number | null {
public getLatestChatRecordId(
categoryId: string,
girlId: number
): number | null {
let oneData = this.getGrilChat(categoryId, girlId);
if (!oneData) return null;
return oneData.getLatestChatRecordId();
}
}
/** 获取最新的聊天记录的时间戳(毫秒) */
public getLatestChatRecordTimestamp(categoryId: string, girlId: number): number | null {
public getLatestChatRecordTimestamp(
categoryId: string,
girlId: number
): number | null {
let oneData = this.getGrilChat(categoryId, girlId);
if (!oneData) return null;
return oneData.getLatestChatRecordTimestamp();
}
}
/** 获取聊天记录,根据 id,是否是 ai 聊天数据 */
public getChatRecordIsAi(categoryId: string, girlId: number, id: number): boolean {
public getChatRecordIsAi(
categoryId: string,
girlId: number,
id: number
): boolean {
let oneData = this.getGrilChat(categoryId, girlId);
if (!oneData) return false;
return oneData.getChatRecordIsAi(id);
}
}
/** 获取聊天记录,根据 id,聊天内容 */
public getChatRecordMsg(categoryId: string, girlId: number, id: number): string {
public getChatRecordMsg(
categoryId: string,
girlId: number,
id: number
): string {
let oneData = this.getGrilChat(categoryId, girlId);
if (!oneData) return "";
return oneData.getChatRecordMsg(id);
}
}
/** 获取所有可聊天的技师 id */
public getAllCanChatGirlIds(): number[] {
const result: number[] = [];
@@ -1022,7 +1106,7 @@ export class GirlData extends BaseData {
result.push(girlId);
}
}
}
}
// 排序
// 1,都存在聊天记录,按照聊天时间从近到远,否则,有聊天记录的排在前面
// 2,都没有聊天记录
@@ -1066,12 +1150,15 @@ export class GirlData extends BaseData {
// 返回结果
return result;
}
}
/** --------------------------------------------------------- 技师的好感度数据 --------------------------------------------------------- */
// 创建一个技师好感度数据
private createOneGirlFavorability(id: number, star: number): GirlFavorabilityData {
private createOneGirlFavorability(
id: number,
star: number
): GirlFavorabilityData {
let oneData = new GirlFavorabilityData();
oneData.init?.(DataId.GirlFavorability);
oneData.setId(id);
@@ -1080,14 +1167,19 @@ export class GirlData extends BaseData {
}
// 解析技师好感度数据,一个
private parseOneGirlFavorability(data: proto.cs.IGirlData): GirlFavorabilityData | null {
private parseOneGirlFavorability(
data: proto.cs.IGirlData
): GirlFavorabilityData | null {
if (!data) return null;
let oneData = this.createOneGirlFavorability(data.id, 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) {
@@ -1115,10 +1207,13 @@ export class GirlData extends BaseData {
bucket.favorability.set(data.id, oneData);
}
}
}
}
/** 取某分类 + 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;
@@ -1129,7 +1224,7 @@ export class GirlData extends BaseData {
const b = this.ensureCategories().get(categoryId);
if (!b) return false;
return b.favorability.has(girlId);
}
}
/** 获取星级 */
public getStar(categoryId: string, girlId: number): number {
@@ -1153,7 +1248,7 @@ export class GirlData extends BaseData {
const bucket = this.ensureCategories().get(DAILY_BUCKET);
if (!bucket) return false;
return bucket.girlIds.length > 0;
}
}
/** 获取推荐id */
public getRecommendGirlId(): number {
@@ -286,6 +286,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
let triggerId = girlData.getTriggerGrilPhotoId(this.categoryId, this.id);
if (triggerId == 0) return;
logger.log("Trigger pop up Image id:" + this.id + "--" + triggerId);
this.popUpImage.refresh(this.categoryId, this.id, triggerId);
@@ -8,6 +8,8 @@ import {
Size,
Vec3,
tween,
view,
screen,
} from "cc";
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
@@ -82,12 +84,30 @@ export class GirlDetailPanel extends li_BaseView {
@property(Node)
sendMsgText: Node;
private _nodeTab: any = {};
ImgVidSelect: Node;
ImgVidFakePos: Node;
// 跟随控制相关属性
private isFollowing: boolean = true; // 当前是否处于跟随状态
private lastFakePosPosition: Vec3 = new Vec3(); // 记录上次的位置
protected onEnable(): void {
this.refresh();
}
onLoadCT() {
super.onLoadCT();
Utils.parseNode(this.node, this._nodeTab);
this.ImgVidSelect = this._nodeTab.ImgVidSelect;
this.ImgVidFakePos = this._nodeTab.ImgVidFakePos;
// 初始化位置跟随
if (this.ImgVidFakePos) {
this.lastFakePosPosition = this.ImgVidFakePos.position.clone();
}
DetailImageItemPool.Instance.setTemplate(this.imgItemInst.node);
@@ -360,6 +380,75 @@ export class GirlDetailPanel extends li_BaseView {
super.onClose();
}
/**
* 检测节点是否在屏幕可见区域内
* @param node 要检测的节点
* @returns 是否在屏幕内
*/
private isNodeInScreen(node: Node): boolean {
if (!node) return false;
const uiTransform = node.getComponent(UITransform);
if (!uiTransform) return false;
// 获取屏幕尺寸
const screenSize = screen.windowSize;
const designResolution = view.getDesignResolutionSize();
// 获取节点的世界坐标
const worldPos = uiTransform.convertToWorldSpaceAR(Vec3.ZERO);
// 获取节点的尺寸
const nodeSize = uiTransform.contentSize;
// 计算节点的边界
const left = worldPos.x - nodeSize.width * uiTransform.anchorX;
const right = worldPos.x + nodeSize.width * (1 - uiTransform.anchorX);
const bottom = worldPos.y - nodeSize.height * uiTransform.anchorY;
const top = worldPos.y + nodeSize.height * (1 - uiTransform.anchorY);
// 检测是否完全在屏幕内
const isInScreen =
left >= 0 &&
right <= designResolution.width &&
bottom >= 0 &&
top <= designResolution.height - 160;
return isInScreen;
}
/**
* 实时更新ImgVidSelect跟随ImgVidFakePos的逻辑
*/
lateUpdate(dt: number) {
if (!this.ImgVidSelect || !this.ImgVidFakePos) {
return;
}
// 检测ImgVidFakePos是否在屏幕内
const isInScreen = this.isNodeInScreen(this.ImgVidFakePos);
if (isInScreen) {
// 在屏幕内,开始或继续跟随
if (!this.isFollowing) {
this.isFollowing = true;
logger.log("ImgVidSelect开始跟随ImgVidFakePos");
}
// 更新ImgVidSelect的位置到ImgVidFakePos的位置
this.ImgVidSelect.worldPosition =
this.ImgVidFakePos.worldPosition.clone();
this.lastFakePosPosition = this.ImgVidFakePos.worldPosition.clone();
} else {
// 超出屏幕,停止跟随
if (this.isFollowing) {
this.isFollowing = false;
logger.log("ImgVidSelect停止跟随ImgVidFakePos(超出屏幕)");
// ImgVidSelect保持在最后的跟随位置
}
}
}
/**
* 面板销毁时的清理工作
*/
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -4062,7 +4062,7 @@
},
{
"__type__": "cc.Node",
"_name": "ENT_BEP",
"_name": "ENT_ETH",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
@@ -4511,7 +4511,7 @@
},
{
"__type__": "cc.Node",
"_name": "ENT_ETH",
"_name": "ENT_BEP",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
Binary file not shown.