c1dcd2f0-53b5-45aa-8b5c-8f322a23573d.js
4.72 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
"use strict";
cc._RF.push(module, 'c1dcdLwU7VFqotcjzIqI1c9', 'ExchangeCodeViewPresenter');
// script/game/ui/presenter/ExchangeCodeViewPresenter.ts
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
const PresenterCCViewFactory_1 = require("../PresenterCCViewFactory");
const ExChangeCodeView_1 = require("../view/type/ExChangeCodeView");
const PresenterBase_1 = require("../../../common/classbase/PresenterBase");
const HttpRequests_1 = require("../../network/HttpRequests");
const GameModelManager_1 = require("../../model/GameModelManager");
const GameConstData_1 = require("../../../common/gameplay/gamedata/GameConstData");
const UIManager_1 = require("../../../common/gameplay/managers/UIManager");
const GameTextData_1 = require("../../../common/gameplay/gamedata/GameTextData");
let ExchangeCodeViewPresenter = /** @class */ (() => {
let ExchangeCodeViewPresenter = class ExchangeCodeViewPresenter extends PresenterBase_1.Presenter {
constructor() {
super();
this.onActionClickCallback = async (ret, cdkey) => {
if (ret) {
let ret = await HttpRequests_1.HttpRequests.exchangeCDKEY(cdkey);
console.log("current ret is" + JSON.stringify(ret));
if (ret.code === "0") {
let player = GameModelManager_1.GameModelManager.getPlayerData();
let outstr = "";
for (let i = 0; i < ret.obj.props.length; i++) {
let data = ret.obj.props[i];
let id = Number.parseInt(data.prop_id);
if (id === GameConstData_1.GameConstData.GAME_CONST_GOLD_ID_VALUE) {
player.addGoldCoin(data.count);
}
else if (id === GameConstData_1.GameConstData.GAME_CONST_CLOTH_ID_VALUE) {
player.addClothCoin(data.count);
}
else {
player.addProps(id, data.count);
}
let item = GameModelManager_1.GameModelManager.getItemConfig(id);
outstr += item.name + " x" + data.count;
if (i != ret.obj.props.length - 1) {
outstr += ",";
}
}
UIManager_1.UIManager.showToast(outstr);
}
else if (ret.code === "104001") { //错误的验证码
let content = GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.TEXT_CDKEYINVALID_VALUE);
UIManager_1.UIManager.showToast(content);
}
else if (ret.code === "104002") //已经领过了
{
let content = GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.TEXT_CDKEYHADEXCHANGED_VALUE);
UIManager_1.UIManager.showToast(content);
}
else { //其他
let content = GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.TEXT_CDKEYINVALID_VALUE);
UIManager_1.UIManager.showToast(content);
}
}
};
this._viewProps = {
titletxt: "",
contenttxt: "",
onActionClick: this.onActionClickCallback
};
}
onOpen(param) {
super.onOpen(param);
this._viewProps.titletxt = param.titletxt;
this._viewProps.contenttxt = param.contenttxt;
this._view.setProps(this._viewProps);
}
};
ExchangeCodeViewPresenter.uuid = "ExchangeCodeViewPresenter";
ExchangeCodeViewPresenter = __decorate([
PresenterCCViewFactory_1.RegPresenter(ExChangeCodeView_1.ExchangeCodeViewType)
], ExchangeCodeViewPresenter);
return ExchangeCodeViewPresenter;
})();
exports.default = ExchangeCodeViewPresenter;
cc._RF.pop();