110 lines
2.8 KiB
JavaScript
110 lines
2.8 KiB
JavaScript
/******************************************************************
|
|
*
|
|
* 礼包选择界面
|
|
*
|
|
******************************************************************/
|
|
|
|
const BridgeWindow = require("bridge.window");
|
|
const FxSVC = require("nx.fx.sv.expand");
|
|
const BackPackController = require("backpack_controller");
|
|
|
|
cc.Class({
|
|
|
|
extends: BridgeWindow,
|
|
|
|
properties: {
|
|
|
|
svcList: {
|
|
default: null,
|
|
type: FxSVC,
|
|
},
|
|
|
|
},
|
|
|
|
// 重载:参数打开
|
|
onOpenConfigs: function (_params) {
|
|
|
|
this.item = _params;
|
|
|
|
// 拆包
|
|
let gifts = [];
|
|
let inside = game.configs.gift_data.data_choose_gift[this.item.base_id];
|
|
if (inside) {
|
|
|
|
// 单选多选(暂留)
|
|
|
|
for (let i in inside) {
|
|
let 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 (_items) {
|
|
|
|
this.giftList = _items || [];
|
|
nx.gui.setActive(this.svcList, "empty", nx.dt.arrEmpty(this.giftList));
|
|
this.svcList.rebuild(this.giftList);
|
|
|
|
// 设置默认
|
|
this.scheduleOnce(() => {
|
|
this.svcList.cleanFocus();
|
|
this.svcList.addFocus(0);
|
|
}, 0.05);
|
|
},
|
|
|
|
// 选中切换
|
|
onFocusChanged: function (_item) {
|
|
|
|
// 空
|
|
if (nx.dt.objEmpty(_item) ||
|
|
nx.dt.objEmpty(_item.mdata)) {
|
|
return;
|
|
}
|
|
|
|
// 聚焦
|
|
this.svcList.cleanFocus();
|
|
this.svcList.addFocus(_item.index);
|
|
|
|
},
|
|
|
|
// 点击确认
|
|
onTouchConfirm: function () {
|
|
|
|
// console.log(JSON.stringify(this.giftList) + "当前的礼包信息" + JSON.stringify(this.item));
|
|
let arg = [];
|
|
this.giftid;
|
|
let quantity = 1;
|
|
for (let 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: "" });
|
|
let sort_id = -1;
|
|
sort_id = this.giftList[this.giftid].sort_id;
|
|
if (sort_id >= 0) {
|
|
arg.push({ name: 2, value: sort_id, str: "" })
|
|
}
|
|
}
|
|
}
|
|
|
|
let BagC = BackPackController.getInstance();
|
|
BagC.sender10515(this.item.id, quantity, arg);
|
|
this.close();
|
|
// BackPackController.getInstance().closeGiftSelectPanel();
|
|
},
|
|
|
|
// // 点击关闭
|
|
// onTouchClose: function () {
|
|
// BackPackController.getInstance().closeGiftSelectPanel();
|
|
// },
|
|
|
|
});
|