LeagueList.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {},
  4. ctor: function () {
  5. this.m_nNeedUpdate = 0;
  6. },
  7. InitView: function () {
  8. if (!this.m_ToggleNode) this.m_ToggleNode = this.$('ToggleContainer');
  9. if (!this.m_ListNode) this.m_ListNode = this.$('ScollView');
  10. if (!this.m_SelToggle) {
  11. this.m_SelToggle = new Array();
  12. for (var i in this.m_ToggleNode.children) {
  13. var index = this.m_ToggleNode.children[i].name;
  14. this.m_SelToggle[index] = this.$('@Toggle', this.m_ToggleNode.children[i]);
  15. }
  16. }
  17. if (!this.m_ListCtrl) {
  18. this.m_ListCtrl = this.$('@CustomListCtrl');
  19. this.m_ListCtrl.InitList(0, 'ClubList&Pre', this);
  20. this.m_ListCtrl.InitList(1, 'LobbyRoom', this);
  21. this.$('@ClubList&Pre').m_Hook = this;
  22. }
  23. },
  24. OnShowView: function () {
  25. this.InitView();
  26. this.m_nNeedUpdate = 1;
  27. ShowO2I(this.node);
  28. },
  29. OnHideView: function () {
  30. HideI2O(this.node);
  31. },
  32. update: function () {
  33. //显示处理
  34. if (this.m_nNeedUpdate > 0) {
  35. this.m_nNeedUpdate--;
  36. } else {
  37. return;
  38. }
  39. for (var i = 0; i < this.m_ListNode.childrenCount; i++) {
  40. this.m_ListNode.children[i].active = false;
  41. }
  42. var Index = 0;
  43. for (var i in this.m_SelToggle) {
  44. if (this.m_SelToggle[i].isChecked) {
  45. Index = i;
  46. break;
  47. }
  48. }
  49. if (this.$('@ClubList&Pre')) {
  50. if (Index == 0) {
  51. this.$('@ClubList&Pre').OnUpdateList(function () {
  52. this.OnLoadRoomHistory(); //if(ShowLobbyClub==0)
  53. //房间记录
  54. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  55. var webUrl = window.PHP_HOME + '/League.php?&GetMark=6&dwUserID=' + pGlobalUserData.dwUserID;
  56. WebCenter.GetData(webUrl, 3, function (data) {
  57. var ClubList = JSON.parse(data);
  58. this.m_Hook.OnQueryLoadRoomHistory(ClubList);
  59. }.bind(this));
  60. }.bind(this));
  61. } else if (Index == 1) {
  62. this.m_ListCtrl.InitList(1, 'LobbyRoom', this);
  63. this.m_Hook.OnLoadOwnRoomList();
  64. }
  65. var tempNode = this.$('ScrollView' + Index, this.m_ListNode);
  66. if (tempNode) tempNode.active = true;
  67. }
  68. },
  69. OnToggleSelList:function(Tag, Data){
  70. this.m_nNeedUpdate = 1;
  71. },
  72. onOwnRoomList: function (OwnRoom) { //CMD_GP_S_OwnRoomInfo
  73. this.m_ListCtrl.InitList(1, 'LobbyRoom', this);
  74. this.$('ScollView/ScrollView1/view/NoRoom').active = OwnRoom.wCnt == 0;
  75. for (var i = 0; i < OwnRoom.wCnt; i++) {
  76. this.m_ListCtrl.InsertListInfo(1, OwnRoom.RoomInfo[i]);
  77. }
  78. },
  79. OnLoadRoomHistory: function () {
  80. //房间记录
  81. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  82. var webUrl = window.PHP_HOME + '/League.php?&GetMark=6&dwUserID=' + pGlobalUserData.dwUserID;
  83. WebCenter.GetData(webUrl, 3, function (data) {
  84. var ClubList = JSON.parse(data);
  85. this.m_Hook.OnQueryLoadRoomHistory(ClubList);
  86. }.bind(this));
  87. },
  88. OnGetRoomExRes: function (Res) { //CMD_GP_C_GetRoomExRes
  89. this.m_RoomArr = Res;
  90. /*this.m_ListCtrl.InitList(1, 'LobbyRoom', this);
  91. this.$('ListBG/ScollView/ScrollView1/view/NoRoom').active = true;
  92. for(var i=Res.wClubCnt;i<Res.wRoomCnt;i++){
  93. this.m_ListCtrl.InsertListInfo(1, Res.RoomInfo[i]);
  94. this.$('ListBG/ScollView/ScrollView1/view/NoRoom').active = false;
  95. }*/
  96. for (var i = 0; i < 10; i++) {
  97. var TempClubID = Res.dwClubID[i];
  98. if (TempClubID > 0) this.m_ClubRoomCnt[TempClubID] = Res.wClubRoomCnt[i];
  99. }
  100. if (this.$('@ClubList&Pre')) {
  101. this.$('@ClubList&Pre').OnUpdateListCheck();
  102. }
  103. var TempStr = cc.sys.localStorage.getItem(window.clientName + 'RoomHistory');
  104. var TempArr = new Array();
  105. if (TempStr) TempArr = JSON.parse(TempStr);
  106. for (var i in TempArr) {
  107. var bIn = false;
  108. for (var j = 0; j < Res.wRoomCnt; j++) {
  109. if (TempArr[i] == Res.RoomInfo[j].dwRoomID) bIn = true;
  110. }
  111. if (!bIn) TempArr.splice(i, 1);
  112. }
  113. cc.sys.localStorage.setItem(window.clientName + 'RoomHistory', JSON.stringify(TempArr));
  114. },
  115. OnChangeClub:function(ClubInfo){
  116. cc.gSoundRes.PlaySound('Button');
  117. this.m_Hook.OnChangeClub(ClubInfo);
  118. },
  119. });