import {_decorator, Label, Node, Sprite, VideoPlayer,instantiate} from "cc"; import {DemoManager} from "./DemoManager"; import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView"; 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"; 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); } setVideEnable(enable:boolean) { this.avatarVideo.enabled = enable; if(enable) { this.avatarVideo.play(); } } refresh(index:number) { console.log(index); const data = girlDetailInfo.find(v=>v.baseInfo.id === index); this.girlName.string=this.descName.string = data.baseInfo.name; 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); } } this.desc.string = data.detailDesc; let desc = ''; for (let i = 0; i < data.baseInfo.tag.length; i++) { if(i!=0) desc += "\n" desc += data.baseInfo.tag[i]; } this.tags.string = desc; for (let i = 0; i <5; i++) { this.starParent.children[i].active =(i