PopUpThirdView.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import FguiMgr from "../../../frameWork/fgui/FguiMgr";
  2. import ClickAuEffect from "../../../utils/ClickAuEffect";
  3. export default class PopUpThirdView {
  4. private MaskBg: fairygui.GObject;
  5. private BgImg: fairygui.GObject;
  6. private TitleLabel: fairygui.GObject;
  7. private CloseBtn: fairygui.GObject;
  8. private _call: Function
  9. private _confirmCall: Function
  10. private closeUI: any;
  11. dispose: boolean;
  12. public constructor(vm: fgui.GComponent) {
  13. this.MaskBg = vm.getChild("MaskBg");
  14. this.BgImg = vm.getChild("BgImg");
  15. this.TitleLabel = vm.getChild("title");
  16. this.CloseBtn = vm.getChild("CloseBtn");
  17. }
  18. public onEnable(): void {
  19. this.MaskBg.onClick(this.OnClickCloseBtn, this);
  20. this.CloseBtn.onClick(this.OnClickCloseBtn, this);
  21. }
  22. public onDisable(): void {
  23. this.MaskBg.offClick(this.OnClickCloseBtn, this);
  24. this.CloseBtn.offClick(this.OnClickCloseBtn, this);
  25. }
  26. setCloseCall(cb:Function, target?:any){
  27. this._call = cb.bind(target)
  28. }
  29. setCloseConfirmCall(cb: Function) {
  30. this._confirmCall = cb
  31. }
  32. /**
  33. *
  34. * @param titleStr 标题
  35. * @param closeUI 关闭的界面
  36. * @param height 界面高度
  37. */
  38. setData(closeUI: any, titleStr?: string, dispose: boolean = true) {
  39. // console.log('log', this);
  40. // 标题
  41. if (titleStr) {
  42. this.TitleLabel.text = titleStr;
  43. }
  44. this.closeUI = closeUI;
  45. this.dispose = dispose
  46. // 界面高度
  47. // this.BgImg.height = height;
  48. }
  49. /**
  50. * 设置标题
  51. * @param titleStr 标题
  52. */
  53. setTitle(titleStr: string) {
  54. this.TitleLabel.text = titleStr;
  55. }
  56. // 关闭
  57. @ClickAuEffect()
  58. private OnClickCloseBtn() {
  59. if (this._confirmCall) {
  60. // 用于点击关闭按钮 不关闭界面 弹出确认窗口
  61. if (this._confirmCall) this._confirmCall();
  62. } else {
  63. if (this._call) this._call()
  64. FguiMgr.Instance.closeUI(this.closeUI, this.dispose);
  65. }
  66. }
  67. /** 显示隐藏关闭按钮 */
  68. public ShowCloseBtn(isShow:boolean) {
  69. this.CloseBtn.visible = isShow;
  70. }
  71. }