Files
fc/dev/project/assets/Scripts/mod/partner/wings/cmp/cmp.wing.wish.wnd.js
T

200 lines
5.9 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
/******************************************************************
*
* 伙伴选择界面
*
******************************************************************/
const BridgeWindow = require( "bridge.window" );
const FxSVC = require( "nx.fx.sv.expand" );
const 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( _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() {
this.svcList.rebuild( [] );
},
// 重建
rebuild: function() {
// console.log( "可许愿列表" + JSON.stringify( this.wishLst ) );
// // 空
let 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 );
let nodes = nx.gui.find( this.svcList.bindSCV, "view/content" ).children;
let num = 0;
// 已选中
let selects = nx.dt.arrEmpty( this.params ) ? [] : [ this.params[0].lucky_sprites_bid ] ;
for( let i = 0; i < this.wishLst.length; ++i ) {
let wing = this.wishLst[ i ];
if( wing && nx.dt.arrMember( selects, null, ( _p ) => {
return _p == wing;
} ) ) {
let sitem = nodes[i];
this.svcList.addFocus( i );
if( sitem ){
let 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 );
}
}
}
}
// 数量更新
this.freshCount();
},
// 数量更新
freshCount: function() {
let key = "";
let total = this.count;
if( total > 1 ) {
let cnt = this.svcList.focusList.length;
key = `${cnt}/${total}`;
}
nx.gui.setString( this.nodCount, "", key );
},
// 选中切换
onFocusChanged: function( _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( _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 );
let ifg = gdata( "item_data","data_unit9", _info.item_id );
nx.bridge.setIcon( this.nodIcon, "icon", ifg.imageid );
let sfg = gdata( "sprite_data", "data_elfin_data", _info.item_id );
let 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() {
// {"lucky_ids":{}}
let EC = ElfinController.getInstance();
let lucky_id = 0
if( EC ){
if( nx.dt.arrEmpty( this.svcList.focusList ) ){
lucky_id = {};
nx.mbox( "WWAskConfirm", ['yes'], ( _key, _box ) => {
_box.close();
if( _key == 'yes' ) {
EC.send26554( { } );
}
} );
EC.openElfinWishTip( false );
// EC.send26554( { } );
return;
}else{
lucky_id = this.wishLst[this.svcList.focusList[0]] ;
let id = [];
id.push({ "lucky_sprites_bid": lucky_id })
EC.send26554( id );
EC.openElfinWishTip( false );
}
}
},
} );