PlotStopViewPresenter.ts
3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// 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 { CommonLocation, ShowLocationType, ShowType } from "../../Enums";
import GameDotMgr from "../../GameDotMgr";
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,
onAdBtnOption: this.onAdBtnOption,
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();
let t = this.view.getSvBtnType();
if (t && t === "share" || t === "video") {
this.onAdBtnOption(ShowType.SHOW, t);
}
}
onClose() {
super.onClose();
}
onEnterForeground() {
super.onEnterForeground();
}
onEnterBackground() {
super.onEnterBackground();
}
onHide() {
}
unlockPlotCallbackFunc = () => {
}
onAdBtnOption = (optionType: ShowType, adType: "share" | "video", ret?: boolean) => {
let location = CommonLocation.Nextplot;
if (adType === "share") {
GameDotMgr.getInstance().dotShare(optionType, ShowLocationType.Share + location);
}
if (adType === "video") {
GameDotMgr.getInstance().dotVideo(optionType, ShowLocationType.Video + location);
}
if (optionType === ShowType.FINISH && ret && adType === "video") {
// GameModelManager.addDailyTasks(DailyQuestType.Dq_AdsWatch, 1);
}
}
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();
}
}