Files

112 lines
2.8 KiB
JavaScript
Raw Permalink Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, '9a0ady7wFZIbbZwfZEIi4Sj', 'cmp.bag.gift.choose.wnd');
// Scripts/mod/backpack/cmps/cmp.bag.gift.choose.wnd.js
"use strict";
/******************************************************************
*
* 礼包选择界面
*
******************************************************************/
var BridgeWindow = require("bridge.window");
var FxSVC = require("nx.fx.sv.expand");
var BackPackController = require("backpack_controller");
cc.Class({
"extends": BridgeWindow,
properties: {
svcList: {
"default": null,
type: FxSVC
}
},
// 重载:参数打开
onOpenConfigs: function onOpenConfigs(_params) {
this.item = _params;
// 拆包
var gifts = [];
var inside = game.configs.gift_data.data_choose_gift[this.item.base_id];
if (inside) {
// 单选多选(暂留)
for (var i in inside) {
var t = inside[i];
if (t && nx.dt.numPositive(t.bid, false)) {
gifts.push({
id: t.bid,
num: t.num,
sort_id: t.sort_id
});
}
}
}
// 重建
gifts.sort(Utils.tableLowerSorter(["sort_id"]));
this.rebuild(gifts);
},
// 重建
rebuild: function rebuild(_items) {
var _this = this;
this.giftList = _items || [];
nx.gui.setActive(this.svcList, "empty", nx.dt.arrEmpty(this.giftList));
this.svcList.rebuild(this.giftList);
// 设置默认
this.scheduleOnce(function () {
_this.svcList.cleanFocus();
_this.svcList.addFocus(0);
}, 0.05);
},
// 选中切换
onFocusChanged: function onFocusChanged(_item) {
// 空
if (nx.dt.objEmpty(_item) || nx.dt.objEmpty(_item.mdata)) {
return;
}
// 聚焦
this.svcList.cleanFocus();
this.svcList.addFocus(_item.index);
},
// 点击确认
onTouchConfirm: function onTouchConfirm() {
// console.log(JSON.stringify(this.giftList) + "当前的礼包信息" + JSON.stringify(this.item));
var arg = [];
this.giftid;
var quantity = 1;
for (var index = 0; index < this.giftList.length; index++) {
//获取当前选中的礼包id
if (this.svcList.isFocus(index)) {
this.giftid = index;
arg.push({
name: 1,
value: this.giftList[this.giftid].id,
str: ""
});
var sort_id = -1;
sort_id = this.giftList[this.giftid].sort_id;
if (sort_id >= 0) {
arg.push({
name: 2,
value: sort_id,
str: ""
});
}
}
}
var BagC = BackPackController.getInstance();
BagC.sender10515(this.item.id, quantity, arg);
this.close();
// BackPackController.getInstance().closeGiftSelectPanel();
}
// // 点击关闭
// onTouchClose: function () {
// BackPackController.getInstance().closeGiftSelectPanel();
// },
});
cc._RF.pop();