import FguiMgr from "../../../frameWork/fgui/FguiMgr"; import ClickAuEffect from "../../../utils/ClickAuEffect"; export default class PopUpThirdView { private MaskBg: fairygui.GObject; private BgImg: fairygui.GObject; private TitleLabel: fairygui.GObject; private CloseBtn: fairygui.GObject; private _call: Function private _confirmCall: Function private closeUI: any; dispose: boolean; public constructor(vm: fgui.GComponent) { this.MaskBg = vm.getChild("MaskBg"); this.BgImg = vm.getChild("BgImg"); this.TitleLabel = vm.getChild("title"); this.CloseBtn = vm.getChild("CloseBtn"); } public onEnable(): void { this.MaskBg.onClick(this.OnClickCloseBtn, this); this.CloseBtn.onClick(this.OnClickCloseBtn, this); } public onDisable(): void { this.MaskBg.offClick(this.OnClickCloseBtn, this); this.CloseBtn.offClick(this.OnClickCloseBtn, this); } setCloseCall(cb:Function, target?:any){ this._call = cb.bind(target) } setCloseConfirmCall(cb: Function) { this._confirmCall = cb } /** * * @param titleStr 标题 * @param closeUI 关闭的界面 * @param height 界面高度 */ setData(closeUI: any, titleStr?: string, dispose: boolean = true) { // console.log('log', this); // 标题 if (titleStr) { this.TitleLabel.text = titleStr; } this.closeUI = closeUI; this.dispose = dispose // 界面高度 // this.BgImg.height = height; } /** * 设置标题 * @param titleStr 标题 */ setTitle(titleStr: string) { this.TitleLabel.text = titleStr; } // 关闭 @ClickAuEffect() private OnClickCloseBtn() { if (this._confirmCall) { // 用于点击关闭按钮 不关闭界面 弹出确认窗口 if (this._confirmCall) this._confirmCall(); } else { if (this._call) this._call() FguiMgr.Instance.closeUI(this.closeUI, this.dispose); } } /** 显示隐藏关闭按钮 */ public ShowCloseBtn(isShow:boolean) { this.CloseBtn.visible = isShow; } }