const RankController = require("rank_controller"); const RankConstant = require("../rank_constant"); /*** * 排行主界面每个界面ui数据显示 * */ cc.Class({ extends: cc.Component, properties: { nodBg: { default: null, type: cc.Sprite, }, // 类型 以及相关描述 ranktitle: { default: null, type: cc.Node, }, rankDesc: { default: null, type: cc.Node, }, nodGuild: { default: null, type: cc.Node, }, rankIcon: { default: null, type: cc.Node, }, firstName: { default: null, type: cc.Node, }, //公会信息 ghName: { default: null, type: cc.Node, }, informBtn: { default: null, type: cc.Button, }, fabHead: { default: null, type: cc.Prefab, } }, // 刷新基本信息 freshBase: function (_data) { if( !_data ){ return; } /**** * * {"type":4,"name":"十三水22","rid":4,"srv_id":"fx_1", * "guild_name":"溜溜联盟","face_id":24302,"avatar_bid":1000,"val1":96501,"val2":2,"val3":1500,"face_update_time":0,"face_file":""} * {"type":2,"name":"Kyofenor","rid":395,"srv_id":"fx_1", * "guild_name":"","face_id":24406,"avatar_bid":1000,"val1":20010,"val2":0,"val3":0,"face_update_time":0,"face_file":""} */ let info = _data; // if (!_data) { // return; // } this.type = info.type; let bg = null; // 不同排行榜背景板切换 bg = cc.path.join("prefab/rank/ui", "rank_" + info.type); nx.gui.setSpriteFrame(this.nodBg, "", bg); let path = ""; switch( this.type ){ case RankConstant.RankType.drama : path = "prefab/rank/ui/rank_31"; break; case RankConstant.RankType.tower : path = "prefab/rank/ui/rank_31"; break; case RankConstant.RankType.power: path = "prefab/rank/ui/rank_30"; nx.gui.setString( this.rankDesc, "type", nx.text.getKey( "RankPowerArri" ) ); break; case RankConstant.RankType.arena: path = "prefab/rank/ui/rank_30"; nx.gui.setString( this.rankDesc, "type", nx.text.getKey( "RankCupArri" ) ); path = "prefab/rank/ui/rank_29"; break; case RankConstant.RankType.union: nx.gui.setString( this.nodGuild, "name", info.guild_name ); break; } // ui显示相关 nx.gui.setSpriteFrame( this.rankDesc, "ticon", path ); nx.gui.setString( this.ranktitle, "", nx.text.getKey( "lab_rank_name_" + this.type ) ); nx.gui.setActive( this.rankDesc, "", this.type != RankConstant.RankType.union ); nx.gui.setActive( this.nodGuild, "", this.type == RankConstant.RankType.union ); nx.gui.setString( this.firstName, "", nx.dt.strEmpty( info.name ) ? nx.text.getKey( "NoRankInfo" ) : info.name ); nx.gui.setString( this.ghName, "", nx.dt.strEmpty( info.guild_name ) ? nx.text.getKey( "NoUnion" ) : info.guild_name ); // 头名 头像相关 if( info.avatar_bid > 0 ){ if( this.rankIcon ) { let node = cc.instantiate( this.fabHead ); node.parent = this.rankIcon ; this.cmpHead = node.getComponent( "cmp.common.header" ); } let cfg = game.configs.avatar_data.data_avatar[ info.avatar_bid ]; let frame = cfg ? cfg.base_id : 0; // 更新 this.cmpHead.setHeadRes( info.face_id ); this.cmpHead.setFrameRes( frame ); } // 设置各个排行榜到达信息 let desc = ""; if( this.type == RankConstant.RankType.drama ){ let infos = gdata( "dungeon_data", "data_drama_dungeon_info", [ info.val1 || 0 ] ); if( infos ){ desc = infos.name; }else{ desc = nx.text.getKey( "RankNoDrama" ); } }else{ if( this.type == RankConstant.RankType.tower ){ desc = nx.text.format( "RankArriInfo", info.val1 ); }else{ desc = info.val1; } } nx.gui.setString( this.rankDesc, "itemdesc", desc ); }, detailInform: function () { const model = RankController.getInstance(); const lst = model.getFirstRankList(); if(!lst){ return; } // console.log("当前的类型" + this.type + "curter" + lst.is_cluster); model.openRankDetail( this.type, 0 ,lst.is_cluster); } });