PlotStopViewPresenter.ts 2.38 KB

// import { DailyQuestType } from "../../../avg/EditorEnums";
import { Presenter } from "../../../common/classbase/PresenterBase";
import { GetRewardType } from "../../../common/gameplay/gamedata/GameEnumData";
import { GameTextData } from "../../../common/gameplay/gamedata/GameTextData";
import { UIManager } from "../../../common/gameplay/managers/UIManager";
import { GameModelManager } from "../../model/GameModelManager";
import { RegPresenter } from "../PresenterCCViewFactory";
import { PlotStopView, PlotStopViewProps, PlotStopViewType } from "../view/type/PlotStopView";
@RegPresenter(PlotStopViewType)
export default class PlotStopViewPresenter extends Presenter<undefined, PlotStopView>{
    static uuid = "PlotStopViewPresenter";
    private _viewProps: PlotStopViewProps;
    constructor() {
        super();
    }
    initViewProps() {
        this._viewProps = {
            unlockPlotCallbackFunc: this.unlockPlotCallbackFunc,
            onAddRes: this.onAddRes,
            onCancelAdCallback: this.onCancelAdCallback,
        }
    }
    onOpen() {
        super.onOpen(undefined);
        this.onShow();
    }
    onShow() {
        super.onShow();
        this.initViewProps();
        this._view.setProps(this._viewProps);
        this.view.adButton.loadSVConfig();
    }
    onClose() {
        super.onClose();
    }
    onEnterForeground() {
        super.onEnterForeground();
    }
    onEnterBackground() {
        super.onEnterBackground();
    }
    onHide() {
    }

    unlockPlotCallbackFunc = () => {

    }

    onCancelAdCallback(type: GetRewardType) {
        let content: string = "";
        if (type == GetRewardType.Ad) {
            content = GameModelManager.getLanguageTxt(GameTextData.GAME_TEXT_MALL_GIFT_ADFAILED_VALUE);
        } else {
            content = GameModelManager.getLanguageTxt(GameTextData.GAME_TEXT_MALL_GIFT_SHAREFAILED_VALUE);
        }
        UIManager.showToast(content);
        this.view.closeView();
    }

    onAddRes = (type: string) => {
        if (type === "video") {
            GameModelManager.dealBlockedPlot(true);
        } else {
            if (cc.sys.browserType == cc.sys.BROWSER_TYPE_CHROME) {
                GameModelManager.dealBlockedPlot(true);
            } else {
                UIManager.showToast(GameModelManager.getLanguageTxt(GameTextData.GAME_TEXT_DEAL_BLOCKED_PLOT_FAIL));
            }
        }
        this.view.closeView();
    }
}