Merge branch 'main' of 47.107.44.202:xionglijia/18xchat
This commit is contained in:
@@ -329,17 +329,16 @@ export default class ResManager {
|
||||
// })
|
||||
// }
|
||||
|
||||
//region 加载远程图片
|
||||
/**
|
||||
* 获取远程图片资源并设置
|
||||
* @param spt 要设置的节点
|
||||
* @param url url地址
|
||||
* @param suffix 图片后缀名
|
||||
* @param cb 回调函数
|
||||
*/
|
||||
changeRemoteSpriteFrame(spt: Sprite, url: string, suffix: string = 'png', cb: Function = null) {
|
||||
/** 加载远程图片 */
|
||||
changeRemoteSpriteFrame(spt: Sprite, url: string, cb: Function = null) {
|
||||
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) {
|
||||
console.log(err);
|
||||
return
|
||||
@@ -347,18 +346,42 @@ export default class ResManager {
|
||||
if (!spt.isValid) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (spttemp.frameUrl != url) {
|
||||
return;
|
||||
}
|
||||
const spriteFrame = new SpriteFrame();
|
||||
const texture = new Texture2D();
|
||||
texture.image = res;
|
||||
spriteFrame.texture = texture;
|
||||
|
||||
spt.spriteFrame = spriteFrame;
|
||||
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:不带后缀*/
|
||||
|
||||
@@ -176,6 +176,13 @@ export class GirlData extends BaseData {
|
||||
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 {
|
||||
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 的详细数据 */
|
||||
public getGrilDetail(
|
||||
categoryId: string,
|
||||
@@ -666,6 +680,13 @@ export class GirlData extends BaseData {
|
||||
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 {
|
||||
let oneData = this.getGrilUnlock(categoryId, girlId);
|
||||
@@ -765,6 +786,13 @@ export class GirlData extends BaseData {
|
||||
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 {
|
||||
let oneData = this.getGrilChat(categoryId, girlId);
|
||||
@@ -889,6 +917,13 @@ export class GirlData extends BaseData {
|
||||
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 {
|
||||
let oneData = this.getGrilFavorability(categoryId, girlId);
|
||||
@@ -906,6 +941,13 @@ export class GirlData extends BaseData {
|
||||
console.log("保存每日推荐: ", bucket);
|
||||
}
|
||||
|
||||
/** 判断每日推荐是否存在 */
|
||||
public isDailyRecommendIn(): boolean {
|
||||
const bucket = this.ensureCategories().get(DAILY_BUCKET);
|
||||
if (!bucket) return false;
|
||||
return bucket.girlIds.length > 0;
|
||||
}
|
||||
|
||||
/** 获取推荐id */
|
||||
public getRecommendGirlId(): number {
|
||||
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 { GButton } from "db://assets/Scripts/Main/Common/GButton";
|
||||
import { SceneBgVideoLayer } from "../../../Sub/UI/SceneBgVideoLayer";
|
||||
import { DataManager, DataId } from "../../data/DataManager";
|
||||
import { EnvData } from "../../data/EnvData";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
interface ShowPanelData {
|
||||
@@ -67,8 +69,14 @@ export class ShowPanel extends li_BaseView {
|
||||
}
|
||||
|
||||
show(path: string) {
|
||||
const envData = DataManager.I.getDataById<EnvData>(DataId.Env);
|
||||
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);
|
||||
});
|
||||
} else {
|
||||
@@ -77,11 +85,11 @@ export class ShowPanel extends li_BaseView {
|
||||
const targetSize = this.videoArea
|
||||
? new Size(this.videoArea.width, this.videoArea.height)
|
||||
: new Size(600, 800);
|
||||
|
||||
ResManager.I.changeBundleVideo(
|
||||
// 加载远程资源
|
||||
let newPath = envData.cdn + "/" + "Girls/" + path + ".mp4";
|
||||
ResManager.I.loadRemoteVideo(
|
||||
this.videoPlayer,
|
||||
path,
|
||||
"Girls",
|
||||
newPath,
|
||||
(res: VideoClip) => {
|
||||
// 设置视频大小和位置
|
||||
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 { DataManager, DataId } from "../data/DataManager";
|
||||
import { GirlData } from "../data/GirlData";
|
||||
import { EnvData } from "../data/EnvData";
|
||||
import { TipsPanel } from "../ui/panels/TipsPanel";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -204,7 +205,16 @@ export class DetailImageItem extends Component {
|
||||
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.scaleToFillItem();
|
||||
this.loading.active = false;
|
||||
@@ -216,7 +226,15 @@ export class DetailImageItem extends Component {
|
||||
this.priceFrame.active = false;
|
||||
this.isVisible = true;
|
||||
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.scaleToFillItem();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user