GameRecord.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. m_NoRecordNode:cc.Node,
  5. m_InputNode:cc.Node,
  6. m_EdInput:cc.EditBox,
  7. },
  8. ctor:function(){
  9. this._KindID = 21201;
  10. this._page = 1;
  11. this._totalPage = 1;
  12. this._day = 0;
  13. },
  14. OnShowView:function() {
  15. this.m_NoRecordNode.active = true;
  16. if(this.m_ListCtrl == null) {
  17. this.m_ListCtrl = this.node.getComponent('CustomListCtrl');
  18. this.m_ListCtrl.InitList(2, 'GameTag', this);
  19. for(var i in window.GameList){
  20. this.m_ListCtrl.InsertListInfo(2, [i,window.GameList[i],i==this._KindID]);
  21. }
  22. }
  23. this.$('LookRePlay@InputReplayCode').SetHook(this);
  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. update:function(){
  34. if( this.m_bNeedUpdate )this.m_bNeedUpdate = false;
  35. else return;
  36. if(!this._filter) return;
  37. this.m_ListCtrl.InitList(0, 'RecordPrefab', this);
  38. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  39. var webUrl = window.PHP_HOME+'/GameRecord.php?&GetMark=2&dwUserID='+pGlobalUserData.dwUserID;
  40. webUrl+="&ClubID=0";
  41. webUrl += `&start=${(this._page - 1) * window.PAGE_ITEM_CNT + 1}`;
  42. webUrl += `&end=${(this._page) * window.PAGE_ITEM_CNT}`;
  43. webUrl += `&KindID=${this._KindID}`;
  44. webUrl += `&day=${this._day}`;
  45. this.m_NoRecordNode.active = true;
  46. WebCenter.GetData(webUrl, 30, function (data) {
  47. g_Lobby.StopLoading();
  48. if(data == "" )return;
  49. var Res = JSON.parse(data);
  50. if (Res.length > 0) this._totalPage = Math.ceil(Res[0][2] / window.PAGE_ITEM_CNT);
  51. else this._totalPage = 1;
  52. this._filter.SetPageTotalCnt(this._totalPage,this._page);
  53. if(Res.length == 0) return;
  54. this.m_NoRecordNode.active = false;
  55. var infoArr = [];
  56. for(var i in Res) infoArr.push([Res[i][0],Res[i][1]]);;
  57. this.SetItemInfo(infoArr);
  58. }.bind(this));
  59. },
  60. // OnHideView:function(){
  61. // HideN2S(this.node);
  62. // },
  63. SetItemInfo:function(IDArr) {
  64. this.m_NoRecordNode.active = false;
  65. for (var i in IDArr ) {
  66. this.m_ListCtrl.InsertListInfo(0, [parseInt(i)+1, IDArr[i]]);
  67. }
  68. },
  69. OnRePlayGame:function( RecordID, KindID, Progress){
  70. if(Progress == null) Progress = 0;
  71. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  72. this.m_Hook.OnRePlayGame(RecordID, KindID, pGlobalUserData, Progress);
  73. },
  74. OnBtShowReplay:function(){
  75. //解析
  76. var RelayID = this.m_EdInput.string;
  77. if(RelayID.indexOf('z') < 0) return this.ShowTips('無效的ID!');
  78. var Arr = RelayID.split('z');
  79. for(var i in Arr) Arr[i] = parseInt(Arr[i], 35);
  80. if(Arr[1] == null || Arr[2] == null || window.GameList[Arr[1]] == null) return this.ShowTips('無效的ID!');
  81. var UserInfo = new Object();
  82. UserInfo.dwUserID = Arr[2]
  83. this.m_Hook.OnRePlayGame(Arr[0], Arr[1], UserInfo);
  84. this.m_InputNode.active = false;
  85. },
  86. OnBtShowInput:function( ){
  87. if(this.m_InputNode.active){
  88. HideN2S(this.m_InputNode)
  89. }else{
  90. this.$('NoClick',this.m_InputNode).setContentSize(10000, 10000);
  91. ShowS2N(this.m_InputNode);
  92. }
  93. },
  94. //update:function(){},
  95. OnShowGameInfoAll:function(RecordID, KindID, ScoreArr){
  96. //显示节点
  97. this.$('RecordInfo').active = true;
  98. //初始化列表
  99. this.$('RecordInfo/ScrollView@ScrollView').scrollToTop(0)
  100. if(this.m_ListCtrl == null) this.m_ListCtrl = this.node.getComponent('CustomListCtrl');
  101. this.m_ListCtrl.InitList(1, 'RecordInfoItem', this);
  102. //加载信息
  103. g_Lobby.ShowLoading();
  104. var webUrl = window.PHP_HOME+'/GameRecord.php?&GetMark=4&RecordID='+RecordID;
  105. WebCenter.GetData(webUrl, 30, function (data) {
  106. g_Lobby.StopLoading();
  107. if(data == "")return;
  108. var Arr = JSON.parse(data);
  109. for(var i in Arr){
  110. this.m_ListCtrl.InsertListInfo(1, [KindID, RecordID, parseInt(i)+1, Arr[i]]);//0 Kind 1 RecordID 2 index 3 info
  111. }
  112. }.bind(this));
  113. },
  114. OnClick_HideInfoAll:function(){
  115. this.$('RecordInfo').active = false;
  116. },
  117. OnClick_ToggleGame:function(_,Data){
  118. this._KindID = Data;
  119. this._page = 1;
  120. this.m_bNeedUpdate = true;
  121. //todo
  122. },
  123. });