ClubList&Pre.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. },
  5. ctor:function () {
  6. this.m_SelClubInfo = null;
  7. this.m_Loading = false;
  8. },
  9. OnUpdateListCheck:function () {
  10. var ClubID = 0;
  11. if(this.m_SelClubInfo)ClubID = this.m_SelClubInfo.dwClubID;
  12. this.m_ListCtrl.ForEachCtrl(0, function(Js){
  13. Js.UpdateClubSel(ClubID)
  14. }.bind(this));
  15. },
  16. OnUpdateList:function (CallBack, Kind) {
  17. this.m_SelKind = Kind;
  18. if(this.m_ListCtrl == null) this.m_ListCtrl = this.node.getComponent('CustomListCtrl');
  19. this.m_ListCtrl.InitList(0, 'ClubList&Pre', this);
  20. this.SetClubList(g_GlobalClubInfo.onGetClubInfoList());
  21. },
  22. OnUpdateTableCnt:function(dwClubID){
  23. this.m_ListCtrl.ForEachCtrl(0,function(e){
  24. if(e.m_ClubInfo.dwClubID == dwClubID ) e.m_LbTableCnt.string = ''+e.m_ClubInfo.wTableCount;
  25. }.bind(this));
  26. },
  27. //显示俱乐部列表
  28. SetClubList:function (ClubList) {
  29. var NoClub = this.$('ListBG/ScollView/ScrollView0/view/NoClub');
  30. NoClub = NoClub || this.$('ScollView/ScrollView0/view/NoClub') || this.$('BGB/BGNoClub');
  31. if(NoClub) NoClub.active = true;
  32. if(ClubList.length == 0) return;
  33. var index = -1;
  34. for(var i in ClubList){
  35. if(window.g_Setting[window.SetKey_CLUB_DEF1] == ClubList[i].dwClubID && this.m_SelKind < CLUB_KIND_2 ){
  36. index = i;
  37. break;
  38. }
  39. if(window.g_Setting[window.SetKey_CLUB_DEF2] == ClubList[i].dwClubID && this.m_SelKind == CLUB_KIND_2 ){
  40. index = i;
  41. break;
  42. }
  43. }
  44. if(index !=-1){
  45. this.m_ListCtrl.InsertListInfo(0, ClubList[index]);
  46. if(NoClub) NoClub.active = false;
  47. }
  48. this.m_SelClubInfo = null;
  49. //刷新列表
  50. for (var i in ClubList ) {
  51. if(this.m_SelKind == null)continue;
  52. if(typeof(ClubList[i])!=='object')continue;
  53. if(ClubList[i] == null)continue;
  54. if(((this.m_SelKind == CLUB_KIND_2 && ClubList[i].wKindID < this.m_SelKind)||(this.m_SelKind<CLUB_KIND_2 && ClubList[i].wKindID > CLUB_KIND_1 ))) continue;
  55. if(index!= -1 && i == index) continue;
  56. this.m_ListCtrl.InsertListInfo(0, ClubList[i]);
  57. if(NoClub) NoClub.active = false;
  58. }
  59. },
  60. OnChangeClub:function (ClubInfo, bHideList) {
  61. this.m_SelClubInfo = ClubInfo;
  62. this.m_Hook.OnChangeClub(ClubInfo);
  63. if(bHideList) this.HideView();
  64. },
  65. OnExitClub:function (ClubInfo) {
  66. var str = '確認退出?'//该联盟
  67. if(ClubInfo.ClubLevel == 9) str ='確認解散?';//该联盟
  68. this.ShowAlert(str,Alert_YesNo, function(Res) {
  69. if(Res){
  70. g_Lobby.ShowLoading();
  71. g_Lobby.OnExitClub(this.m_SelClubInfo.dwClubID);
  72. this.HideView();
  73. }
  74. }.bind(this));
  75. },
  76. OnBtShare: function(){
  77. if(this.m_SelClubInfo == null ) return this.ShowTips("請先進入大聯盟!");
  78. this.ShowPrefabDLG("SharePre");
  79. },
  80. //分享信息
  81. GetShareInfo: function() {
  82. var ShareInfo = new Object();
  83. ShareInfo.title = '【'+this.m_SelClubInfo.szClubName+'】 大聯盟 ID:'+this.m_SelClubInfo.dwAllianceID;
  84. ShareInfo.desc = '歡迎加入【'+ g_GlobalUserInfo.m_UserInfoMap[this.m_SelClubInfo.dwCreaterID].NickName+'】ID:'
  85. +g_GlobalUserInfo.m_UserInfoMap[this.m_SelClubInfo.dwCreaterID].GameID+'的大聯盟';
  86. ShareInfo.link = cc.share.MakeLink_InviteClub(this.m_SelClubInfo.wKindID, this.m_SelClubInfo.dwAllianceID);
  87. return ShareInfo;
  88. },
  89. OnClickMoreClub: function(){
  90. this.m_Hook.OnClickMoreClub();
  91. this.HideView();
  92. },
  93. //筛选
  94. OnBtFliter:function(){
  95. this.$('BGB/FliterNode').active = !this.$('BGB/FliterNode').active;
  96. },
  97. OnBtFliterLimit:function(_,data){
  98. this.$('BGB/FliterNode').active = false;
  99. this.$('BGB/FliterBtn/Background/LimitTip@Label').string = this.$('BGB/FliterNode/BtFliter'+data+'/Background/Label@Label').string;
  100. var level = 0;
  101. if (data == 1){
  102. level = 0;
  103. }else if(data == 2){
  104. level = 3;
  105. }
  106. else if(data == 3){
  107. level = 6;
  108. }
  109. else if(data == 4){
  110. level = 8;
  111. }
  112. else if(data == 5){
  113. level = 9;
  114. }
  115. var ClubList = g_GlobalClubInfo.onGetClubInfoList();
  116. for (var j in ClubList )
  117. {
  118. if(typeof(ClubList[j])!=='object')continue;
  119. if(ClubList[j] == null)continue;
  120. for(var i=0;i<this.m_ListCtrl.m_CtrlArr[0].length;i++)
  121. {
  122. var Js = this.m_ListCtrl.m_CtrlArr[0][i];
  123. if(Js.m_ClubInfo.dwClubID != ClubList[j].dwClubID) continue;
  124. Js.node.active = level == 0?true: Js.m_ClubInfo.cbClubLevel == level;
  125. break;
  126. }
  127. }
  128. },
  129. UpdateDefTog:function(){
  130. this.OnUpdateList(null,this.m_SelKind);
  131. },
  132. /////////////////////////////////////////////////////////////////////////////
  133. //Pre js
  134. InitPre:function(){
  135. if(this.m_LabID == null) {
  136. this.m_LabID = this.$("LbID@Label");
  137. if(this.m_UserCtrl == null) this.m_UserCtrl = this.$("@UserCtrl");
  138. if(this.m_UserCtrl ) this.m_UserCtrl.SetUserByID(0);
  139. if(this.m_TogCtrl == null) this.m_TogCtrl = this.$("@Toggle");
  140. if(this.m_LabName == null) this.m_LabName = this.$("LbName@Label");
  141. if(this.m_LabCnt == null) this.m_LabCnt = this.$("LbCnt@Label");
  142. if(this.m_LbLv == null) this.m_LbLv = this.$("LbLv@Label");
  143. if(this.m_NdClub == null) this.m_NdClub = this.$("NdClub");
  144. if(this.m_NdClub1 == null) this.m_NdClub1 = this.$("NdClub1");
  145. if(this.m_LbTableCnt == null) this.m_LbTableCnt = this.$("LbTableCnt@Label");
  146. }
  147. },
  148. SetPreInfo:function(ParaArr){
  149. this.SetClubInfo(ParaArr);
  150. },
  151. //ClubInfo : ClubLever CreaterID GameID HeadUrl NickName Notice
  152. SetClubInfo:function(ClubInfo){
  153. //参数
  154. this.m_ClubInfo = ClubInfo;
  155. //显示内容
  156. if(this.m_UserCtrl ) {
  157. this.m_UserCtrl.SetUserByID(ClubInfo.dwCreaterID);
  158. this.m_UserCtrl.SetShowFullName(false, 5);
  159. }
  160. if(this.m_LabName)this.m_LabName.string =cutstr(ClubInfo.szClubName, 4);// ClubInfo.ClubName;
  161. if(this.m_LabID)this.m_LabID.string = ClubInfo.dwAllianceID;//"ID:"+
  162. if(this.m_LabCnt)this.m_LabCnt.string = "玩家:"+ ClubInfo.wMemberCnt + "人";
  163. //if(this.m_LbLv)this.m_LbLv.string = window.ClubLvStr[ClubInfo.ClubLevel];
  164. //俱乐部权限等级
  165. if(this.m_LbLv) {
  166. this.m_LbLv.string = window.ClubLvStr[ClubInfo.cbClubLevel];
  167. // if(ClubInfo.ClubLevel >= 9) this.m_LbLv.node.color = cc.color(255, 98, 0);
  168. // else if(ClubInfo.ClubLevel == 8) this.m_LbLv.node.color = cc.color(0, 168, 255);
  169. // else if(ClubInfo.ClubLevel >= 6) this.m_LbLv.node.color = cc.color(35, 222, 30);
  170. // else this.m_LbLv.node.color = cc.color(170, 57, 40);
  171. }
  172. g_Lobby.m_ClubRoomCnt[ClubInfo.dwClubID] = ClubInfo.wTableCount;
  173. var TableCnt = g_Lobby.m_ClubRoomCnt[ClubInfo.dwClubID] ;
  174. if(TableCnt == null) TableCnt = 0;
  175. if(this.m_LbTableCnt) this.m_LbTableCnt.string = TableCnt;
  176. if(this.m_NdClub && this.m_NdClub1){
  177. this.m_NdClub.active = ClubInfo.wKindID < CLUB_KIND_2;
  178. this.m_NdClub1.active = ClubInfo.wKindID >= CLUB_KIND_2;
  179. }
  180. if(this.m_TogCtrl )this.m_TogCtrl.isChecked = false;
  181. if(ShowLobbyClub && ClubInfo.ClubID == ShowLobbyClub) {
  182. //ShowLobbyClub = 0;
  183. if(this.m_TogCtrl) this.m_TogCtrl.check();
  184. //this.OnBtClicked();
  185. }
  186. if(this.$('NdClub/type@Label')) this.$('NdClub/type@Label').string = ClubInfo.wKindID == CLUB_KIND_0?'普通場':'比賽場';
  187. this.UpdateClubSel();
  188. this.setDefTog();
  189. },
  190. UpdateClubSel:function(ClubID){
  191. //this.m_TogCtrl.isChecked = (this.m_ClubInfo.ClubID == ClubID);
  192. if(g_Lobby.m_RoomArr == null) return
  193. var RoomArr = g_Lobby.m_RoomArr;
  194. var RoomInfo = null;
  195. for(var i=0;i<RoomArr.wClubCnt;i++){
  196. if(RoomArr.RoomInfo[i].dwClubID == this.m_ClubInfo.ClubID){
  197. RoomInfo = RoomArr.RoomInfo[i];
  198. break;
  199. }
  200. }
  201. if(RoomInfo && this.$('score@Label')){
  202. var dwRules = RoomInfo.dwRules;
  203. var dwServerRules = RoomInfo.dwServerRules;
  204. var gamedef = new window['CMD_GAME_'+RoomInfo.wKindID]();
  205. this.$('score@Label').string = gamedef.GetBaseScore(dwServerRules, dwRules);
  206. this.$('rule@Label').string = gamedef.GetGameMode(dwServerRules, dwRules);
  207. this.$('pay@Label').string = gamedef.GetPayMode(dwServerRules, dwRules);
  208. this.$('subroom@Label').string = gamedef.GetGameCount(dwServerRules, dwRules);
  209. this.$('people@Label').string = RoomInfo.byPlayerCnt;
  210. }
  211. },
  212. OnBtClicked:function(){
  213. //if(this.m_Hook == null) return;
  214. //if(this.m_TogCtrl.isChecked) return;
  215. //this.m_Hook.OnChangeClub(this.m_ClubInfo);
  216. if(g_Lobby == null) return;
  217. this.m_Hook.node.active = false;
  218. g_Lobby.OnChangeClub(this.m_ClubInfo);
  219. },
  220. OnBtClickExit:function(){
  221. if(this.m_Hook == null) return;
  222. this.m_Hook.OnExitClub(this.m_ClubInfo);
  223. },
  224. OnClick_BtShare:function(){
  225. this.m_Hook.m_SelClubInfo = this.m_ClubInfo;
  226. this.m_Hook.OnBtShare();
  227. },
  228. OnTogClick:function(){
  229. var tagSelected = this.$('Tog@Toggle').isChecked;
  230. if(this.m_ClubInfo.wKindID < CLUB_KIND_2){
  231. window.SaveSetting(window.SetKey_CLUB_DEF1, parseInt(tagSelected?this.m_ClubInfo.dwClubID:0));
  232. window.g_Setting[window.SetKey_CLUB_DEF1] = tagSelected?this.m_ClubInfo.dwClubID:0;
  233. }else{
  234. window.SaveSetting(window.SetKey_CLUB_DEF2, parseInt(tagSelected?this.m_ClubInfo.dwClubID:0));
  235. window.g_Setting[window.SetKey_CLUB_DEF2] = tagSelected?this.m_ClubInfo.dwClubID:0;
  236. }
  237. this.m_Hook.UpdateDefTog();
  238. },
  239. setDefTog:function(){
  240. if(this.m_ClubInfo.wKindID < CLUB_KIND_2){
  241. this.$('Tog@Toggle').isChecked = window.g_Setting[window.SetKey_CLUB_DEF1] == this.m_ClubInfo.dwClubID;
  242. } else{
  243. this.$('Tog@Toggle').isChecked = window.g_Setting[window.SetKey_CLUB_DEF2] == this.m_ClubInfo.dwClubID;
  244. }
  245. }
  246. /////////////////////////////////////////////////////////////////////////////
  247. });