167 lines
5.2 KiB
JavaScript
167 lines
5.2 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '2544dCShyBHQppyymZJwh5F', 'cmp.act.exclusive.wnd');
|
|
// Scripts/mod/acts/exclusive/cmp/cmp.act.exclusive.wnd.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 新服专享
|
|
*
|
|
******************************************************************/
|
|
var ActPage = require("act.page.base");
|
|
var Mod = require("act.exclusive.mod");
|
|
var NxSpine = require("nx.fx.spine");
|
|
var Payment = require("payment.mod");
|
|
var themeMod = require("acts.mod");
|
|
var max = 4;
|
|
var FID = require("bridge.function.ids");
|
|
cc.Class({
|
|
"extends": ActPage,
|
|
properties: {
|
|
nodGift: {
|
|
type: cc.Node,
|
|
"default": null
|
|
},
|
|
spRole: {
|
|
"default": null,
|
|
type: NxSpine
|
|
},
|
|
nodEndTime: {
|
|
"default": null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
// 初始化
|
|
build: function build(_data) {
|
|
var _this = this;
|
|
this._super(_data);
|
|
// 无效
|
|
|
|
this.spRole.load("resDB/models/H30021/show", function (_e) {
|
|
if (!_e) {
|
|
_this.spRole.action("drama1", true);
|
|
} else {
|
|
_this.spRole.stop();
|
|
}
|
|
});
|
|
|
|
// 活动监听
|
|
this.mod.vbind(this, [["exclusive", this.freshGift.bind(this)]]);
|
|
},
|
|
onEnable: function onEnable() {
|
|
// 请求信息
|
|
this.mod.reqExclusiveData();
|
|
},
|
|
// 销毁
|
|
onDestroy: function onDestroy() {
|
|
// 活动监听解除
|
|
if (this.mod) {
|
|
this.mod.vunbind(this);
|
|
}
|
|
this._super();
|
|
},
|
|
freshGift: function freshGift(_data) {
|
|
var _this2 = this;
|
|
this.exclusive = _data;
|
|
if (!this.exclusive) {
|
|
return;
|
|
}
|
|
this.cost = [];
|
|
var left = this.exclusive.remain_sec != 0 ? this.exclusive.remain_sec : 0.1;
|
|
nx.gui.setCdTxt(this.nodEndTime, "txt", left, function () {
|
|
nx.gui.setString(_this2.nodEndTime, "txt", nx.text.getKey("lab_planesafk_main_have_over"));
|
|
});
|
|
this.gifts = this.exclusive.aim_list;
|
|
var _loop = function _loop() {
|
|
var gift = _this2.gifts[g];
|
|
var giftCost = gift.aim_args;
|
|
giftCost.forEach(function (_arg) {
|
|
if (_arg.aim_args_key == 39) {
|
|
gift.sortid = _arg.aim_args_val;
|
|
}
|
|
});
|
|
};
|
|
for (var g = 0; g < this.gifts.length; g++) {
|
|
_loop();
|
|
}
|
|
this.gifts.sort(Utils.tableLowerSorter(["sortid"]));
|
|
nx.gui.gocChildren(this.nodGift, "view/content", this.gifts.length);
|
|
var chd = nx.gui.find(this.nodGift, "view/content").children;
|
|
var _loop2 = function _loop2() {
|
|
var nod = chd[i];
|
|
var giftInfo = _this2.gifts[i];
|
|
if (giftInfo) {
|
|
var giftCost = giftInfo.aim_args;
|
|
var num = giftInfo.status;
|
|
var price = 0;
|
|
var disPrice = 0;
|
|
giftCost.forEach(function (_arg) {
|
|
if (_arg.aim_args_key == 2 && _arg.aim_args_val != 0) {
|
|
var showNum = num == 0 ? num : num <= _arg.aim_args_val && num != 0 ? num : _arg.aim_args_val;
|
|
nx.gui.setString(nod, "limit", nx.text.format("BuyLimit", showNum, _arg.aim_args_val));
|
|
}
|
|
if (_arg.aim_args_key == 26) {
|
|
price = _arg.aim_args_val;
|
|
}
|
|
if (_arg.aim_args_key == 27 && _arg.aim_args_val != price && price != 0) {
|
|
disPrice = _arg.aim_args_val;
|
|
}
|
|
});
|
|
nx.gui.setActive(nod, "op/tip", false);
|
|
_this2.cost.push(price);
|
|
nx.gui.setString(nod, "title", giftInfo.aim_str);
|
|
var btn = nx.gui.getComponent(nod, "op", cc.Button);
|
|
if (btn) {
|
|
btn.interactable = price != 0 ? giftInfo.status == 0 : giftInfo.status == 1;
|
|
if (price != 0) {
|
|
nx.gui.setOutlineColor(nod, "op/num", giftInfo.status == 0 ? new cc.color("#B85833") : cc.Color.BLACK);
|
|
} else {
|
|
nx.gui.setActive(nod, "op/tip", disPrice == 0 && giftInfo.status == 1);
|
|
nx.gui.setOutlineColor(nod, "op/num", giftInfo.status == 1 ? new cc.color("#B85833") : cc.Color.BLACK);
|
|
}
|
|
}
|
|
var path = i < max ? "prefab/acts/exclusive/ui/zhuanxiang_0" + (4 + i) : "prefab/acts/exclusive/ui/zhuanxiang_08";
|
|
nx.gui.setSpriteFrame(nod, "icon", path);
|
|
var cmp = nx.gui.getComponent(nod, "list", "cmp.common.itemlayout");
|
|
if (cmp) {
|
|
cmp.rebuild(giftInfo.item_list);
|
|
}
|
|
nod.zIndex = i;
|
|
nx.gui.setString(nod, "op/num", price == 0 ? nx.text.getKey("Free") : Payment.getInstance().fmtPrice(price));
|
|
}
|
|
};
|
|
for (var i = 0; i < chd.length; i++) {
|
|
_loop2();
|
|
}
|
|
},
|
|
onTouchBuy: function onTouchBuy(_btn) {
|
|
if (this.exclusive.remain_sec == 0) {
|
|
nx.tbox("lab_recruit_hero_window_tip_6");
|
|
return;
|
|
}
|
|
var number = _btn.parent.zIndex;
|
|
var aim = this.gifts[number].aim;
|
|
if (this.gifts[number].status != 0 && this.cost[number] != 0) {
|
|
nx.tbox("lab_ladder_main_window_tip4");
|
|
return;
|
|
}
|
|
if (this.cost[number] == 0) {
|
|
this.mod.reqExclusiveGift(aim);
|
|
return;
|
|
}
|
|
Payment.getInstance().reqPayment(aim);
|
|
|
|
// this.mod.reqExclusiveGift( this.exclusive.bid, aim );
|
|
}
|
|
|
|
// close: function(){
|
|
|
|
// let theme = themeMod.getInstance().queryTheme( this.mod.data.theme_id );
|
|
|
|
// nx.bridge.jumper.jump2Window( FID.ActOpenServer, theme );
|
|
// this._super();
|
|
// },
|
|
});
|
|
|
|
cc._RF.pop(); |