ClubRank.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. },
  5. ctor:function(){
  6. this.m_bNeedUpdate = false;
  7. this._first = false;
  8. this._bLimit = false;
  9. this._page = 1;
  10. this._totalPage = 1;
  11. this._kind = 0;//0 -增加 1- 减少
  12. this._day = 0;// 0- 今天 1- 昨天 2- 前天
  13. this._searchID = 0;
  14. this._bSearch = false;
  15. },
  16. OnShowView:function(){
  17. this._first = true;
  18. if(this.m_ListCtrl == null) this.m_ListCtrl = this.$('@CustomListCtrl');
  19. this.m_InputNum = this.$('UpdateUserScore/BGM/InputNum@Label');
  20. // if(this.m_SelfCtrl == null) this.m_SelfCtrl = this.$('BottomBG/ClubRankPre@ClubRankPre');
  21. this.$('BGB/Type/0').active = this.m_Hook.m_SelClubInfo.wKindID > CLUB_KIND_0;
  22. this.$('BGB/Type/1').active = this.m_Hook.m_SelClubInfo.wKindID > CLUB_KIND_0;
  23. this.$('BGB/Type/4').active = this.m_Hook.m_SelClubInfo.wKindID > CLUB_KIND_0;
  24. this.$('UpdateUserScore').active = false;
  25. var webUrl = window.PHP_HOME+'/League.php?GetMark=137&ClubID='+this.m_Hook.m_SelClubInfo.dwClubID;
  26. WebCenter.GetData(webUrl, 1, function (data) {
  27. var Res = JSON.parse(data);
  28. if((Res['Rules'] & this.m_Hook.SHOW_RANK) == 0 &&this.m_Hook.m_SelClubInfo.cbClubLevel<CLUB_LEVEL_MANAGER){
  29. this._bLimit = true;
  30. }
  31. if(this.m_Hook.m_SelClubInfo.wKindID == CLUB_KIND_0){
  32. this.$('BGB/Type/2@Toggle').check();
  33. }else{
  34. this.$('BGB/Type/0@Toggle').check();
  35. }
  36. }.bind(this));
  37. var imgName = this.m_Hook.m_SelClubInfo.wKindID > CLUB_KIND_0?'TRank':'T-paihangbang';
  38. cc.gPreLoader.LoadRes('Image_ClubRank_'+imgName,'Club',function(sprFrame){
  39. this.$('topBG/LabRank@Sprite').spriteFrame = sprFrame;
  40. }.bind(this));
  41. this.ShowPrefabDLG('FilterNode',this.node,function(Js){
  42. this._filter = Js;
  43. this._filter.SetMode(FILTER_MENU_PAGE,function(o){
  44. this._day = o.d;
  45. this._kind = o.t;//0 -增加 1- 减少
  46. this._page = o.p;
  47. this.m_bNeedUpdate = true;
  48. }.bind(this),cc.Vec2(510,-330));
  49. }.bind(this));
  50. },
  51. OnToggleClick:function(Tag){
  52. if(this._first == false)cc.gSoundRes.PlaySound('Button');
  53. this.ShowPrefabDLG('CustomLoading', this.node, function (Js) {
  54. this.m_DlgLoading = Js;
  55. this.m_DlgLoading.SetWorkStr('加載中');
  56. setTimeout(function() {
  57. this.m_DlgLoading.HideView();
  58. }.bind(this), 1000);
  59. }.bind(this));
  60. this._first = false;
  61. this._page = 1;
  62. this._searchID = 0;
  63. this.m_bNeedUpdate = true;
  64. },
  65. update:function(){
  66. if( this.m_bNeedUpdate ){
  67. this.m_bNeedUpdate = false;
  68. }else{
  69. return;
  70. }
  71. if(!this._filter) return;
  72. for(var i=0;i<6;i++){
  73. this.$(`${i}`).active = false;
  74. }
  75. var RandType = 0;
  76. for(var i=0;i<6;i++){
  77. if(this.$('BGB/Type/'+i+'@Toggle').isChecked) RandType = i;
  78. }
  79. this._filter.node.active = RandType != 4;
  80. this._RandType = RandType;
  81. if(RandType == 2|| RandType == 3){
  82. this.$('LabLimit').active = this._bLimit;
  83. if(this._bLimit) return;
  84. }else{
  85. this.$('LabLimit').active = false;
  86. }
  87. //this.$('BTBack').active = !this._bLimit;
  88. this.$(`${RandType}`).active = true;
  89. this.m_ListCtrl.InitList(RandType, 'ClubRankPre');
  90. var webUrl = '';
  91. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  92. //上下分日志
  93. if(RandType == 0){
  94. webUrl = window.PHP_HOME+'/League.php?GetMark=60&dwUserID='+pGlobalUserData.dwUserID+'&dwClubID='+this.m_Hook.m_SelClubInfo.dwClubID;
  95. }else if(RandType == 1){
  96. webUrl = window.PHP_HOME+ '/League.php?GetMark=13&ClubID='+this.m_Hook.m_SelClubInfo.dwClubID+'&dwUserID='+pGlobalUserData.dwUserID;
  97. webUrl += `&kind=${this._kind}`;
  98. webUrl += `&day=${this._day}`;
  99. }else if(RandType == 2){
  100. if((this.m_Hook.m_SelClubInfo.dwRules & CLUB_SET_RULE_0) == 0 &&this.m_Hook.m_SelClubInfo.cbClubLevel < CLUB_LEVEL_MANAGER){
  101. return ;
  102. }
  103. webUrl = window.PHP_HOME+ '/League.php?GetMark=8&dwUserID='+pGlobalUserData.dwUserID+'&ClubID='+this.m_Hook.m_SelClubInfo.dwClubID+'&RandType=3&TimeType=200';
  104. }
  105. else if(RandType == 3){
  106. if((this.m_Hook.m_SelClubInfo.dwRules & CLUB_SET_RULE_0) == 0 &&this.m_Hook.m_SelClubInfo.cbClubLevel < CLUB_LEVEL_MANAGER){
  107. return ;
  108. }
  109. webUrl = window.PHP_HOME+ '/League.php?GetMark=8&dwUserID='+pGlobalUserData.dwUserID+'&ClubID='+this.m_Hook.m_SelClubInfo.dwClubID+'&RandType=0&TimeType=200';
  110. }
  111. else if(RandType == 4){
  112. webUrl = window.PHP_HOME+'/League.php?GetMark=112&dwUserID='+pGlobalUserData.dwUserID+'&ClubID='+this.m_Hook.m_SelClubInfo.dwClubID;
  113. }
  114. else if(RandType == 5){
  115. webUrl = window.PHP_HOME+'/League.php?GetMark=117&ClubID='+this.m_Hook.m_SelClubInfo.dwClubID;
  116. }
  117. if(RandType != 4)
  118. {
  119. webUrl += `&start=${(this._page - 1) * window.PAGE_ITEM_CNT + 1}`;
  120. webUrl += `&end=${(this._page) * window.PAGE_ITEM_CNT}`;
  121. webUrl += `&searchID=${this._searchID}`;
  122. }
  123. WebCenter.GetData(webUrl, 1, function (data) {
  124. this.m_ListCtrl.InitList(RandType, 'ClubRankPre');
  125. var Res = JSON.parse(data);
  126. if(RandType == 4){
  127. this.m_ListCtrl.InsertListInfo(RandType, [0,[Res, RandType, this]]);
  128. }else{
  129. if (RandType == 0) {
  130. if (Res.length > 0) this._totalPage = Math.ceil(Res[0][5] / window.PAGE_ITEM_CNT);else this._totalPage = 1;
  131. this._filter.SetPageTotalCnt(this._totalPage,this._page);
  132. }
  133. if (RandType == 1) {
  134. if (Res.length > 0) this._totalPage = Math.ceil(Res[0][7] / window.PAGE_ITEM_CNT); else this._totalPage = 1;
  135. this._filter.SetPageTotalCnt(this._totalPage,this._page);
  136. }
  137. if (RandType == 2||RandType == 3) {
  138. if (Res.length > 0) this._totalPage = Math.ceil(Res[0][3] / window.PAGE_ITEM_CNT);else this._totalPage = 1;
  139. this._filter.SetPageTotalCnt(this._totalPage,this._page);
  140. }
  141. if (RandType == 5) {
  142. if (Res.length > 0) this._totalPage = Math.ceil(Res[0][8] / window.PAGE_ITEM_CNT);else this._totalPage = 1;
  143. this._filter.SetPageTotalCnt(this._totalPage,this._page);
  144. }
  145. this._inforArr = [];
  146. for(var i=0;i<Res.length;i++){
  147. this._inforArr.push([Res[i], RandType, this]);
  148. //this.m_ListCtrl.InsertListInfo(RandType, [Res[i], RandType, this]);
  149. }
  150. this.m_ListCtrl.InsertListInfoArr(RandType,this._inforArr);
  151. }
  152. }.bind(this));
  153. },
  154. OnBtClickOpenUpdateUserScoreNode:function(dwUserID){
  155. cc.gSoundRes.PlaySound('Button');
  156. this.m_UserID = dwUserID;
  157. this.$('UpdateUserScore').active = true;
  158. this.m_InputNum.string = '';
  159. },
  160. OnBtClickCloseUpdateUserScoreNode:function(Tag, Data){
  161. cc.gSoundRes.PlaySound('Button');
  162. this.m_InputNum.string = '';
  163. this.$('UpdateUserScore').active = false;
  164. },
  165. OnBtClickUpdateUserScoreNum:function(Tag, Data){
  166. cc.gSoundRes.PlaySound('Button');
  167. this.$('UpdateUserScore/BGM/EditBox').active =false;
  168. if(Data == 'Del'){ //删除
  169. if(this.m_InputNum.string.length){
  170. this.m_InputNum.string = this.m_InputNum.string.slice(0,this.m_InputNum.string.length-1)
  171. }
  172. if (this.m_InputNum.string.length <=0) {
  173. this.$('UpdateUserScore/BGM/EditBox').active =true;
  174. }
  175. }else if(Data == 'Retype'){
  176. this.m_InputNum.string = ''
  177. }
  178. else{
  179. if(this.m_InputNum.string.length >= 7) return //0-9
  180. this.m_InputNum.string += Data;
  181. }
  182. },
  183. OnBtClickUpdateUserScoreSure:function(){
  184. cc.gSoundRes.PlaySound('Button');
  185. var Num = this.m_InputNum.string;
  186. var NumArr = Num.split('');
  187. var error = false;
  188. for(var i=1;i<NumArr.length;i++){
  189. if (NumArr[i] == '-') {
  190. error = true;
  191. break;
  192. }
  193. }
  194. if(error) {
  195. this.ShowTips('輸入金額錯誤!');
  196. this.m_InputNum.string = '';
  197. return;
  198. }
  199. this.$('UpdateUserScore').active =false;
  200. var Score = parseInt(Num);
  201. if(Score>0) {
  202. this.m_Hook.OnGiveScore(this.m_UserID, 1, Score);
  203. }else if(Score<0) {
  204. this.m_Hook.OnTakeScore(this.m_UserID, 1,-Score);
  205. }
  206. //this.m_bNeedUpdate = true;
  207. },
  208. OnShowRankDataInfo:function(){
  209. cc.gSoundRes.PlaySound('Button');
  210. this.ShowPrefabDLG('ClubRankDataInfo',this.node,function(Js){
  211. }.bind(this));
  212. },
  213. OnBtSearch: function (_, Data) {
  214. cc.gSoundRes.PlaySound('Button');
  215. var strID = this.$(`${Data}/EdSearch@EditBox`).string;
  216. this.m_type = Data;
  217. if (strID.length < 6) {
  218. this.ShowTips('請輸入正確的ID');
  219. return;
  220. }
  221. this._searchID = parseInt(strID);
  222. this.$('BTBack').active = true;
  223. this.$(`${Data}/BTSearch`).active = false;
  224. this._page = 1;
  225. this.m_bNeedUpdate = true;
  226. },
  227. OnBtBack: function () {
  228. cc.gSoundRes.PlaySound('Button');
  229. this.$('BTBack').active = false;
  230. for (var i = 0; i < 6; i++) {
  231. this.$(`${i}/EdSearch@EditBox`).string = '';
  232. this.$(`${i}/BTSearch`).active = true;
  233. }
  234. this._searchID = 0;
  235. this.m_bNeedUpdate = true;
  236. },
  237. });