Files
18xchat/assets/Scripts/test/GirlDetailPanel.ts
T

119 lines
3.0 KiB
TypeScript
Raw Normal View History

2025-08-01 18:28:36 +08:00
import {_decorator, Label, Node, Sprite, VideoPlayer,instantiate} from "cc";
import {DemoManager} from "./DemoManager";
2025-07-25 18:27:30 +08:00
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
2025-08-01 18:28:36 +08:00
import {girlDetailInfo} from "db://assets/Scripts/Main/Config/cfg/characters";
import {Config18x} from "db://assets/Scripts/Main/Config/Config18x";
import PicType = Config18x.PicType;
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
import {DetailImageItem} from "db://assets/Scripts/test/girlListPanel/DetailImageItem";
import {GirlListItem} from "db://assets/Scripts/test/girlListPanel/GirlListItem";
import Utils from "db://assets/Scripts/Main/Common/Utils";
2025-07-22 16:43:10 +08:00
const { ccclass, property } = _decorator;
@ccclass("GirlDetailPanel")
2025-07-25 18:27:30 +08:00
export class GirlDetailPanel extends li_BaseView {
2025-07-22 16:43:10 +08:00
@property(Sprite)
avatar: Sprite;
2025-08-01 18:28:36 +08:00
@property(VideoPlayer)
avatarVideo: VideoPlayer;
2025-07-22 16:43:10 +08:00
@property(Label)
girlName: Label;
2025-07-30 21:52:26 +08:00
@property(Node)
starParent: Node;
@property(Label)
tags: Label;
@property(Label)
descName: Label;
@property(Label)
descAge: Label;
2025-07-22 16:43:10 +08:00
@property(Label)
desc: Label;
@property(Node)
chatBtn: Node;
id = 0;
2025-07-25 15:20:02 +08:00
2025-08-01 18:28:36 +08:00
@property(DetailImageItem)
imgItemInst:DetailImageItem;
@property(Node)
imgsLayout:Node;
2025-07-25 18:27:30 +08:00
openUIDataCT(data)
{
this.id = data;
2025-07-30 21:52:26 +08:00
}
onLoadCT() {
super.onLoadCT();
2025-08-01 18:28:36 +08:00
this.imgItemInst.node.active =false;
2025-07-25 18:27:30 +08:00
this.refresh(this.id);
2025-07-30 21:52:26 +08:00
2025-07-25 18:27:30 +08:00
}
2025-08-01 18:28:36 +08:00
setVideEnable(enable:boolean) {
this.avatarVideo.enabled = enable;
if(enable)
{
this.avatarVideo.play();
}
}
2025-07-25 15:20:02 +08:00
refresh(index:number)
{
2025-07-30 21:52:26 +08:00
console.log(index);
const data = girlDetailInfo.find(v=>v.baseInfo.id === index);
this.girlName.string=this.descName.string = data.baseInfo.name;
2025-08-01 18:28:36 +08:00
if(data.pics[0].picType == PicType.LocalGif)
{
ResManager.I.changeBundleVideo(this.avatarVideo,data.pics[0].url,"Chat18x");
}
if(data.pics.length>1)
{
for (let i = this.imgsLayout.children.length-1; i >=0 ; i--) {
this.imgsLayout.children[i].destroy();
}
for (let i = 1; i < data.pics.length; i++) {
const cfg = data.pics[i];
let newNode = instantiate(this.imgItemInst.node)
let item = newNode.getComponent(DetailImageItem);
item.refresh(cfg,this);
newNode.active = true;
this.imgsLayout.addChild(newNode);
}
}
2025-07-30 21:52:26 +08:00
this.desc.string = data.detailDesc;
let desc = '';
for (let i = 0; i < data.baseInfo.tag.length; i++) {
2025-08-01 18:28:36 +08:00
if(i!=0) desc += "\n"
desc += data.baseInfo.tag[i];
2025-07-30 21:52:26 +08:00
}
this.tags.string = desc;
for (let i = 0; i <5; i++) {
this.starParent.children[i].active =(i<data.baseInfo.starCount);
}
this.descAge.string = data.baseInfo.age.toString();
this.desc.string = data.detailDesc;
this.id = data.baseInfo.id;
2025-07-22 16:43:10 +08:00
}
OnClickChatBtn() {
DemoManager.getInstance().EnterChat(this.id);
2025-07-25 18:27:30 +08:00
this.onClose();
}
returnBtn()
{
this.onClose();
2025-08-01 18:28:36 +08:00
DemoManager.getInstance().EnterGirlList();
2025-07-25 18:27:30 +08:00
//ViewManager.I.openBundlesView("GirlListPanel");
2025-07-22 16:43:10 +08:00
}
}