ClubFreeDLG.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. m_CreatNode:cc.Node,
  5. m_JoinNode:cc.Node,
  6. m_ClubNameEdit:cc.EditBox,
  7. },
  8. ctor:function () {
  9. this.m_RecordArr = new Array();
  10. this.m_numArr = '';
  11. this.m_numLabArr = [];
  12. this.m_numInidex = 0;
  13. this.m_Authority = 0;
  14. },
  15. ShowKind:function (Kind) {
  16. if(Kind)this.m_ClubKind = Kind
  17. this.$('BGB/Club').active = this.m_ClubKind < CLUB_KIND_2 ;
  18. this.$('BGB/Club1').active = this.m_ClubKind >= CLUB_KIND_2;
  19. this.$('BGB/BGNoClub/spNoClub').active = this.m_ClubKind < CLUB_KIND_2;
  20. this.$('BGB/BGNoClub/spNoClub1').active = this.m_ClubKind >= CLUB_KIND_2;
  21. this.$('@ClubList&Pre').m_Hook = this;
  22. this.$('@ClubList&Pre').OnUpdateList(null, this.m_ClubKind);
  23. for (let i = 0; i < 6; i++) {
  24. this.m_numLabArr.push(this.$(`JoinClub/NumBG/n${i}@Label`));
  25. this.m_numLabArr[i].string = '';
  26. }
  27. },
  28. OnBtClickNum:function(Tag,Data){
  29. if( this.m_ClubNum ) return
  30. if(Data == 'Reset'){ //重置
  31. this.m_ClubNum = 0;
  32. this.m_numArr ='';
  33. this.m_numInidex = 0;
  34. for (let i = 0; i < 6; i++) {
  35. this.m_numLabArr[i].string = '';
  36. }
  37. }else if(Data == 'Del'){ //删除
  38. if(this.m_numArr.length){
  39. this.m_numArr = this.m_numArr.slice(0,this.m_numArr.length-1)
  40. this.m_numLabArr[--this.m_numInidex].string = '';
  41. }
  42. }else{ //0-9
  43. this.m_numArr += Data;
  44. this.m_numLabArr[this.m_numInidex++].string = Data;
  45. }
  46. //6位完成
  47. if(this.m_numArr.length >= 6){
  48. this.m_ClubNum = parseInt(this.m_numArr);
  49. this.OnBtJoinSure();
  50. this.m_numArr = '';
  51. this.m_numInidex = 0;
  52. for (let i = 0; i < 6; i++) {
  53. this.m_numLabArr[i].string = '';
  54. }
  55. }
  56. },
  57. //显示 创建/加入二级框
  58. OnBtShowCreat:function () {
  59. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  60. var webUrl = window.PHP_HOME+ '/League.php?GetMark=39&dwUserID='+pGlobalUserData.dwUserID;
  61. WebCenter.GetData(webUrl, null, function (data) {
  62. this.m_Authority = parseInt(data);
  63. }.bind(this));
  64. this.m_ClubNameEdit.string = '';
  65. this.m_ClubKind = CLUB_KIND_0;
  66. if(this.m_CreatNode.active){
  67. this.m_CreatNode.active = false;
  68. }else{
  69. this.m_CreatNode.active = true;
  70. this.$('CreateNode/kind').active = true;
  71. this.$('CreateNode/BGM/TCreat').active = true;
  72. this.$('CreateNode/BGM/TCreat1').active = false;
  73. this.$('CreateNode/BGM/Label@Label').string = '創建俱樂部需要100鑽石';
  74. }
  75. },
  76. //显示 创建/加入二级框
  77. OnBtShowCreat1:function () {
  78. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  79. var webUrl = window.PHP_HOME+ '/League.php?GetMark=39&dwUserID='+pGlobalUserData.dwUserID;
  80. WebCenter.GetData(webUrl, null, function (data) {
  81. this.m_Authority = parseInt(data);
  82. }.bind(this));
  83. this.m_ClubNameEdit.string = '';
  84. this.m_ClubKind = CLUB_KIND_2;
  85. if(this.m_CreatNode.active){
  86. this.m_CreatNode.active = false;
  87. }else{
  88. this.m_CreatNode.active = true;
  89. this.$('CreateNode/kind').active = false;
  90. this.$('CreateNode/BGM/TCreat').active = false;
  91. this.$('CreateNode/BGM/TCreat1').active = true;
  92. this.$('CreateNode/BGM/Label@Label').string = '創建聯盟需要100鑽石';
  93. }
  94. },
  95. OnBtShowJoin:function (Tag, Para) {
  96. this.m_ClubNum = 0;
  97. this.m_ClubNameEdit.string = '';
  98. this.m_numArr ='';
  99. this.m_numInidex = 0;
  100. for (let i = 0; i < 6; i++) {
  101. this.m_numLabArr[i].string = '';
  102. }
  103. if(Para){
  104. this.$('JoinClub/BGM/TJoin').active = false;
  105. this.$('JoinClub/BGM/TJoin1').active = true;
  106. }else{
  107. this.$('JoinClub/BGM/TJoin').active = true;
  108. this.$('JoinClub/BGM/TJoin1').active = false;
  109. }
  110. if(this.m_JoinNode.active){
  111. this.m_JoinNode.active = false;
  112. }else{
  113. this.m_JoinNode.active = true;
  114. }
  115. },
  116. OnBtCreateSure:function () {
  117. if(this.m_ClubKind == CLUB_KIND_2 && (this.m_Authority & 0x04)==0){
  118. this.ShowTips('許可權不足');//,請聯系管理員.
  119. return;
  120. }
  121. if(this.m_ClubKind == CLUB_KIND_1 && (this.m_Authority & 0x02)==0){
  122. this.ShowTips('許可權不足');//,請聯系管理員.
  123. return;
  124. }
  125. //创建
  126. var reg = /^(?!_)(?!.*?_$)[a-zA-Z0-9_\u4e00-\u9fa5]+$/;
  127. if( !reg.test(this.m_ClubNameEdit.string) || this.m_ClubNameEdit.string.length < 1 ){
  128. this.ShowAlert("請輸入有效名稱!");
  129. return;
  130. }
  131. window.gClubClientKernel.onSendCreateClub(0,this.m_ClubNameEdit.string,this.m_ClubKind,(this.m_ClubKind>CLUB_KIND_0?6:0));
  132. this.ResetView();
  133. },
  134. OnBtJoinSure:function () {
  135. window.gClubClientKernel.onSendJoinClub(this,this.m_ClubNum);
  136. },
  137. //检查网络
  138. ShowLoading:function(){
  139. if(this.m_Hook) this.m_Hook.ShowLoading();
  140. },
  141. StopLoading:function(){
  142. if(this.m_Hook) this.m_Hook.StopLoading();
  143. },
  144. OnBtShowDlg:function(Tag,Data){
  145. cc.gSoundRes.PlaySound('Button');
  146. if(this.m_SelClubInfo == null) return;
  147. this.ShowPrefabDLG(Data);
  148. },
  149. OnHideView:function(){
  150. // g_Lobby.$('@ClubList&Pre').OnUpdateList();
  151. if(g_Lobby.m_LeagueList) g_Lobby.m_LeagueList.$('@ClubList&Pre').OnUpdateList();
  152. this.node.active = false;
  153. this.$('BGB/FliterNode').active = false;
  154. },
  155. OnChangeClub:function(Club){
  156. g_Lobby.OnChangeClub(Club);
  157. this.node.active = false;
  158. this.HideView();
  159. },
  160. OnCheckToggle:function(tag,Data){
  161. this.m_ClubKind = parseInt(Data);
  162. },
  163. OnMsgRes:function(szMsg){
  164. this.m_ClubNum = 0;
  165. this.ShowTips(szMsg);
  166. },
  167. JoinClubRes:function(Res){
  168. this.m_JoinNode.active = false;
  169. if(Res.cbRes ==1){
  170. g_Lobby.ShowTips('申請加入成功,等待稽核。');
  171. }else{
  172. g_Lobby.ShowTips('加入成功');
  173. this.$('@ClubList&Pre').OnUpdateList(null, this.m_ClubKind);
  174. }
  175. },
  176. ResetView:function(){
  177. this.m_CreatNode.active = false;
  178. this.m_ClubNameEdit.string = '';
  179. this.m_JoinNode.active = false;
  180. },
  181. UpdateView:function(dwClubID){
  182. this.$('@ClubList&Pre').OnUpdateTableCnt(dwClubID);
  183. }
  184. });