/****************************************************************** * * BUG反馈界面 * ******************************************************************/ const BridgeWindow = require( "bridge.window" ); const RoleController = require( "role_controller" ); const RoleEvent = require( "role_event" ) const MIN_WORDS = 20; // 问题类型 const ReportTypes = { Question: 1, // 提问 Suggestion: 2, // 游戏建议 Bug: 3, // bug反馈 Append: 4, // 追问 }; cc.Class( { extends: BridgeWindow, properties: { nodName: { default: null, type: cc.Node, displayName: "被舉報的玩家名字顯示" }, edtTitle: { default: null, type: cc.EditBox }, edtDetail: { default: null, type: cc.EditBox }, nodTypes: { default: null, type: cc.Node }, nodOther: { default: null, type: cc.Node }, nodEvidence: { default: null, type: cc.Node }, }, // 显示 onEnable: function() { // this.onTogType( ReportTypes.Bug ); }, // 关闭 onDisable: function() { }, onLoad: function(){ this.bindGEvent( RoleEvent.ROLE_REPORTED_EVENT, this.freshMsgInfo.bind( this ) ); }, onOpenConfigs( _info ){ this.uid = _info.rid; let name = _info.showname; this.srv_id = _info.srv_id; let showDesc = nx.text.format( "FriendReportNUID", name, this.uid ); nx.gui.setString( this.nodName, "name", showDesc ); nx.gui.setActive( this.nodOther, "", true ); this.roleCtl = RoleController.getInstance(); if( this.roleCtl ){ this.roleCtl.send12771( this.uid, this.srv_id ); } }, showOther: function( _nod ){ // let cmp = _nod.getComponent( cc.Toggle ); // if( cmp ){ // nx.gui.setActive( this.nodOther, "", cmp.isChecked ); // } }, freshMsgInfo: function( _msg ){ nx.gui.hideAllChildren( this.nodEvidence ); if( !_msg ){ return; } let info = _msg.history; if( nx.dt.arrNEmpty( info ) ){ nx.gui.gocChildren( this.nodEvidence, "", info.length ); let chd = this.nodEvidence.children; for (let i = 0; i < chd.length; i++) { let nod = chd[i]; let data = info[i]; nx.gui.setString( nod, "tip", data.msg ); } } }, // // 类型切换 // onTogType: function( _key ) { // this.ctype = parseInt( _key ) || 1; // let chds = this.nodTypes.children; // for( let i = 0; i < chds.length; ++i ) { // let tp = chds[ i ]; // let on = ( tp.name == ( "t" + this.ctype ) ); // nx.gui.setActive( tp, "icon/on", on ); // nx.gui.setActive( tp, "icon/off", !on ); // } // }, // 点击提交 onTouchCommit: function() { let type = 0; let chd = this.nodTypes.children; for (let i = 0; i < chd.length; i++) { let nod = chd[i]; let cmp = nx.gui.getComponent( nod, "", cc.Toggle ); if( cmp ){ type = cmp.isChecked ? ( i + 1 ) : type; } } let msgcmp = nx.gui.getComponent( this.nodOther, "edt", cc.EditBox ); let msg = ""; if( msgcmp ){ msg = msgcmp.string; } let histroy = []; let evidencechd = this.nodEvidence.children; for (let i = 0; i < evidencechd.length; i++) { let nod = evidencechd[i]; let cmp = nx.gui.getComponent( nod, "", cc.Toggle ); if( cmp ){ if( cmp.isChecked ){ let data = { id : i + 1, } histroy.push( data ); } } // nx.gui.setString( nod, "tip", data.msg ); } // let title = this.edtTitle.string; // let detail = this.edtDetail.string; // if( nx.dt.strBytes( title ) < MIN_WORDS || // nx.dt.strBytes( detail ) < MIN_WORDS ) { // nx.tbox( "BugReportTooShort" ); // return; // } this.roleCtl.send12770( this.uid, this.srv_id, type, msg, histroy, ( _ret, _data ) => { if( !_ret ){ return; } this.close(); } ); }, } );