| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- cc.Class({
- extends: cc.BaseClass,
- properties: {
- m_HeadNode:cc.Node,
- m_HeadErr:cc.Node,
- m_SpGender:[cc.Sprite],
- m_LabNick:cc.Label,
- m_LabID:cc.Label,
- m_BtKick:cc.Button,
- m_SpGenderstr:cc.Label,
- m_adressStr: cc.Label,
- m_winRateStr: cc.Label,
- m_shootRateStr: cc.Label,
- m_pairingRateStr: cc.Label,
- },
- ctor: function(){
- this.m_bForceUpdare = true;
-
- },
- onLoad:function() {
- },
- InitPre:function(){
- this.SetUserByID(0);
- },
- SetPreInfo:function(ParaArr){
- this.SetUserByID(ParaArr);
- },
- SetUserByGameID :function(GameID, bForceUpdare) {
- this.m_bForceUpdare = bForceUpdare;
- this.InitUser();
- if(GameID == null || GameID == 0) return;
- this.m_CheckGameID = GameID;
- this.m_CheckUserID = null;
- this.m_CheckCnt = 0;
- },
- SetUserByID :function(UserID, bForceUpdare) {
- this.m_bForceUpdare = bForceUpdare;
- this.InitUser();
- if(UserID == null || UserID == 0) return;
- this.m_CheckUserID = UserID;
- this.m_CheckGameID = null;
- this.m_CheckCnt = 0;
- },
- GetUserID:function(){ return this.m_UserID;},
- InitUser:function(){
- this.m_UserID = 0;
- this.m_bShowFullID = true;
- this.m_bShowFullName = true;
- this.m_LenName = 6;
- // if(this.m_LabNick) this.m_LabNick.string = '使用者暱稱';
- // if(this.m_LabID) this.m_LabID.string = '使用者ID';
- if(this.m_HeadCtrl) {
- this.m_HeadCtrl.SetHook(this);
- this.m_HeadCtrl.SetUserHead();
- }
- if(this.m_HeadErr) this.m_HeadErr.active = false;
- if(this.m_BtKick) this.m_BtKick.node.active = false;
- this.SetShowFullIDWithClubRule();
- },
- OnClicked_Kick: function() {
- cc.gSoundRes.PlaySound('Button');
- if(this.m_Hook && this.m_Hook.OnUserCtrlCallback_Kick) this.m_Hook.OnUserCtrlCallback_Kick(this);
- },
- OnHeadErr:function(){
- if(this.m_HeadErr) this.m_HeadErr.active = true;
- },
- SetShowFullID:function(bShow){
- this.m_bFulShowlID=bShow;
- if(this.m_LabID && !this.m_bShowFullID) {
- var temp = (this.m_LabID.string+"").split('');
- temp[2] = '*'
- temp[3] = '*'
- this.m_LabID.string = temp.join('');
-
- }
- },
- SetShowFullIDWithClubRule:function(){
- if(g_ServerListDataLast == null || ShowLobbyClub == 0) return;
- var ClubRule = g_GlobalClubInfo.onGetClubRules(ShowLobbyClub);
- if((ClubRule & 0x01)>0){
- this.SetShowFullID(false);
- }
- },
- SetShowFullName:function(bShow, Len){
- this.m_bShowFullName=bShow;
- if(Len) this.m_LenName = Len;
- if(this.m_LabNick && !this.m_bShowFullName) {
- var temp = this.m_LabNick.string;
- this.m_LabNick.string = cutstr(temp, this.m_LenName);
- }
- },
- SetUserInfo :function(UserID, Info) {
- console.log("SetUserInfo",UserID, Info);
- //未加载成功
- if(Info == null || Info == 'Loading') return;
- //设置信息
- this.m_UserID = UserID;
- this.m_CheckUserID = null;
- this.m_CheckGameID = null;
- // for(var i in this.m_SpGender) {
- // if(!this.m_SpGender[i]) continue;
- // this.m_SpGender[i].node.active = (i == Info.Gender);
- // }
-
- if(this.m_LabNick && Info.NickName != null){
- this.m_LabNick.string = this.m_bShowFullName?Info.NickName:cutstr(Info.NickName, this.m_LenName);
- }
-
- // if(this.m_LabID && Info.GameID != null){
- // this.m_LabID.string = Info.GameID;
- // if(!this.m_bShowFullID) {
- // var temp = (this.m_LabID.string+"").split(''); //ID显示
- // temp[2] = '*';
- // temp[3] = '*';
- // this.m_LabID.string = temp.join('');
- // }
- // }
- if(this.m_SpGenderstr && Info.Gender != null){
- this.m_SpGenderstr.string = Info.Gender ==0?"女":"男";
- }
- if(this.m_LabID && UserID != null){
- this.m_LabID.string = UserID;
- if(!this.m_bShowFullID) {
- var temp = (this.m_LabID.string+"").split(''); //ID显示
- temp[2] = '*';
- temp[3] = '*';
- this.m_LabID.string = temp.join('');
-
- }
- }
- if(this.m_HeadNode && this.m_HeadCtrl == null) this.m_HeadCtrl = this.m_HeadNode.getComponent('HeadPrefab');
- if(this.m_HeadCtrl) this.m_HeadCtrl.SetUserHead(UserID, this.m_bForceUpdare);
- if(this.m_BtKick) this.m_BtKick.node.active = true;
- if (this.m_adressStr) {
- let isShow = !!Info.Adress;
- this.m_adressStr.node.parent.active = isShow;
- if (isShow) {
- this.m_adressStr.string = `${Info.Adress}`;
- }
- }
- if (this.m_winRateStr) {
- let isShow = !!Info.WinRate;
- this.m_winRateStr.node.parent.active = isShow;
- if (isShow) {
- this.m_winRateStr.string = `${Info.WinRate}%`;
- }
- }
- if (this.m_shootRateStr) {
- let isShow = !!Info.ShootRate;
- this.m_shootRateStr.node.parent.active = isShow;
- if (isShow) {
- this.m_shootRateStr.string = `${Info.ShootRate}%`;
- }
- }
- if (this.m_pairingRateStr) {
- let isShow = !!Info.PairingRate;
- this.m_pairingRateStr.node.parent.active = isShow;
- if (isShow) {
- this.m_pairingRateStr.string = `${Info.PairingRate}%`;
- }
- }
- },
- update:function() {
- if(this.m_CheckUserID == null && this.m_CheckGameID == null) return;
- if(this.m_CheckUserID) this.GetUserInfo(this.m_CheckUserID);
- if(this.m_CheckGameID) this.GetUserInfo2(this.m_CheckGameID);
-
- },
- GetUserInfo:function(UserID){
- //等待其他控件加载结果
- if ( g_GlobalUserInfo.m_UserInfoMap[UserID] == 'Loading') return;
- //首次加载
- // if(this.m_bForceUpdare || g_GlobalUserInfo.m_UserInfoMap[UserID] == null){
- // this.LoadUserInfo(UserID);
- // }else {
- // this.SetUserInfo(UserID, g_GlobalUserInfo.m_UserInfoMap[UserID]);
- // }
- this.LoadUserInfo(UserID);
-
- },
- LoadUserInfo:function(UserID, bReload){
- g_GlobalUserInfo.m_UserInfoMap[UserID] = 'Loading';
- var webUrl = window.PHP_HOME+'/UserFunc.php?GetMark=12&dwUserID='+UserID;
- WebCenter.GetData(webUrl, null, function (data) {
- var UserInfo = JSON.parse(data);
- if (UserInfo.UserID == null) {
- if(bReload == null) this.LoadUserInfo(UserID, true);
- else this.m_CheckUserID = null;
- }else{
- g_GlobalUserInfo.SetUserInfo(UserID,UserInfo.NickName,UserInfo.GameID,UserInfo.HeadUrl,UserInfo.Gender);
- if(this.m_CheckUserID == UserID) this.SetUserInfo(UserID, g_GlobalUserInfo.m_UserInfoMap[UserID]);
-
- }
- }.bind(this));
- },
- GetUserInfo2:function(GameID, bReload){
- //等待其他控件加载结果
- if( g_GlobalUserInfo.m_UserGameIDMap[GameID] == 'Loading') return;
- if(g_GlobalUserInfo.m_UserGameIDMap[GameID] == null){
- this.LoadUserInfo2(GameID);
- }else{
- var UserID = g_GlobalUserInfo.m_UserGameIDMap[GameID];
- this.SetUserInfo(UserID, g_GlobalUserInfo.m_UserInfoMap[UserID]);
-
- }
- },
- LoadUserInfo2:function(GameID, bReload){
- g_GlobalUserInfo.m_UserGameIDMap[GameID] = 'Loading';
- var webUrl = window.PHP_HOME+'/UserFunc.php?GetMark=13&dwGameID='+GameID;
- WebCenter.GetData(webUrl, null, function (data) {
- var UserInfo = JSON.parse(data);
- if(UserInfo.UserID == null){
- if(bReload == null) this.LoadUserInfo2(GameID, true);
- else this.m_CheckGameID = null;
- }else{
- g_GlobalUserInfo.SetUserInfo(UserInfo.UserID,UserInfo.NickName,UserInfo.GameID,UserInfo.HeadUrl);
- if(this.m_CheckGameID == GameID)this.SetUserInfo(UserInfo.UserID, g_GlobalUserInfo.m_UserInfoMap[UserInfo.UserID]);
-
- }
- }.bind(this));
- },
- OnBtChangeSex:function(){
- var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
- var ChangeSex = pGlobalUserData.cbGender==1?0:1 ;
- // if(pGlobalUserData.cbGender) ChangeSex=0;
- var webUrl = window.PHP_HOME+'/UserFunc.php?&GetMark=6&dwUserID='+pGlobalUserData.dwUserID;
- webUrl += "&Sex="+ChangeSex;
- WebCenter.GetData(webUrl, null, function (data) {
- pGlobalUserData.cbGender = ChangeSex;
- console.log("OnBtChangeSex",pGlobalUserData);
- for(var i in this.m_SpGender) {
- if(!this.m_SpGender[i]) continue;
- this.m_SpGender[i].node.active = (i == ChangeSex);
-
- }
-
- }.bind(this));
- },
-
- });
|