Merge branch 'main' of 47.107.44.202:xionglijia/18xchat
This commit is contained in:
@@ -329,17 +329,16 @@ export default class ResManager {
|
|||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
|
|
||||||
//region 加载远程图片
|
/** 加载远程图片 */
|
||||||
/**
|
changeRemoteSpriteFrame(spt: Sprite, url: string, cb: Function = null) {
|
||||||
* 获取远程图片资源并设置
|
|
||||||
* @param spt 要设置的节点
|
|
||||||
* @param url url地址
|
|
||||||
* @param suffix 图片后缀名
|
|
||||||
* @param cb 回调函数
|
|
||||||
*/
|
|
||||||
changeRemoteSpriteFrame(spt: Sprite, url: string, suffix: string = 'png', cb: Function = null) {
|
|
||||||
if (!spt || !url) return;
|
if (!spt || !url) return;
|
||||||
assetManager.loadRemote<ImageAsset>(url, {ext: '.'+suffix}, (err, res: ImageAsset) => {
|
// 临时加了一个字段,用来保存当前加载的资源路径
|
||||||
|
let spttemp:any = spt;
|
||||||
|
// 在异步回调时判断这个组件是不是还在加载同一个 url,避免多次调用时产生覆盖冲突
|
||||||
|
spttemp.frameUrl = url;
|
||||||
|
// 加载
|
||||||
|
assetManager.loadRemote<ImageAsset>(url, (err, res: ImageAsset) => {
|
||||||
|
console.log("加载远程图片: ", url);
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return
|
||||||
@@ -347,18 +346,42 @@ export default class ResManager {
|
|||||||
if (!spt.isValid) {
|
if (!spt.isValid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (spttemp.frameUrl != url) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const spriteFrame = new SpriteFrame();
|
const spriteFrame = new SpriteFrame();
|
||||||
const texture = new Texture2D();
|
const texture = new Texture2D();
|
||||||
texture.image = res;
|
texture.image = res;
|
||||||
spriteFrame.texture = texture;
|
spriteFrame.texture = texture;
|
||||||
|
|
||||||
spt.spriteFrame = spriteFrame;
|
spt.spriteFrame = spriteFrame;
|
||||||
cb && cb(res);
|
cb && cb(res);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 加载远程视频 */
|
||||||
|
loadRemoteVideo(spt: VideoPlayer, url: string, cb: Function = null) {
|
||||||
|
if (!spt || !url) return;
|
||||||
|
// 临时加了一个字段,用来保存当前加载的资源路径
|
||||||
|
let spttemp:any = spt;
|
||||||
|
// 在异步回调时判断这个组件是不是还在加载同一个 url,避免多次调用时产生覆盖冲突
|
||||||
|
spttemp.frameUrl = url;
|
||||||
|
// 加载
|
||||||
|
assetManager.loadRemote<VideoClip>(url, (err, res: VideoClip) => {
|
||||||
|
console.log("加载远程视频: ", url);
|
||||||
|
if (err) {
|
||||||
|
console.error(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!spt.isValid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (spttemp.frameUrl != url) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
spt.clip = res;
|
||||||
|
cb && cb(res);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/** 加载resources里的PB path:不带后缀*/
|
/** 加载resources里的PB path:不带后缀*/
|
||||||
|
|||||||
@@ -176,6 +176,13 @@ export class GirlData extends BaseData {
|
|||||||
return b.briefs.get(girlId) ?? null;
|
return b.briefs.get(girlId) ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 技师的简要信息是否存在 */
|
||||||
|
public isGirlBriefIn(categoryId: string, girlId: number): boolean {
|
||||||
|
const b = this.ensureCategories().get(categoryId);
|
||||||
|
if (!b) return false;
|
||||||
|
return b.briefs.has(girlId);
|
||||||
|
}
|
||||||
|
|
||||||
/** 获取名字键 */
|
/** 获取名字键 */
|
||||||
public getGrilName(categoryId: string, girlId: number): string {
|
public getGrilName(categoryId: string, girlId: number): string {
|
||||||
let oneData = this.getGrilBrief(categoryId, girlId);
|
let oneData = this.getGrilBrief(categoryId, girlId);
|
||||||
@@ -286,6 +293,13 @@ export class GirlData extends BaseData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 技师的详细信息是否存在 */
|
||||||
|
public isGirlDetailIn(categoryId: string, girlId: number): boolean {
|
||||||
|
const b = this.ensureCategories().get(categoryId);
|
||||||
|
if (!b) return false;
|
||||||
|
return b.details.has(girlId);
|
||||||
|
}
|
||||||
|
|
||||||
/** 取某分类 + girlId 的详细数据 */
|
/** 取某分类 + girlId 的详细数据 */
|
||||||
public getGrilDetail(
|
public getGrilDetail(
|
||||||
categoryId: string,
|
categoryId: string,
|
||||||
@@ -666,6 +680,13 @@ export class GirlData extends BaseData {
|
|||||||
return b.unlocks.get(girlId) ?? null;
|
return b.unlocks.get(girlId) ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 技师的解锁数据是否存在 */
|
||||||
|
public isGirlUnlockIn(categoryId: string, girlId: number): boolean {
|
||||||
|
const b = this.ensureCategories().get(categoryId);
|
||||||
|
if (!b) return false;
|
||||||
|
return b.unlocks.has(girlId);
|
||||||
|
}
|
||||||
|
|
||||||
/** 获取 付费技师是否已经解锁 */
|
/** 获取 付费技师是否已经解锁 */
|
||||||
public getIsRelease(categoryId: string, girlId: number): boolean {
|
public getIsRelease(categoryId: string, girlId: number): boolean {
|
||||||
let oneData = this.getGrilUnlock(categoryId, girlId);
|
let oneData = this.getGrilUnlock(categoryId, girlId);
|
||||||
@@ -765,6 +786,13 @@ export class GirlData extends BaseData {
|
|||||||
return b.chats.get(girlId) ?? null;
|
return b.chats.get(girlId) ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 技师的聊天数据是否存在 */
|
||||||
|
public isGirlChatIn(categoryId: string, girlId: number): boolean {
|
||||||
|
const b = this.ensureCategories().get(categoryId);
|
||||||
|
if (!b) return false;
|
||||||
|
return b.chats.has(girlId);
|
||||||
|
}
|
||||||
|
|
||||||
/** 获取总聊天次数 */
|
/** 获取总聊天次数 */
|
||||||
public getChatTotalCount(categoryId: string, girlId: number): number {
|
public getChatTotalCount(categoryId: string, girlId: number): number {
|
||||||
let oneData = this.getGrilChat(categoryId, girlId);
|
let oneData = this.getGrilChat(categoryId, girlId);
|
||||||
@@ -889,6 +917,13 @@ export class GirlData extends BaseData {
|
|||||||
return b.favorability.get(girlId) ?? null;
|
return b.favorability.get(girlId) ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 技师的好感度数据是否存在 */
|
||||||
|
public isGirlFavorabilityIn(categoryId: string, girlId: number): boolean {
|
||||||
|
const b = this.ensureCategories().get(categoryId);
|
||||||
|
if (!b) return false;
|
||||||
|
return b.favorability.has(girlId);
|
||||||
|
}
|
||||||
|
|
||||||
/** 获取星级 */
|
/** 获取星级 */
|
||||||
public getStar(categoryId: string, girlId: number): number {
|
public getStar(categoryId: string, girlId: number): number {
|
||||||
let oneData = this.getGrilFavorability(categoryId, girlId);
|
let oneData = this.getGrilFavorability(categoryId, girlId);
|
||||||
@@ -906,6 +941,13 @@ export class GirlData extends BaseData {
|
|||||||
console.log("保存每日推荐: ", bucket);
|
console.log("保存每日推荐: ", bucket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 判断每日推荐是否存在 */
|
||||||
|
public isDailyRecommendIn(): boolean {
|
||||||
|
const bucket = this.ensureCategories().get(DAILY_BUCKET);
|
||||||
|
if (!bucket) return false;
|
||||||
|
return bucket.girlIds.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** 获取推荐id */
|
/** 获取推荐id */
|
||||||
public getRecommendGirlId(): number {
|
public getRecommendGirlId(): number {
|
||||||
const bucket = this.ensureBucket(DAILY_BUCKET);
|
const bucket = this.ensureBucket(DAILY_BUCKET);
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import Utils from "db://assets/Scripts/Main/Common/Utils";
|
|||||||
import { ViewManager } from "db://assets/Scripts/Main/Manager/ViewManager";
|
import { ViewManager } from "db://assets/Scripts/Main/Manager/ViewManager";
|
||||||
import { GButton } from "db://assets/Scripts/Main/Common/GButton";
|
import { GButton } from "db://assets/Scripts/Main/Common/GButton";
|
||||||
import { SceneBgVideoLayer } from "../../../Sub/UI/SceneBgVideoLayer";
|
import { SceneBgVideoLayer } from "../../../Sub/UI/SceneBgVideoLayer";
|
||||||
|
import { DataManager, DataId } from "../../data/DataManager";
|
||||||
|
import { EnvData } from "../../data/EnvData";
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
interface ShowPanelData {
|
interface ShowPanelData {
|
||||||
@@ -67,8 +69,14 @@ export class ShowPanel extends li_BaseView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
show(path: string) {
|
show(path: string) {
|
||||||
|
const envData = DataManager.I.getDataById<EnvData>(DataId.Env);
|
||||||
if (this.isImg) {
|
if (this.isImg) {
|
||||||
ResManager.I.changeBundleSpriteFrame(this.image, path, "Girls", () => {
|
// ResManager.I.changeBundleSpriteFrame(this.image, path, "Girls", () => {
|
||||||
|
// Utils.adjustBgPixelRatio(this.image.node, 3);
|
||||||
|
// });
|
||||||
|
// 加载远程资源
|
||||||
|
let newPath = envData.cdn + "/" + "Girls/" + path + ".png";
|
||||||
|
ResManager.I.changeRemoteSpriteFrame(this.image, newPath, () => {
|
||||||
Utils.adjustBgPixelRatio(this.image.node, 3);
|
Utils.adjustBgPixelRatio(this.image.node, 3);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -77,11 +85,11 @@ export class ShowPanel extends li_BaseView {
|
|||||||
const targetSize = this.videoArea
|
const targetSize = this.videoArea
|
||||||
? new Size(this.videoArea.width, this.videoArea.height)
|
? new Size(this.videoArea.width, this.videoArea.height)
|
||||||
: new Size(600, 800);
|
: new Size(600, 800);
|
||||||
|
// 加载远程资源
|
||||||
ResManager.I.changeBundleVideo(
|
let newPath = envData.cdn + "/" + "Girls/" + path + ".mp4";
|
||||||
|
ResManager.I.loadRemoteVideo(
|
||||||
this.videoPlayer,
|
this.videoPlayer,
|
||||||
path,
|
newPath,
|
||||||
"Girls",
|
|
||||||
(res: VideoClip) => {
|
(res: VideoClip) => {
|
||||||
// 设置视频大小和位置
|
// 设置视频大小和位置
|
||||||
const uiTransform = this.videoPlayer.node.getComponent(UITransform);
|
const uiTransform = this.videoPlayer.node.getComponent(UITransform);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { GirlDetailPanel } from "../ui/panels/GirlDetailPanel";
|
|||||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||||
import { DataManager, DataId } from "../data/DataManager";
|
import { DataManager, DataId } from "../data/DataManager";
|
||||||
import { GirlData } from "../data/GirlData";
|
import { GirlData } from "../data/GirlData";
|
||||||
|
import { EnvData } from "../data/EnvData";
|
||||||
import { TipsPanel } from "../ui/panels/TipsPanel";
|
import { TipsPanel } from "../ui/panels/TipsPanel";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
@@ -204,7 +205,16 @@ export class DetailImageItem extends Component {
|
|||||||
imgPath = this.url + "_thumbnail_blur";
|
imgPath = this.url + "_thumbnail_blur";
|
||||||
}
|
}
|
||||||
|
|
||||||
ResManager.I.changeBundleSpriteFrame(this.img, imgPath, "Girls", () => {
|
// ResManager.I.changeBundleSpriteFrame(this.img, imgPath, "Girls", () => {
|
||||||
|
// this.question.active = false;
|
||||||
|
// this.scaleToFillItem();
|
||||||
|
// this.loading.active = false;
|
||||||
|
// });
|
||||||
|
|
||||||
|
// 加载远程资源
|
||||||
|
const envData = DataManager.I.getDataById<EnvData>(DataId.Env);
|
||||||
|
let newPath = envData.cdn + "/" + "Girls/" + imgPath + ".jpg";
|
||||||
|
ResManager.I.changeRemoteSpriteFrame(this.img, newPath, () => {
|
||||||
this.question.active = false;
|
this.question.active = false;
|
||||||
this.scaleToFillItem();
|
this.scaleToFillItem();
|
||||||
this.loading.active = false;
|
this.loading.active = false;
|
||||||
@@ -216,7 +226,15 @@ export class DetailImageItem extends Component {
|
|||||||
this.priceFrame.active = false;
|
this.priceFrame.active = false;
|
||||||
this.isVisible = true;
|
this.isVisible = true;
|
||||||
const imgPath = this.url + "_thumbnail";
|
const imgPath = this.url + "_thumbnail";
|
||||||
ResManager.I.changeBundleSpriteFrame(this.img, imgPath, "Girls", () => {
|
// ResManager.I.changeBundleSpriteFrame(this.img, imgPath, "Girls", () => {
|
||||||
|
// this.question.active = false; // 图片加载成功后隐藏问号
|
||||||
|
// this.scaleToFillItem();
|
||||||
|
// });
|
||||||
|
|
||||||
|
// 加载远程资源
|
||||||
|
const envData = DataManager.I.getDataById<EnvData>(DataId.Env);
|
||||||
|
let newPath = envData.cdn + "/" + "Girls/" + imgPath + ".jpg";
|
||||||
|
ResManager.I.changeRemoteSpriteFrame(this.img, newPath, () => {
|
||||||
this.question.active = false; // 图片加载成功后隐藏问号
|
this.question.active = false; // 图片加载成功后隐藏问号
|
||||||
this.scaleToFillItem();
|
this.scaleToFillItem();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user