PopUpSecondView.ts 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { gameMethod } from "../../../common/gameMethod";
  2. import { HelpType } from "../../../data/const/TypeConst";
  3. import FguiMgr from "../../../frameWork/fgui/FguiMgr";
  4. import ClickAuEffect from "../../../utils/ClickAuEffect";
  5. export default class PopUpSecondView {
  6. private MaskBg: fairygui.GObject;
  7. private BgImg: fairygui.GObject;
  8. private TitleImg: fairygui.GObject;
  9. private HelpBtn: fairygui.GObject;
  10. private CloseBtn: fairygui.GObject;
  11. private _call: Function
  12. private _confirmCall: Function
  13. private helpId: HelpType;
  14. private closeUI: any;
  15. dispose: boolean;
  16. public constructor(vm: fgui.GComponent) {
  17. this.MaskBg = vm.getChild("MaskBg");
  18. this.BgImg = vm.getChild("BgImg");
  19. this.TitleImg = vm.getChild("TitleImg");
  20. this.HelpBtn = vm.getChild("HelpBtn");
  21. this.CloseBtn = vm.getChild("CloseBtn");
  22. }
  23. public onEnable(): void {
  24. this.HelpBtn.onClick(this.OnClickHelpBtn, this);
  25. this.MaskBg.onClick(this.OnClickCloseBtn, this);
  26. this.CloseBtn.onClick(this.OnClickCloseBtn, this);
  27. }
  28. public onDisable(): void {
  29. this.HelpBtn.offClick(this.OnClickHelpBtn, this);
  30. this.MaskBg.offClick(this.OnClickCloseBtn, this);
  31. this.CloseBtn.offClick(this.OnClickCloseBtn, this);
  32. }
  33. setCloseCall(cb: Function, target?: any) {
  34. this._call = cb.bind(target)
  35. }
  36. setCloseConfirmCall(cb: Function) {
  37. this._confirmCall = cb
  38. }
  39. /**
  40. *
  41. * @param titleUrl 标题路径
  42. * @param closeUI 关闭的界面
  43. * @param helpId 帮助id
  44. * @param height 界面高度
  45. */
  46. setData(closeUI: any, helpId?: HelpType, titleUrl?: string, dispose: boolean = true) {
  47. // console.log('log', this);
  48. // 标题
  49. if (titleUrl) {
  50. this.TitleImg.asLoader.url = titleUrl;
  51. }
  52. this.closeUI = closeUI;
  53. this.dispose = dispose
  54. // 帮助
  55. if (helpId) {
  56. this.helpId = helpId;
  57. this.HelpBtn.visible = true;
  58. } else {
  59. this.HelpBtn.visible = false;
  60. }
  61. // 界面高度
  62. // this.BgImg.height = height;
  63. }
  64. // 帮助
  65. @ClickAuEffect()
  66. private OnClickHelpBtn() {
  67. if (!gameMethod.isEmpty(this.helpId)) {
  68. // FguiMgr.Instance.openUI(HelpViewView, ViewZorder.POP, null, this.helpId);
  69. }
  70. }
  71. // 关闭
  72. @ClickAuEffect()
  73. private OnClickCloseBtn() {
  74. if (this._confirmCall) {
  75. // 用于点击关闭按钮 不关闭界面 弹出确认窗口
  76. if (this._confirmCall) this._confirmCall();
  77. } else {
  78. if (this._call) this._call()
  79. FguiMgr.Instance.closeUI(this.closeUI, this.dispose);
  80. }
  81. }
  82. }