185 lines
5.3 KiB
JavaScript
185 lines
5.3 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '1bc99roHmNMCaxFnt9I9mvI', 'cmp.wing.wish.wnd');
|
|
// Scripts/mod/partner/wings/cmp/cmp.wing.wish.wnd.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 伙伴选择界面
|
|
*
|
|
******************************************************************/
|
|
|
|
var BridgeWindow = require("bridge.window");
|
|
var FxSVC = require("nx.fx.sv.expand");
|
|
var ElfinController = require("elfin_controller");
|
|
cc.Class({
|
|
"extends": BridgeWindow,
|
|
properties: {
|
|
nodRoot: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
svcList: {
|
|
"default": null,
|
|
type: FxSVC
|
|
},
|
|
nodCount: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodIcon: {
|
|
"default": null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
// 重载:参数打开
|
|
onOpenConfigs: function onOpenConfigs(_params) {
|
|
/**
|
|
* params {
|
|
* partners: 列表,
|
|
* count: 选择上限,
|
|
* selects: 已选择,
|
|
* fnSelector: 选择验证(默认空)
|
|
* fixed: 是否固定选择上限数(默认false)
|
|
* flag: 特殊标记 }
|
|
*/
|
|
// console.log( "当前的数据格式" + JSON.stringify( _params ) );
|
|
// 参数判定
|
|
this.count = _params.count;
|
|
this.params = _params.selects;
|
|
this.cb = _params.cb || [];
|
|
this.wishLst = _params.wishLst;
|
|
this.wing = -1;
|
|
// 重建
|
|
this.rebuild();
|
|
},
|
|
// 重载:关闭前
|
|
onPreClosed: function onPreClosed() {
|
|
this.svcList.rebuild([]);
|
|
},
|
|
// 重建
|
|
rebuild: function rebuild() {
|
|
var _this = this;
|
|
// console.log( "可许愿列表" + JSON.stringify( this.wishLst ) );
|
|
// // 空
|
|
var empty = nx.dt.arrEmpty(this.wishLst);
|
|
nx.gui.setActive(this.nodRoot, "empty", empty);
|
|
nx.gui.setActive(this.nodRoot, "panel", !empty);
|
|
if (empty) {
|
|
return;
|
|
}
|
|
nx.gui.setActive(this, "panel/panel/desc", false);
|
|
// // 重建
|
|
this.svcList.rebuild(this.wishLst);
|
|
var nodes = nx.gui.find(this.svcList.bindSCV, "view/content").children;
|
|
var num = 0;
|
|
// 已选中
|
|
var selects = nx.dt.arrEmpty(this.params) ? [] : [this.params[0].lucky_sprites_bid];
|
|
var _loop = function _loop() {
|
|
var wing = _this.wishLst[i];
|
|
if (wing && nx.dt.arrMember(selects, null, function (_p) {
|
|
return _p == wing;
|
|
})) {
|
|
var sitem = nodes[i];
|
|
_this.svcList.addFocus(i);
|
|
if (sitem) {
|
|
var cmp = sitem.svItem;
|
|
// console.log( defaultSchemeInfo[0].item_bid + "当前的方案处理www" + Object.keys( sitem ) );
|
|
if (cmp) {
|
|
// console.log( defaultSchemeInfo[0].item_bid + "当前的方案处理www" + JSON.stringify( cmp.mdata ) );
|
|
_this.onFocusChanged(cmp);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
for (var i = 0; i < this.wishLst.length; ++i) {
|
|
_loop();
|
|
}
|
|
// 数量更新
|
|
this.freshCount();
|
|
},
|
|
// 数量更新
|
|
freshCount: function freshCount() {
|
|
var key = "";
|
|
var total = this.count;
|
|
if (total > 1) {
|
|
var cnt = this.svcList.focusList.length;
|
|
key = cnt + "/" + total;
|
|
}
|
|
nx.gui.setString(this.nodCount, "", key);
|
|
},
|
|
// 选中切换
|
|
onFocusChanged: function onFocusChanged(_item) {
|
|
// console.log( nx.dt.objEmpty( _item ) + "当前点击" + JSON.stringify( _item.info ) );
|
|
|
|
this.svcList.cleanFocus();
|
|
if (nx.dt.arrMember(this.selects, _item.mdata)) {
|
|
this.svcList.addFocus(_item.index);
|
|
this.wing = _item.index;
|
|
this.freshCount();
|
|
this.freshIcon(_item.info);
|
|
} else {
|
|
if (this.wing == _item.index) {
|
|
// console.log( "选中取消");
|
|
this.svcList.removeFocus(_item.index);
|
|
this.wing = -1;
|
|
this.freshCount();
|
|
this.freshIcon([]);
|
|
} else {
|
|
this.svcList.addFocus(_item.index);
|
|
this.wing = _item.index;
|
|
this.freshCount();
|
|
this.freshIcon(_item.info);
|
|
}
|
|
}
|
|
},
|
|
freshIcon: function freshIcon(_info) {
|
|
if (nx.dt.arrEmpty(_info) && !nx.dt.objGood(_info)) {
|
|
nx.gui.setString(this.nodIcon, "titlebg/txt", "");
|
|
nx.gui.setSpriteFrame(this.nodIcon, "icon", "");
|
|
nx.gui.setActive(this, "panel/panel/desc", false);
|
|
return;
|
|
}
|
|
nx.gui.setString(this.nodIcon, "titlebg/txt", _info.name);
|
|
var ifg = gdata("item_data", "data_unit9", _info.item_id);
|
|
nx.bridge.setIcon(this.nodIcon, "icon", ifg.imageid);
|
|
var sfg = gdata("sprite_data", "data_elfin_data", _info.item_id);
|
|
var cmp = nx.gui.getComponent(this, "panel/panel/desc/skill", "cmp.skill.base");
|
|
if (cmp) {
|
|
cmp.setData(sfg.skill);
|
|
}
|
|
nx.gui.setActive(this, "panel/panel/desc", true);
|
|
},
|
|
// 点击确认
|
|
onTouchConfirm: function onTouchConfirm() {
|
|
// {"lucky_ids":{}}
|
|
var EC = ElfinController.getInstance();
|
|
var lucky_id = 0;
|
|
if (EC) {
|
|
if (nx.dt.arrEmpty(this.svcList.focusList)) {
|
|
lucky_id = {};
|
|
nx.mbox("WWAskConfirm", ['yes'], function (_key, _box) {
|
|
_box.close();
|
|
if (_key == 'yes') {
|
|
EC.send26554({});
|
|
}
|
|
});
|
|
EC.openElfinWishTip(false);
|
|
// EC.send26554( { } );
|
|
|
|
return;
|
|
} else {
|
|
lucky_id = this.wishLst[this.svcList.focusList[0]];
|
|
var id = [];
|
|
id.push({
|
|
"lucky_sprites_bid": lucky_id
|
|
});
|
|
EC.send26554(id);
|
|
EC.openElfinWishTip(false);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |