Files
fc/dev/project/library/imports/01/01ab0f85-d953-436b-bfb7-a2c26395ba23.js
T

184 lines
4.9 KiB
JavaScript
Raw Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, '01ab0+F2VNDa7+3osJjlboj', 'cmp.act.limitedtimeoffer');
// Scripts/mod/acts/limitedtimeoffer/cmp/cmp.act.limitedtimeoffer.js
"use strict";
/******************************************************************
*
* 限時特惠
*
******************************************************************/
var ActPopup = require("act.popup.base");
var NxSpine = require("nx.fx.spine");
var Payment = require("payment.mod");
var Mod = require("act.limitedtimeoffer.mod");
var themeMod = require("acts.mod");
var FID = require("bridge.function.ids");
// const ActPage = require( "act.page.base" );
cc.Class({
"extends": ActPopup,
properties: {
nodGift: {
type: cc.Node,
"default": null
},
spRole: {
"default": null,
type: NxSpine
},
nodInfo: {
"default": null,
type: cc.Node
},
nodOp: {
"default": null,
type: cc.Node
}
},
// 初始化
onOpenConfigs: function onOpenConfigs(_params) {
var _this = this;
this._super(_params);
this.mod = Mod.getInstance();
// 无效
if (!this.mod || !this.mod.data) {
this.delayClose();
return;
}
this.spRole.load("resDB/models/H30002/show", function (_e) {
if (!_e) {
_this.spRole.action("action1", true);
} else {
_this.spRole.stop();
}
});
// 活动监听
this.mod.vbind(this, [["limitedtimeoffer", this.freshInfo.bind(this)]]);
// // 请求信息
this.mod.reqLimitedTimeOfferData();
},
// 初始化
// build: function( _data ) {
// this._super( _data );
// this.spRole.load( "resDB/models/H30002/show", ( _e ) => {
// if( !_e ) {
// this.spRole.action( "action1", true );
// } else {
// this.spRole.stop();
// }
// } );
// // 活动监听
// this.mod.vbind( this, [
// [ "limitedtimeoffer", this.freshInfo.bind( this ) ],
// ] );
// // // 请求信息
// this.mod.reqLimitedTimeOfferData();
// },
onEnable: function onEnable() {},
onDisable: function onDisable() {},
// 销毁
onDestroy: function onDestroy() {
// 活动监听解除
if (this.mod) {
this.mod.vunbind(this);
}
this._super();
},
freshInfo: function freshInfo(_data) {
var _this2 = this;
if (!_data) {
return;
}
var aim_list = _data.aim_list;
this.limitoffer = _data;
this.aims = aim_list;
var gift = aim_list[0]; // 当前为1个礼包的布局,若要增加则需要加scrollview
this.gift = gift;
if (gift) {
nx.gui.gocChildren(this.nodGift, "", gift.item_list.length);
var chd = this.nodGift.children;
for (var i = 0; i < chd.length; i++) {
var nod = chd[i];
var info = gift.item_list[i];
var cmp = nod.getComponent("cmp.item.base");
if (cmp) {
cmp.setData(info);
}
}
var limit = 0;
var nowbuy = 0;
this.paycode = 0;
var needpay = 0;
var discount = 0;
var pay = 0;
gift.aim_args.forEach(function (_arg) {
switch (_arg.aim_args_key) {
case 27:
{
pay = _arg.aim_args_val;
}
break;
case 26:
{
needpay = _arg.aim_args_val;
}
break;
case 4:
{
limit = _arg.aim_args_val;
}
break;
case 5:
{
nowbuy = _arg.aim_args_val;
}
break;
case 25:
{
discount = _arg.aim_args_val;
}
break;
case 33:
{
_this2.paycode = _arg.aim_args_val;
}
break;
}
});
var showNum = 0;
if (nowbuy == 0) {
showNum = limit;
}
nx.gui.setString(this.nodOp, "limit/count", showNum + "/" + limit);
nx.gui.setString(this.nodOp, "cost", Payment.getInstance().fmtPrice(needpay));
nx.gui.setString(this.nodOp, "buy/txt", Payment.getInstance().fmtPrice(pay));
var btn = nx.gui.getComponent(this.nodOp, "buy", cc.Button);
if (btn) {
btn.interactable = limit != nowbuy;
nx.gui.setOutlineColor(this.nodOp, "buy/txt", limit != nowbuy ? new cc.color("#b85833") : cc.Color.BLACK);
}
nx.gui.setActive(this.nodOp, "limit", false);
}
var left = _data.remain_sec > 0 ? _data.remain_sec : 0.1;
nx.gui.setCdTxt(this.nodInfo, "time", left, function () {
nx.gui.setString(_this2.nodInfo, "time", nx.text.getKey("lab_planesafk_main_have_over"));
});
},
onTouchBuy: function onTouchBuy(_btn) {
if (this.limitoffer.remain_sec == 0) {
nx.tbox("lab_recruit_hero_window_tip_6");
return;
}
if (this.gift.status != 0) {
nx.tbox("lab_ladder_main_window_tip4");
return;
}
Payment.getInstance().reqPayment(this.paycode);
}
});
cc._RF.pop();