UICommonNotice.ts 1.71 KB
// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import { WindowName } from "../../Global";

import { UIBase } from "../UIBase";
import { UIManager } from "../UIManager";
import { UICommonNoticeEnableParam } from "./UICommonNoticeEnableParam";

const { ccclass, property } = cc._decorator;

@ccclass
export default class UICommonNotice extends UIBase {

    private _data: UICommonNoticeEnableParam;

    private _txtDesc: cc.Label;

    //#region  LIFE-CYCLE CALLBACKS:

    onLoad() {
        this._txtDesc = this.node.getChildByName('descNode').getComponentInChildren(cc.Label);

    }

    protected onEnable(): void {
        this._data = this.enableParam as UICommonNoticeEnableParam;

        if (this._data) {
            this._txtDesc.string = this._data.desc;
        }
    }


    // update (dt) {}

    //#endregion

    //#region public method

    //#endregion

    //#region event

    onBtnDoneClick() {

        UIManager.ins.closeWindow(WindowName.COMMON_NOTICE);

        if (this._data && this._data.doneCallBack && this._data.callBackThisObj) {
            this._data.doneCallBack.call(this._data.callBackThisObj);
        }
    }

    onBtnCancelClick() {

        UIManager.ins.closeWindow(WindowName.COMMON_NOTICE);

        if (this._data && this._data.cancelCallBack && this._data.callBackThisObj) {
            this._data.cancelCallBack.call(this._data.callBackThisObj);
        }

    }

    //#endregion

    //#region private method

    //#endregion
}