import { gameMethod } from "../../../common/gameMethod"; import { HelpType } from "../../../data/const/TypeConst"; import FguiMgr from "../../../frameWork/fgui/FguiMgr"; import ClickAuEffect from "../../../utils/ClickAuEffect"; export default class PopUpSecondView { private MaskBg: fairygui.GObject; private BgImg: fairygui.GObject; private TitleImg: fairygui.GObject; private HelpBtn: fairygui.GObject; private CloseBtn: fairygui.GObject; private _call: Function private _confirmCall: Function private helpId: HelpType; private closeUI: any; dispose: boolean; public constructor(vm: fgui.GComponent) { this.MaskBg = vm.getChild("MaskBg"); this.BgImg = vm.getChild("BgImg"); this.TitleImg = vm.getChild("TitleImg"); this.HelpBtn = vm.getChild("HelpBtn"); this.CloseBtn = vm.getChild("CloseBtn"); } public onEnable(): void { this.HelpBtn.onClick(this.OnClickHelpBtn, this); this.MaskBg.onClick(this.OnClickCloseBtn, this); this.CloseBtn.onClick(this.OnClickCloseBtn, this); } public onDisable(): void { this.HelpBtn.offClick(this.OnClickHelpBtn, this); 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 titleUrl 标题路径 * @param closeUI 关闭的界面 * @param helpId 帮助id * @param height 界面高度 */ setData(closeUI: any, helpId?: HelpType, titleUrl?: string, dispose: boolean = true) { // console.log('log', this); // 标题 if (titleUrl) { this.TitleImg.asLoader.url = titleUrl; } this.closeUI = closeUI; this.dispose = dispose // 帮助 if (helpId) { this.helpId = helpId; this.HelpBtn.visible = true; } else { this.HelpBtn.visible = false; } // 界面高度 // this.BgImg.height = height; } // 帮助 @ClickAuEffect() private OnClickHelpBtn() { if (!gameMethod.isEmpty(this.helpId)) { // FguiMgr.Instance.openUI(HelpViewView, ViewZorder.POP, null, this.helpId); } } // 关闭 @ClickAuEffect() private OnClickCloseBtn() { if (this._confirmCall) { // 用于点击关闭按钮 不关闭界面 弹出确认窗口 if (this._confirmCall) this._confirmCall(); } else { if (this._call) this._call() FguiMgr.Instance.closeUI(this.closeUI, this.dispose); } } }