DiscoverViewPresenter.ts
4.08 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import { SDK } from "simba-sdk";
import { GameRecord } from "../../../avg/AVG";
import { Presenter } from "../../../common/classbase/PresenterBase";
import { UIManager } from "../../../common/gameplay/managers/UIManager";
import { GameModelManager } from "../../model/GameModelManager";
import { RegPresenter } from "../PresenterCCViewFactory";
import { DiscoverView, DiscoverViewProps, DiscoverViewType } from "../view/type/DiscoverView";
import { DiscoverSettingViewPresenter } from "./discover/DiscoverSettingViewPresenter";
import { GameTextData } from "../../../common/gameplay/gamedata/GameTextData";
import { DiscoverItemType } from "../../Enums";
import QRCodeViewPresenter from "./QRCodeViewPresenter";
import GameDotMgr from "../../GameDotMgr";
import ProductionTeamViewPresenter from "./discover/ProductionTeamViewPresenter";
@RegPresenter(DiscoverViewType)
export default class DiscoverViewPresenter extends Presenter<undefined, DiscoverView> {
static uuid = "DiscoverViewPresenter";
private _viewProps: DiscoverViewProps;
static isShowRedDot() {
return false;
}
constructor() {
super();
}
initViewProps() {
this._viewProps = {
manName: "",
manId: "",
manIcon: "",
onCopyInfo: this.onCopyInfo,
onItemClick: this.itemClickCallBack
};
}
itemClickCallBack = (itemType: DiscoverItemType) => {
switch (itemType) {
case DiscoverItemType.Settings:
this.hideGameClubBtn();
UIManager.pushPresenter(DiscoverSettingViewPresenter, undefined);
break;
case DiscoverItemType.Forum:
break;
case DiscoverItemType.CustomerService:
this.hideGameClubBtn();
//点击二维码打点
GameDotMgr.getInstance().dotClickUI("CustomerService");
UIManager.pushPresenter(QRCodeViewPresenter, undefined);
break;
case DiscoverItemType.ProductionTeam:
this.hideGameClubBtn();
//点击二维码打点
UIManager.pushPresenter(ProductionTeamViewPresenter, undefined);
break;
default:
UIManager.showToast(GameModelManager.getLanguageTxt(GameTextData.GAME_TEXT_DEVELOPING_VALUE));
break;
}
}
onCopyInfo = async () => {
await SDK.setClipboardData(this._viewProps.manId);
UIManager.showToast("用户ID:" + this._viewProps.manId);
}
initItemConfig() {
this._viewProps.manName = GameRecord.globalVariables.playerName;
if (SDK.getLoginInfo()?.playerId) {
this._viewProps.manId = SDK.getLoginInfo()?.playerId as string;
}
let player = GameModelManager.getPlayerData();
this._viewProps.manName = player.getConfig().name;
this._viewProps.manIcon = player.getHeadIcon();
}
onOpen() {
super.onOpen(undefined);
this._disposable.add(GameModelManager.PlayerOptionSkin.on(this.onPlayerOptionSkin));
this._disposable.add(GameModelManager.ForceEnterDiscoverSubView.on(this.onForceEnterDiscoverSubView));
this.onShow();
}
onForceEnterDiscoverSubView = (itemType: DiscoverItemType) => {
this.itemClickCallBack(itemType);
}
onPlayerOptionSkin = () => {
this.initViewProps();
this.initItemConfig();
this._view.updateProps(this._viewProps);
}
onShow() {
super.onShow();
this.initViewProps();
this.initItemConfig();
this.view.setProps(this._viewProps);
this.view.createGameClubBtn();
this.showGameClubBtn();
}
onEnterBackground() {
super.onEnterBackground();
this.hideGameClubBtn();
}
onEnterForeground() {
super.onEnterForeground();
this.showGameClubBtn();
}
onHide() {
super.onHide();
SDK.destroyGameClubButton();
}
showGameClubBtn() {
SDK.showGameClubButton();
}
hideGameClubBtn() {
SDK.hideGameClubButton();
}
}