211 lines
4.9 KiB
JavaScript
211 lines
4.9 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, '857c1YV0+VDAIRFfAKd0aZ+', 'cmp.item.detail.ops');
|
||
|
|
// Scripts/mod/backpack/cmps/cmp.item.detail.ops.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
var BackPackConst = require("backpack_const");
|
||
|
|
var BackpackController = require("backpack_controller");
|
||
|
|
var BagWnd = require("cmp.bag.wnd");
|
||
|
|
var FID = require("bridge.function.ids");
|
||
|
|
var BBT = BackPackConst.tips_btn_type;
|
||
|
|
cc.Class({
|
||
|
|
"extends": cc.Component,
|
||
|
|
properties: {
|
||
|
|
nodOps: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node,
|
||
|
|
displayName: "操作栏"
|
||
|
|
},
|
||
|
|
wndBag: {
|
||
|
|
"default": null,
|
||
|
|
type: BagWnd,
|
||
|
|
displayName: "归属窗体"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 载入
|
||
|
|
onLoad: function onLoad() {
|
||
|
|
this.BC = BackpackController.getInstance();
|
||
|
|
this.setEmpty();
|
||
|
|
},
|
||
|
|
// 置空
|
||
|
|
setEmpty: function setEmpty() {
|
||
|
|
// 操作全隐藏
|
||
|
|
nx.gui.hideAllChildren(this.nodOps, "");
|
||
|
|
this.opCount = 0;
|
||
|
|
},
|
||
|
|
// 设置道具
|
||
|
|
// @ 返回true:需要显示
|
||
|
|
setData: function setData(_item, _config, _fromBag) {
|
||
|
|
// 全隐藏
|
||
|
|
if (!_item || !_config) {
|
||
|
|
this.setEmpty();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 获取配置
|
||
|
|
this.item = _item;
|
||
|
|
this.config = _config;
|
||
|
|
|
||
|
|
// 道具操作选项
|
||
|
|
var ops = _config.tips_btn;
|
||
|
|
if (nx.dt.arrEmpty(ops)) {
|
||
|
|
this.setEmpty();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 列表创建
|
||
|
|
var chds = this.nodOps.children;
|
||
|
|
nx.gui.gocChildren(this.nodOps, "", ops.length, chds[0]);
|
||
|
|
for (var i = 0; i < ops.length; ++i) {
|
||
|
|
var btn = chds[i];
|
||
|
|
btn.op = ops[i];
|
||
|
|
var txt = nx.text.getKey("ItemOp" + btn.op[0]);
|
||
|
|
nx.gui.setString(btn, "on/txt", txt);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 按钮数保存
|
||
|
|
this.opCount = ops.length;
|
||
|
|
|
||
|
|
// 居中特殊操作
|
||
|
|
this.node.width = this.opCount == 1 ? 120 : 266;
|
||
|
|
return true;
|
||
|
|
},
|
||
|
|
// 点击
|
||
|
|
onTouchButton: function onTouchButton(_btn) {
|
||
|
|
// 无效道具
|
||
|
|
if (nx.dt.objEmpty(this.item)) {
|
||
|
|
nx.error("[ItemOP]无效道具!");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 道具操作跳转
|
||
|
|
this.doOp(_btn.op);
|
||
|
|
},
|
||
|
|
// 操作处理
|
||
|
|
doOp: function doOp(_op) {
|
||
|
|
if (nx.dt.arrEmpty(_op)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
nx.debug("[OPS] %s, %s", _op[0], _op[1]);
|
||
|
|
|
||
|
|
// 第二参数:如果为sourceId(<10000),则直接统一进行功能跳转
|
||
|
|
// 比如:[1,245]
|
||
|
|
var OTS = BackPackConst.ItemOpSubType;
|
||
|
|
if (nx.dt.numPositive(_op[1], false) && _op[1] < OTS.Begin) {
|
||
|
|
nx.bridge.jumper.jump2Window(_op[1]);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 第二参数:如果为道具操作特殊子类型(>10000),则直接使用
|
||
|
|
// 比如:[1,10101]
|
||
|
|
if (nx.dt.numPositive(_op[1], false) && _op[1] > OTS.Begin) {
|
||
|
|
if (_op[1] == 10104) {
|
||
|
|
//自選禮包多種類批量操作
|
||
|
|
nx.bridge.jumper.jumpOpItem(BBT.SectMoreUse, {
|
||
|
|
config: this.config,
|
||
|
|
item: this.item
|
||
|
|
});
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
nx.bridge.jumper.jumpOpItem(BBT.goods_use, {
|
||
|
|
config: this.config,
|
||
|
|
item: this.item
|
||
|
|
});
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 否则为特殊子类型,区别处理
|
||
|
|
var OT = BackPackConst.ItemOps;
|
||
|
|
switch (_op[0]) {
|
||
|
|
// 使用
|
||
|
|
case OT.Use:
|
||
|
|
{}
|
||
|
|
break;
|
||
|
|
// 合成
|
||
|
|
case OT.Compound:
|
||
|
|
{
|
||
|
|
nx.bridge.jumper.jumpOpItem(BBT.hecheng, {
|
||
|
|
config: this.config,
|
||
|
|
item: this.item
|
||
|
|
});
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
// 出售
|
||
|
|
case OT.Sell:
|
||
|
|
{
|
||
|
|
nx.bridge.jumper.jumpOpItem(BBT.item_sell, {
|
||
|
|
config: this.config,
|
||
|
|
item: this.item
|
||
|
|
});
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
// 重铸
|
||
|
|
case OT.Recast:
|
||
|
|
{
|
||
|
|
nx.bridge.jumper.jump2Window(FID.ArtifactReset, {
|
||
|
|
item: this.item,
|
||
|
|
config: this.config
|
||
|
|
});
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
// 分解
|
||
|
|
case OT.Resolve:
|
||
|
|
{
|
||
|
|
nx.bridge.jumper.jumpOpItem(BBT.RuneSell, {
|
||
|
|
config: this.config,
|
||
|
|
item: this.item
|
||
|
|
});
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
// 穿戴
|
||
|
|
case OT.Equip:
|
||
|
|
{
|
||
|
|
nx.bridge.jumper.jumpOpItem(BBT.RuneEquip, {
|
||
|
|
config: this.config,
|
||
|
|
item: this.item
|
||
|
|
});
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
// 详情
|
||
|
|
case OT.Detail:
|
||
|
|
{}
|
||
|
|
break;
|
||
|
|
// 查看
|
||
|
|
case OT.Lookup:
|
||
|
|
{
|
||
|
|
nx.bridge.jumper.jumpOpItem(BBT.JumpToSingleHero, {
|
||
|
|
item: this.item,
|
||
|
|
config: this.config
|
||
|
|
});
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
// 查看
|
||
|
|
case OT.Refine:
|
||
|
|
{
|
||
|
|
nx.bridge.jumper.jumpOpItem(BBT.GodEquipmentReMake, {
|
||
|
|
config: this.item,
|
||
|
|
item: 0
|
||
|
|
});
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
// 皮肤合成
|
||
|
|
case OT.SkinCompound:
|
||
|
|
{
|
||
|
|
nx.bridge.jumper.jumpOpItem(BBT.SkinCompound, {
|
||
|
|
item: this.item,
|
||
|
|
config: this.config
|
||
|
|
});
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
// nx.bridge.jumper.jumpOpItem( _op, {
|
||
|
|
// config: this.config,
|
||
|
|
// item: this.item
|
||
|
|
// } );
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|