137 lines
3.6 KiB
TypeScript
137 lines
3.6 KiB
TypeScript
import { _decorator, Label, Node, Sprite, VideoPlayer, instantiate } from "cc";
|
|
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
|
|
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
|
|
import { DetailImageItem } from "../../uiitems/DetailImageItem";
|
|
import { NavigationManager } from "../../manager/NavigationManager";
|
|
import ConfigManager from "../../manager/ConfigManager";
|
|
import LanguageUtils from "../../../Main/Common/LanguageUtils";
|
|
import Utils from "../../../Main/Common/Utils";
|
|
import { InnerMsgCode } from "../../../Main/Config/InnerMsgCode";
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass("GirlDetailPanel")
|
|
export class GirlDetailPanel extends li_BaseView {
|
|
@property(Sprite)
|
|
avatar: Sprite;
|
|
@property(VideoPlayer)
|
|
avatarVideo: VideoPlayer;
|
|
@property(Label)
|
|
girlName: Label;
|
|
|
|
@property(Node)
|
|
starParent: Node;
|
|
|
|
@property(Label)
|
|
tags: Label;
|
|
|
|
@property(Label)
|
|
descName: Label;
|
|
@property(Label)
|
|
descAge: Label;
|
|
@property(Label)
|
|
desc: Label;
|
|
|
|
@property(Node)
|
|
chatBtn: Node;
|
|
id = 0;
|
|
|
|
@property(DetailImageItem)
|
|
imgItemInst: DetailImageItem;
|
|
|
|
@property(Node)
|
|
imgsLayout: Node;
|
|
|
|
openUIDataCT(data) {
|
|
this.id = data;
|
|
}
|
|
|
|
onLoadCT() {
|
|
super.onLoadCT();
|
|
this.imgItemInst.node.active = false;
|
|
this.refresh(this.id);
|
|
|
|
Utils.addInnerEL(InnerMsgCode.LanguageChange, this, () => {
|
|
this.girlName.string = this.descName.string = LanguageUtils.getText(
|
|
this.nameKey
|
|
);
|
|
let desc = "";
|
|
const tags = LanguageUtils.getText(this.tagKey).split("|");
|
|
for (let i = 0; i < tags.length; i++) {
|
|
if (i != 0) desc += "\n";
|
|
desc += tags[i];
|
|
}
|
|
this.tags.string = desc;
|
|
});
|
|
}
|
|
|
|
setVideEnable(enable: boolean) {
|
|
this.avatarVideo.enabled = enable;
|
|
if (enable) {
|
|
this.avatarVideo.play();
|
|
}
|
|
}
|
|
nameKey: string;
|
|
tagKey: string;
|
|
category;
|
|
refresh(index: number) {
|
|
console.log(index);
|
|
const dataDetail = ConfigManager.tables.TbGirlsDetail.get(this.id);
|
|
const data = ConfigManager.tables.TbGirls.get(this.id);
|
|
this.category = data.category;
|
|
this.nameKey = data.nameKey;
|
|
this.girlName.string = this.descName.string = LanguageUtils.getText(
|
|
data.nameKey
|
|
);
|
|
|
|
if (dataDetail.pics[0].endsWith("video")) {
|
|
ResManager.I.changeBundleVideo(
|
|
this.avatarVideo,
|
|
dataDetail.pics[0],
|
|
"Chat18x"
|
|
);
|
|
}
|
|
if (dataDetail.pics.length > 1) {
|
|
for (let i = this.imgsLayout.children.length - 1; i >= 0; i--) {
|
|
this.imgsLayout.children[i].destroy();
|
|
}
|
|
|
|
for (let i = 1; i < dataDetail.pics.length; i++) {
|
|
const path = dataDetail.pics[i];
|
|
let newNode = instantiate(this.imgItemInst.node);
|
|
let item = newNode.getComponent(DetailImageItem);
|
|
item.refresh(path, this);
|
|
newNode.active = true;
|
|
this.imgsLayout.addChild(newNode);
|
|
}
|
|
}
|
|
|
|
this.desc.string = dataDetail.detailDesc;
|
|
let desc = "";
|
|
this.tagKey = data.tagKey;
|
|
const tags = LanguageUtils.getText(data.tagKey).split("|");
|
|
for (let i = 0; i < tags.length; i++) {
|
|
if (i != 0) desc += "\n";
|
|
desc += tags[i];
|
|
}
|
|
this.tags.string = desc;
|
|
for (let i = 0; i < 5; i++) {
|
|
this.starParent.children[i].active = i < data.starCount;
|
|
}
|
|
this.descAge.string = data.age.toString();
|
|
this.desc.string = dataDetail.detailDesc;
|
|
|
|
this.id = data.id;
|
|
}
|
|
OnClickChatBtn() {
|
|
NavigationManager.Instance.navigateToChat(this.id);
|
|
this.onClose();
|
|
}
|
|
|
|
returnBtn() {
|
|
this.onClose();
|
|
NavigationManager.Instance.navigateToGirlList(this.category);
|
|
//ViewManager.I.openBundlesView("GirlListPanel");
|
|
}
|
|
}
|