ClubSet.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. m_TabNode:cc.Node,
  5. m_SubNode:cc.Node,
  6. },
  7. ctor:function(){
  8. this.m_nNeedUpdate = 0;
  9. this.SHOW_RANK = 4;
  10. this.HIDE_ID = 1;
  11. this.NORMAL_GAME = 2;
  12. },
  13. OnShowView:function(){
  14. this.$('NoUse').active = this.m_Hook.m_SelClubInfo.cbClubLevel<=CLUB_LEVEL_MEMBER;
  15. this.$('Sub/Sub_0').active = this.m_Hook.m_SelClubInfo.cbClubLevel>=CLUB_LEVEL_PARTNER;
  16. this.$('Sub/Sub_0/ClubName').active = this.m_Hook.m_SelClubInfo.cbClubLevel>=CLUB_LEVEL_MANAGER;
  17. this.$('Sub/Sub_0/ClubRank').active = this.m_Hook.m_SelClubInfo.cbClubLevel>=CLUB_LEVEL_MANAGER;
  18. this.$('Sub/Sub_0/ClubCheck').active = this.m_Hook.m_SelClubInfo.cbClubLevel>=CLUB_LEVEL_MANAGER;
  19. this.$('Sub/Sub_0/ClubNoitce1').active = this.m_Hook.m_SelClubInfo.cbClubLevel>=CLUB_LEVEL_MANAGER;
  20. this.$('Sub/Sub_0/ClubClose').active = this.m_Hook.m_SelClubInfo.cbClubLevel>=CLUB_LEVEL_MANAGER;
  21. this.$('Sub/Sub_0/ClubSecret').active = this.m_Hook.m_SelClubInfo.cbClubLevel>=CLUB_LEVEL_MANAGER;
  22. this.$('Sub/Sub_0/ClubNoitce2').active = this.m_Hook.m_SelClubInfo.wKindID > CLUB_KIND_0 && this.m_Hook.m_SelClubInfo.cbClubLevel>=CLUB_LEVEL_PARTNER;
  23. this.$('Sub/Sub_0/BtNode/BtRemit').active = this.m_Hook.m_SelClubInfo.cbClubLevel>=CLUB_LEVEL_PARTNER;
  24. this.$('Sub/Sub_0/BtNode/BtLeaveClub').active = this.m_Hook.m_SelClubInfo.wKindID<CLUB_KIND_2;
  25. this.$('Sub/Sub_0/BtNode/BtLeaveLeague').active = this.m_Hook.m_SelClubInfo.wKindID==CLUB_KIND_2;
  26. if(this.m_Hook.m_SelClubInfo.cbClubLevel == CLUB_LEVEL_OWNER){
  27. cc.gPreLoader.LoadRes('Image_ClubSet_BtDissClub','Club',function(sprFrame){
  28. this.$('Sub/Sub_0/BtNode/BtLeaveClub@Sprite').spriteFrame = sprFrame;
  29. }.bind(this));
  30. cc.gPreLoader.LoadRes('Image_ClubSet_BtDissClub2','Club',function(sprFrame){
  31. this.$('Sub/Sub_0/BtNode/BtLeaveLeague@Sprite').spriteFrame = sprFrame;
  32. }.bind(this));
  33. }
  34. else{
  35. cc.gPreLoader.LoadRes('Image_ClubSet_BtExitClub','Club',function(sprFrame){
  36. this.$('Sub/Sub_0/BtNode/BtLeaveClub@Sprite').spriteFrame = sprFrame;
  37. }.bind(this));
  38. cc.gPreLoader.LoadRes('Image_ClubSet_BtExitClub2','Club',function(sprFrame){
  39. this.$('Sub/Sub_0/BtNode/BtLeaveLeague@Sprite').spriteFrame = sprFrame;
  40. }.bind(this));
  41. }
  42. this.$('ToggleContainer/1').active = this.m_Hook.m_SelClubInfo.cbClubLevel>=CLUB_LEVEL_MANAGER;
  43. this.$('ToggleContainer/2').active = this.m_Hook.m_SelClubInfo.cbClubLevel>=CLUB_LEVEL_MANAGER;
  44. this.$('ToggleContainer/0/Background/Label@Label').string = this.m_Hook.m_SelClubInfo.wKindID<CLUB_KIND_2 ? '俱樂部設定':'聯盟設定';
  45. this.$('ToggleContainer/0/checkmark/Label@Label').string = this.m_Hook.m_SelClubInfo.wKindID<CLUB_KIND_2 ? '俱樂部設定':'聯盟設定';
  46. this.$('BG/TClubSet').active = this.m_Hook.m_SelClubInfo.wKindID==CLUB_KIND_2;
  47. this.$('BG/TClubSet2').active = this.m_Hook.m_SelClubInfo.wKindID<CLUB_KIND_2;
  48. this.$('Sub/Sub_0/ClubNoitce2@Label').string = this.m_Hook.m_SelClubInfo.wKindID==CLUB_KIND_2?'聯盟公告':'俱樂部公告';
  49. this.$('Sub/Sub_0/ClubNoitce2/EditBox/PLACEHOLDER_LABEL@Label').string = this.m_Hook.m_SelClubInfo.wKindID==CLUB_KIND_2?'請輸入聯盟公告':'請輸入俱樂部公告';
  50. this.m_EdClubName = this.$('Sub/Sub_0/ClubName/EditBox@EditBox');
  51. if(this.m_EdClubName) this.m_EdClubName.string = this.m_Hook.m_SelClubInfo.szClubName;
  52. this.m_EdClubNoitce = this.$('Sub/Sub_0/ClubNoitce1/EditBox@EditBox');
  53. if(this.m_EdClubNoitce) this.m_EdClubNoitce.string = this.m_Hook.m_SelClubInfo.szNotice;
  54. this.m_EdClubNoitce2 = this.$('Sub/Sub_0/ClubNoitce2/EditBox@EditBox');
  55. if(this.m_EdClubNoitce2) this.m_EdClubNoitce2.string = this.m_Hook.m_SelClubInfo.szNotice2;
  56. this.TgNoChat = this.$('ToggleNoChat@Toggle');
  57. if(!this.m_BlockedUser) {
  58. this.m_BlockedUser = this.$('Sub/1@BlockedUser');
  59. this.m_BlockedUser.m_Hook = this.m_Hook;
  60. }
  61. if(!this.m_ClubGroup) {
  62. this.m_ClubGroup = this.$('Sub/2@ClubGroup');
  63. this.m_ClubGroup.m_Hook = this.m_Hook;
  64. }
  65. this.m_nNeedUpdate = 1;
  66. this.$('Sub/Sub_0/ClubClose/toggle1@Toggle').isChecked = this.m_Hook.m_SelClubInfo.cbCloseStatus;
  67. this.$('Sub/Sub_0/ClubCheck/toggle1@Toggle').isChecked = this.m_Hook.m_SelClubInfo.cbJoinLimit;
  68. this.$('Sub/Sub_0/ClubRank/toggle1@Toggle').isChecked = ( this.m_Hook.m_SelClubInfo.dwRules & this.SHOW_RANK);
  69. this.$('Sub/Sub_0/ClubSecret/toggle1@Toggle').isChecked = ( this.m_Hook.m_SelClubInfo.dwRules & this.HIDE_ID);
  70. this.$('Sub/3@ClubSwitchBG').SetHook(this.m_Hook);
  71. },
  72. OnToggleClicked: function() {
  73. this.m_nNeedUpdate=1;
  74. },
  75. update: function() {
  76. if(this.m_nNeedUpdate > 0) {
  77. this.m_nNeedUpdate--;
  78. } else {
  79. return;
  80. }
  81. for(var i in this.$('ToggleContainer').children) {
  82. var pNode = this.$('ToggleContainer').children[i];
  83. var pToggle = this.$('@Toggle', pNode);
  84. if(!pToggle) continue;
  85. if(pToggle.isChecked) {
  86. if(this.$('Sub').children[i]) {
  87. this.$('Sub').children[i].active = true;
  88. if(i==3){
  89. this.$('NoUse').active = false;
  90. } else{
  91. this.$('NoUse').active = this.m_Hook.m_SelClubInfo.cbClubLevel<=CLUB_LEVEL_MEMBER;
  92. }
  93. }
  94. } else {
  95. if(this.$('Sub').children[i]) this.$('Sub').children[i].active = false;
  96. }
  97. }
  98. if(this.m_BlockedUser.node.active) {
  99. this.m_BlockedUser.Refresh();
  100. } else if(this.m_ClubGroup.node.active) {
  101. this.m_ClubGroup.Refresh();
  102. }
  103. },
  104. OnBtSure:function(){
  105. var reg = /^(?!_)(?!.*?_$)[a-zA-Z0-9_\u4e00-\u9fa5]+$/;
  106. if ( this.m_EdClubName.string.length < 1 || !reg.test( this.m_EdClubName.string )) {
  107. this.ShowAlert("請輸入有效名稱!");
  108. return;
  109. }
  110. var TempRules = this.m_Hook.m_SelClubInfo.dwRules;
  111. if(this.$('Sub/Sub_0/ClubRank/toggle1@Toggle').isChecked){
  112. TempRules = (TempRules|this.SHOW_RANK);
  113. }else{
  114. if( TempRules & this.SHOW_RANK ) TempRules -= this.SHOW_RANK;
  115. }
  116. if(this.$('Sub/Sub_0/ClubSecret/toggle1@Toggle').isChecked){
  117. TempRules = (TempRules|this.HIDE_ID);
  118. }else{
  119. if( TempRules & this.HIDE_ID ) TempRules -= this.HIDE_ID;
  120. }
  121. var Joinlimit = 0;
  122. if(this.$('Sub/Sub_0/ClubCheck/toggle1@Toggle').isChecked){
  123. Joinlimit = 1;
  124. }
  125. var CloseStatus = 0;
  126. if(this.$('Sub/Sub_0/ClubClose/toggle1@Toggle').isChecked){
  127. CloseStatus = 1;
  128. }
  129. if(this.m_EdClubName.string == this.m_Hook.m_SelClubInfo.szClubName &&
  130. this.m_EdClubNoitce.string == this.m_Hook.m_SelClubInfo.szNotice &&
  131. this.m_EdClubNoitce2.string == this.m_Hook.m_SelClubInfo.szNotice2 &&
  132. this.m_Hook.m_SelClubInfo.dwRules == TempRules &&
  133. Joinlimit == this.m_Hook.m_SelClubInfo.cbJoinLimit &&
  134. CloseStatus == this.m_Hook.m_SelClubInfo){
  135. g_Lobby.ShowTips('沒有修改,不能保存');
  136. return;
  137. }
  138. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  139. var Obj = new CMD_GC_SaveClubSet();
  140. Obj.dwUserID = pGlobalUserData.dwUserID;
  141. Obj.szPassWord = pGlobalUserData.szPassword;
  142. Obj.dwClubID = this.m_Hook.m_SelClubInfo.dwClubID; //俱乐部ID
  143. Obj.szClubName = this.m_EdClubName.string;//[31]; //俱乐部名字
  144. Obj.cbJoinLimit = Joinlimit; //
  145. Obj.dwRules = TempRules; //
  146. Obj.szNotice = this.m_EdClubNoitce.string;//[256]; //俱乐部公告
  147. Obj.szNotice2 = this.m_EdClubNoitce2.string;//[256]; //专属公告
  148. Obj.cbCloseStatus = CloseStatus;
  149. window.gClubClientKernel.onSendSaveClubSet(this,Obj);
  150. },
  151. OnClick_ComNoChat:function(){
  152. this.m_Hook.OnOpNoChat( this.TgNoChat.isChecked );
  153. this.HideView();
  154. },
  155. OnChangeClubSet:function(){
  156. this.m_Hook.SendClubConfig( this.m_Toggle[0].isChecked,this.m_Toggle[1].isChecked);
  157. this.HideView();
  158. },
  159. OnClick_ClubJoinLimit:function(){
  160. },
  161. OnClick_SetHideRank:function(){
  162. },
  163. OnClick_SetHideID:function(){
  164. },
  165. OnClick_SetNormalGame:function(){
  166. },
  167. OnClick_ExitClub:function(){
  168. this.m_Hook.OnBtExitClub();
  169. },
  170. OnClick_ClubClose:function(target){
  171. },
  172. });