ClubInviteUserList.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. },
  5. ctor :function () {
  6. this._UserID = 0;
  7. this._Status = 0;
  8. this._time = 0;
  9. },
  10. OnShowView:function(){
  11. if(this.m_ListCtrl == null){
  12. this.m_ListCtrl = this.node.getComponent('CustomListCtrl');
  13. if(this._btInviteAll == null) this._btInviteAll = this.$('node/ScrollView/BtInviteAll@Button');
  14. if(this._LabTime == null) this._LabTime = this.$('node/ScrollView/time@Label');
  15. this._LabTime.node.active = false;
  16. }
  17. this.m_ListCtrl.InitList(0, 'ClubInviteUserList', this);
  18. },
  19. OnHideView:function(){
  20. this.m_ListCtrl.ForEachCtrl(0,function(e){
  21. e._time = 0;
  22. e.unschedule(e.UpdateTimePre);
  23. }.bind(this));
  24. this.node.active = false;
  25. },
  26. OnInsertListInfor:function(arr){
  27. for(var i = 0; i < arr.length;i++){
  28. this.m_ListCtrl.InsertListInfo(0, [arr[i],this]);
  29. }
  30. },
  31. OnSetGameInfor:function(RoomInfor){
  32. console.log(RoomInfor);
  33. this._roomInfor = RoomInfor;
  34. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  35. var Obj = new CMD_GC_GetOnlineUser();
  36. Obj.dwUserID = pGlobalUserData.dwUserID;
  37. Obj.dwClubID = RoomInfor.m_dwClubID; //俱乐部ID
  38. window.gClubClientKernel.OnSendGetOnlineUser(this,Obj);
  39. },
  40. OnClick_InviteAll:function(){
  41. this.m_ListCtrl.ForEachCtrl(0,function(e){
  42. e.OnClick_Invite();
  43. }.bind(this));
  44. this.OnCountdown();
  45. },
  46. OnCountdown:function(){
  47. this._time = 10;
  48. this._btInviteAll.interactable = false;
  49. this._LabTime.node.active = true;
  50. this._LabTime.string = this._time+'s';
  51. this.schedule(this.UpdateTime,1.0);
  52. },
  53. UpdateTime:function(){
  54. if(this._time==0){
  55. this._btInviteAll.interactable = true;
  56. this._LabTime.node.active = false;
  57. this.unschedule(this.UpdateTime);
  58. return;
  59. }
  60. this._time--;
  61. this._LabTime.string = this._time+'s';
  62. },
  63. onOnlineUserRes:function(arr){
  64. var freeList = [];
  65. var playList = [];
  66. var busyList = [];
  67. for(var i in arr){
  68. if(arr[i].cbInvite == 1){
  69. busyList.push(arr[i]);
  70. }
  71. else if(arr[i].cbUserStatus < US_SIT){
  72. freeList.push(arr[i]);
  73. }else if(arr[i].cbUserStatus){
  74. playList.push(arr[i]);
  75. }
  76. }
  77. this.OnInsertListInfor(freeList.concat(playList,busyList));
  78. },
  79. /////////////////////////////////////////////////////////////////////////////
  80. //Pre js
  81. InitPre:function(){
  82. if(this.m_UserCtrl == null) this.m_UserCtrl = this.$("@UserCtrl");
  83. if(this.m_Status == null) this.m_Status = this.$("status@Sprite");
  84. if(this._LabTime == null) this._LabTime = this.$('time@Label');
  85. if(this._btInvite == null) this._btInvite = this.$('BtInvite@Button');
  86. this._LabTime.node.active = false;
  87. },
  88. SetPreInfo:function(ParaArr){
  89. this._UserID = ParaArr[0].dwUserID;
  90. this._Status = ParaArr[0].cbUserStatus;
  91. this._bInvite = ParaArr[0].cbInvite;
  92. this.m_UserCtrl.SetUserByID(ParaArr[0].dwUserID);
  93. //this.m_UserCtrl.SetShowFullName(false,6);
  94. var str = '';
  95. if(ParaArr[0].cbInvite == 1){
  96. str = 'busy';
  97. }else if(ParaArr[0].cbUserStatus < US_SIT){
  98. str = 'online';
  99. }else {
  100. str = 'paly';
  101. }
  102. cc.gPreLoader.LoadRes('Image_ClubInviteUserList_'+str,'GamePublic_3',function (spriteFrame) {
  103. this.m_Status.spriteFrame = spriteFrame;
  104. }.bind(this));
  105. this.$('BtInvite').active = (ParaArr[0].cbUserStatus< US_SIT && ParaArr[0].cbInvite == 0);
  106. var userInofr = window.gClubClientKernel.OnGetInviteUser(this._UserID);
  107. var nowTime = new Date().getTime();
  108. if(userInofr && (nowTime - userInofr.inviteTime)<10000)
  109. {
  110. this._time = 10-Math.round((nowTime - userInofr.inviteTime)/1000);
  111. this.OnCountdownPre();
  112. }
  113. else{
  114. this._btInvite.interactable = true;
  115. }
  116. },
  117. OnClick_Invite:function(){
  118. if(this._Status >= US_SIT ||this._bInvite ==1) return;
  119. if(this._btInvite.interactable == false) return;
  120. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  121. window.gClubClientKernel.OnSendInviteUser(this.m_Hook._roomInfor.m_dwClubID,this._UserID,pGlobalUserData.dwUserID,GameDef.KIND_ID,this.m_Hook._roomInfor.m_dwRoomID,);
  122. var userInofr = window.gClubClientKernel.OnGetInviteUser(this._UserID);
  123. if(userInofr) userInofr.inviteTime = new Date().getTime();
  124. this._time = 10;
  125. this.OnCountdownPre();
  126. },
  127. OnCountdownPre:function(){
  128. this._LabTime.string = this._time+'s';
  129. this._LabTime.node.active = true;
  130. this._btInvite.interactable = false;
  131. this.schedule(this.UpdateTimePre,1.0);
  132. },
  133. UpdateTimePre:function(){
  134. if(this._time<=0){
  135. this._LabTime.string = '';
  136. this._btInvite.interactable = true;
  137. this._LabTime.node.active = false;
  138. this.unschedule(this.UpdateTimePre);
  139. return;
  140. }
  141. this._time--;
  142. this._LabTime.string = this._time+'s';
  143. }
  144. });