ClubGameRecord.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. m_InputNode:cc.Node,
  5. },
  6. ctor:function(){
  7. this._KindID = 21201;
  8. this._type = 0;
  9. this._page = 1;
  10. this._totalPage = 1;
  11. this._day = 0;
  12. },
  13. OnShowView:function() {
  14. this.m_bNeedUpdate = true;
  15. this.$('RecordInfo').active = false;
  16. this.$('LookRePlay@ClubInputReplayCode').SetHook(this);
  17. if(this.m_ListCtrl == null) {
  18. this.m_ListCtrl = this.node.getComponent('CustomListCtrl');
  19. this.m_ListCtrl.InitList(2, 'GameTag', this);
  20. for(var i in window.GameList){
  21. this.m_ListCtrl.InsertListInfo(2, [i,window.GameList[i],i==this._KindID]);
  22. }
  23. }
  24. this.ShowPrefabDLG('FilterNode',this.node,function(Js){
  25. this._filter = Js;
  26. this._filter.SetMode(FILTER_MENU_PAGE|FILTER_MENU_DAY,function(o){
  27. this._day = o.d;
  28. this._page = o.p;
  29. this.m_bNeedUpdate = true;
  30. }.bind(this),cc.Vec2(510,-330));
  31. }.bind(this));
  32. },
  33. OnRePlayGame:function( RecordID, KindID, Progress){
  34. if(Progress == null) Progress = 0;
  35. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  36. this.m_Hook.OnRePlayGame(RecordID, KindID, pGlobalUserData, Progress);
  37. },
  38. OnBtShowInput:function( ){
  39. if(this.m_InputNode.active){
  40. HideN2S(this.m_InputNode)
  41. }else{
  42. this.$('NoClick',this.m_InputNode).setContentSize(10000, 10000);
  43. ShowS2N(this.m_InputNode);
  44. }
  45. },
  46. OnShowGameInfoAll:function(RecordID, KindID){
  47. //显示节点
  48. this.$('RecordInfo').active = true;
  49. this._filter.node.active = false;
  50. //初始化列表
  51. this.$('RecordInfo/ScrollView@ScrollView').scrollToTop( 0)
  52. if(this.m_ListCtrl == null) this.m_ListCtrl = this.node.getComponent('CustomListCtrl');
  53. this.m_ListCtrl.InitList(1, 'ClubRecordInfoItem', this);
  54. //加载信息
  55. g_Lobby.ShowLoading();
  56. var webUrl = window.PHP_HOME+'/GameRecord.php?&GetMark=4&RecordID='+RecordID;
  57. WebCenter.GetData(webUrl, 30, function (data) {
  58. g_Lobby.StopLoading();
  59. if(data == "")return;
  60. var Arr = JSON.parse(data);
  61. var infoArr=[];
  62. for(var i in Arr){
  63. infoArr.push([KindID, RecordID, parseInt(i)+1, Arr[i]]);
  64. //this.m_ListCtrl.InsertListInfo(1, [KindID, RecordID, parseInt(i)+1, Arr[i]]);//0 Kind 1 RecordID 2 index 3 info
  65. }
  66. this.m_ListCtrl.InsertListInfoArr(1,infoArr);
  67. }.bind(this));
  68. },
  69. OnClick_HideInfoAll:function(){
  70. this.$('RecordInfo').active = false;
  71. this._filter.node.active = true;
  72. },
  73. OnClick_Toggle:function(event){
  74. if(event.target.name == 'toggle1')this._type = 0; else this._type = 1;
  75. this.m_bNeedUpdate = true;
  76. },
  77. OnClick_ToggleGame:function(_,Data){
  78. this.m_bNeedUpdate = true;
  79. this._KindID = Data;
  80. this._page = 1;
  81. //todo
  82. },
  83. update:function(){
  84. if( this.m_bNeedUpdate )this.m_bNeedUpdate = false;
  85. else return;
  86. if(!this._filter) return ;
  87. if(this._type == 1&& this.m_Hook.m_SelClubInfo.cbClubLevel < CLUB_LEVEL_MANAGER){
  88. this.$('ToggleContainer/toggle1@Toggle').check();
  89. return this.m_Hook.ShowTips('許可權不足,無法查看全部戰績!')
  90. }
  91. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  92. var Club=this.m_Hook.m_SelClubInfo.dwClubID;
  93. var webUrl = window.PHP_HOME+'/GameRecord.php?&GetMark=10&dwUserID='+pGlobalUserData.dwUserID;
  94. webUrl+="&ClubID="+Club;
  95. webUrl += `&start=${(this._page - 1) * window.PAGE_ITEM_CNT + 1}`;
  96. webUrl += `&end=${(this._page) * window.PAGE_ITEM_CNT}`;
  97. webUrl += `&KindID=${this._KindID}`;
  98. webUrl += `&type=${this._type}`;
  99. webUrl += `&day=${this._day}`;
  100. this.$('NdNoRecord').active= true;
  101. if(this.m_ListCtrl == null) this.m_ListCtrl = this.node.getComponent('CustomListCtrl');
  102. this.m_ListCtrl.InitList(0, 'ClubRecordPrefab', this);
  103. WebCenter.GetData(webUrl, 30, function (data) {
  104. g_Lobby.StopLoading();
  105. if(data == "")return;
  106. var Res = JSON.parse(data);
  107. if (Res.length > 0) this._totalPage = Math.ceil(Res[0][2] / window.PAGE_ITEM_CNT);
  108. else this._totalPage = 1;
  109. this._filter.SetPageTotalCnt(this._totalPage,this._page);
  110. if(Res.length == 0) return;
  111. this.$('NdNoRecord').active = false;
  112. var infoArr=[];
  113. for(var i in Res){
  114. infoArr.push([Res[i][0],Res[i][1]]);
  115. //this.m_ListCtrl.InsertListInfo(0, [parseInt(i)+1, Arr[i], bShowSelf]);
  116. }
  117. this.m_ListCtrl.InsertListInfoArr(0,infoArr);
  118. }.bind(this));
  119. },
  120. });