
cc.Class({
    extends: cc.Component,

    properties: {
        cancelButton: cc.Button,
        okButton: cc.Button,

        //修改人物状态弹窗
        titleRichText: cc.RichText,
        coinRichText: cc.RichText,

        //失败弹窗
        errorTipsNode: cc.Node,
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {

    },

    init(information) {
      this.information = information;
    },

    closeAlert() {
        this.node.active = false;

    },

    showRelationErrorAlert(spriteFrameString, title, cancelAction) {

        cc.loader.loadRes(spriteFrameString, cc.SpriteFrame, (err, spriteFrame) => {
            this.errorTipsNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
        });

        this.titleRichText.string = title;

        if (cancelAction) {
            this.cancelAction = cancelAction;
        }

        this.node.active = true;
    },

    showRelationAlert(title,coin,cancelAction,okAction) {
        this.titleRichText.string = title;
        this.coinRichText.string = "<img src='alert_coin' /> " + coin;

        if (cancelAction) {
            this.cancelAction = cancelAction;
        }

        if (okAction) {
            this.okAction = okAction;
        }
        this.node.active = true;
    },

    alertCancelAction() {
        if (this.cancelAction) {
            this.cancelAction();
        }
    },

    alertOkAction() {
        if (this.okAction) {
            this.okAction();
        }
    },

    // update (dt) {},
});
