ClubScoreRecord.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. m_NdSubView:cc.Node,
  5. },
  6. ctor:function () {
  7. this.m_ScoreCnt = 0;
  8. this.m_PoolCnt = 0;
  9. this.m_Psw = '';
  10. this._page = 1;
  11. this._totalPage = 1;
  12. this._day = 0;// 0- 今天 1- 昨天 2- 前天
  13. this._searchID = 0;
  14. this._type = 0; // 0- 收取, 1 增加
  15. this._tagIndex = 0;
  16. },
  17. OnShowView:function () {
  18. if(this.m_ListCtrl == null) this.m_ListCtrl = this.$('@CustomListCtrl');
  19. this.m_ListCtrl.InitList(0, 'ClubScoreRecordPre', this);
  20. this.m_ListCtrl.InitList(1, 'ClubScoreBankRecord', this);
  21. if(this.m_ToggleArr == null){
  22. this.m_ToggleArr = this.node.getComponentsInChildren(cc.Toggle);
  23. }
  24. this._searchNode = this.$('SearchNode');
  25. this.OnUpdateView();
  26. this.$('SearchNode/BtSearch').active = true;
  27. this.$('SearchNode/BtBack').active = false;
  28. this.$('SearchNode/IDEditBox@EditBox').string = '';
  29. this.$('ScrollView/ScrollView3/EdOldPsw@EditBox').string = '';
  30. this.$('ScrollView/ScrollView3/EdNewPsw@EditBox').string = '';
  31. this.$('ScrollView/ScrollView3/EdNewPsw1@EditBox').string = '';
  32. this.$('NdSetPsw/EdPsw1@EditBox').string = '';
  33. this.$('Take&Save/EdCnt@EditBox').string = '';
  34. this.ShowPrefabDLG('FilterNode',this.node,function(Js){
  35. this._filter = Js;
  36. this._filter.SetMode(this._tagIndex == 1?FILTER_MENU_PAGE:FILTER_MENU_PAGE|FILTER_MENU_DAY|FILTER_MENU_KIND,function(o){
  37. this._day = o.d;
  38. this._page = o.p;
  39. this._type = o.k;
  40. this.m_bNeedUpdate = true;
  41. }.bind(this),cc.Vec2(510,-330));
  42. }.bind(this));
  43. },
  44. OnUpdateView:function () {
  45. for(var i=0;i<this.m_ToggleArr.length;i++){
  46. if(this.m_ToggleArr[i].isChecked) {
  47. this.m_ToggleArr[i].isChecked = false;
  48. this.m_ToggleArr[i].check();
  49. }
  50. }
  51. },
  52. OnCheckChange:function (_, Data) {
  53. this._page = 1;
  54. this.m_bNeedUpdate = true;
  55. },
  56. ShowUserScoreInfo:function (UseID, View) {
  57. this.m_Hook.ShowUserScoreInfo(UseID, View)
  58. this.HideView();
  59. },
  60. OnTakeUserAllScore:function (UseID, Score) {
  61. if(Score>0) {
  62. this.ShowAlert('確認清楚玩家積分?',Alert_YesNo, function(Res) {
  63. if(Res) {
  64. this.m_Hook.OnTakeScore(UseID, 1, Score);
  65. this.HideView();
  66. }
  67. }.bind(this));
  68. }else{
  69. return this.m_Hook.ShowTips('輸入金額錯誤!');
  70. }
  71. },
  72. update:function(){
  73. if( this.m_bNeedUpdate ){
  74. this.m_bNeedUpdate = false;
  75. }else{
  76. return;
  77. }
  78. if(!this._filter) return;
  79. var RandType = 0;
  80. for (var i = 0; i < 5; i++) {
  81. if (this.$('Toggle/' + i + '@Toggle').isChecked) RandType = i;
  82. }
  83. var ShowName = 'ScrollView'+RandType;
  84. for(var i = 0;i<this.m_NdSubView.childrenCount; i++ ){
  85. this.m_NdSubView.children[i].active = (this.m_NdSubView.children[i].name == ShowName);
  86. }
  87. if(RandType == 3){
  88. this.$('ScrollView/'+ShowName+'/EdOldPsw@EditBox').string = '';
  89. this.$('ScrollView/'+ShowName+'/EdNewPsw@EditBox').string = '';
  90. this.$('ScrollView/'+ShowName+'/EdNewPsw1@EditBox').string = '';
  91. }
  92. if(RandType == 4){
  93. this.$('ScrollView/'+ShowName+'/Edit1@EditBox').string = '';
  94. this.$('ScrollView/'+ShowName+'/Edit2@EditBox').string = '';
  95. this.$('ScrollView/'+ShowName+'/Edit3@EditBox').string = '';
  96. }
  97. this.$('NdSetPsw').active = false;
  98. this.m_ListCtrl.InitList(0, 'ClubScoreBankRecord', this);
  99. this.m_ListCtrl.InitList(1, 'ClubScoreRecordPre', this);
  100. this._filter.node.active = RandType ==1 || RandType == 2;
  101. if(RandType != this._tagIndex) this._filter.SetMode1(RandType == 1?FILTER_MENU_PAGE:FILTER_MENU_PAGE|FILTER_MENU_DAY|FILTER_MENU_KIND);
  102. this._tagIndex = RandType;
  103. this._searchNode.active = RandType == 2;
  104. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  105. //俱乐部银行
  106. if(RandType == 0){
  107. var webUrl = window.PHP_HOME+'/League.php?GetMark=51&dwUserID='+pGlobalUserData.dwUserID;
  108. webUrl += '&ClubID='+this.m_Hook.m_SelClubInfo.dwClubID;
  109. WebCenter.GetData(webUrl, 0, function (data) {
  110. var Info = JSON.parse(data);
  111. this.$('ScrollView/ScrollView0/LbScore@Label').string = Score2Str(parseInt(Info[1]));
  112. this.$('ScrollView/ScrollView0/LbBank@Label').string = Score2Str(parseInt(Info[2]));
  113. this.m_ScoreCnt = Score2Str(parseInt(Info[1]));
  114. this.m_PoolCnt = Score2Str(parseInt(Info[2]));
  115. }.bind(this));
  116. }
  117. //俱乐部银行
  118. if(RandType == 1){
  119. var webUrl = window.PHP_HOME+'/League.php?GetMark=55&dwUserID='+pGlobalUserData.dwUserID;
  120. webUrl += '&ClubID='+this.m_Hook.m_SelClubInfo.dwClubID;
  121. webUrl += `&start=${(this._page - 1) * window.PAGE_ITEM_CNT + 1}`;
  122. webUrl += `&end=${(this._page) * window.PAGE_ITEM_CNT}`;
  123. WebCenter.GetData(webUrl, null, function (data) {
  124. var Info = JSON.parse(data);
  125. //for(var i in Info) this.m_ListCtrl.InsertListInfo(0, Info[i]);
  126. if (Info.length > 0) this._totalPage = Math.ceil(Info[0][2] / window.PAGE_ITEM_CNT);
  127. else this._totalPage = 1;
  128. this._filter.SetPageTotalCnt(this._totalPage,this._page);
  129. if(Info.length > 0)this.m_ListCtrl.InsertListInfoArr(0,Info);
  130. }.bind(this));
  131. }
  132. //俱乐部银行
  133. if(RandType == 2){
  134. var webUrl = window.PHP_HOME+'/League.php?GetMark=136&dwUserID='+pGlobalUserData.dwUserID;
  135. webUrl += '&ClubID='+this.m_Hook.m_SelClubInfo.dwClubID;
  136. webUrl += `&start=${(this._page - 1) * window.PAGE_ITEM_CNT + 1}`;
  137. webUrl += `&end=${(this._page) * window.PAGE_ITEM_CNT}`;
  138. webUrl += `&day=${this._day}`;
  139. webUrl += `&searchID=${this._searchID}`;
  140. webUrl += `&type=${this._type}`;
  141. WebCenter.GetData(webUrl, null, function (data) {
  142. var Info = JSON.parse(data);
  143. if (Info.length > 0) this._totalPage = Math.ceil(Info[0][9] / window.PAGE_ITEM_CNT);
  144. else this._totalPage = 1;
  145. this._filter.SetPageTotalCnt(this._totalPage,this._page);
  146. //for(var i in Info) this.m_ListCtrl.InsertListInfo(1, Info[i]);
  147. if(Info.length > 0)this.m_ListCtrl.InsertListInfoArr(1,Info);
  148. }.bind(this));
  149. }
  150. },
  151. GetSelUserStr:function(){
  152. if(this.m_EdUserFind && this.m_EdUserFind.node.active){
  153. return this.m_EdUserFind.string;
  154. }
  155. return "";
  156. },
  157. SetClubList: function(UserMap){
  158. var findStr = this.GetSelUserStr();
  159. var bShowFullID = this.m_Hook.m_SelClubInfo.cbClubLevel>=CLUB_LEVEL_MANAGER || (this.m_Hook.m_SelClubInfo.dwRules & this.HIDE_ID) == 0 ;
  160. for(var Lv = CLUB_LEVEL_OWNER; Lv >= CLUB_LEVEL_MEMBER; Lv--){
  161. for(var i in UserMap){
  162. if(i == 'Revenue' || i == 'ARevenue') continue
  163. if(Lv != UserMap[i][1]) continue;
  164. var UserID = UserMap[i][0];
  165. if(findStr != '' && g_GlobalUserInfo.m_UserInfoMap[UserID] != null){
  166. var Name = g_GlobalUserInfo.m_UserInfoMap[UserID].NickName;
  167. var ID = g_GlobalUserInfo.m_UserInfoMap[UserID].GameID+'';
  168. if(Name.indexOf(findStr) < 0 && ID.indexOf(findStr) < 0) continue
  169. }
  170. this.m_ListCtrl.InsertListInfo(1, [i, UserID, UserMap[i][1], UserMap[i][2], bShowFullID]);
  171. }
  172. }
  173. },
  174. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  175. //银行功能
  176. OnClick_Save:function(){
  177. this.m_type = 0;
  178. this.$('Take&Save').active = true;
  179. cc.gPreLoader.LoadRes('Image_ClubScoreRecord_T-chunjifen','Club',function (spriteFrame) {
  180. this.$('Take&Save/BGM/TPsw@Sprite').spriteFrame = spriteFrame;
  181. }.bind(this));
  182. this.$('Take&Save/ScoreCnt@Label').string = '當前積分:'+this.m_ScoreCnt;
  183. this.$('Take&Save/PoolCnt@Label').string = '積分池積分:'+this.m_PoolCnt;
  184. this.$('Take&Save/Label@Label').string = '存入:';
  185. this.$('Take&Save/EdCnt/PLACEHOLDER_LABEL@Label').string = '輸入要存入的積分數';
  186. this.$('Take&Save/EdCnt/TEXT_LABEL@Label').string = '輸入要存入的積分數';
  187. },
  188. //取
  189. OnClick_Take:function(){
  190. this.m_type = 1;
  191. this.$('Take&Save').active = true;
  192. cc.gPreLoader.LoadRes('Image_ClubScoreRecord_T-qujifen','Club',function (spriteFrame) {
  193. this.$('Take&Save/BGM/TPsw@Sprite').spriteFrame = spriteFrame;
  194. }.bind(this));
  195. this.$('Take&Save/ScoreCnt@Label').string = '當前積分:'+this.m_ScoreCnt;
  196. this.$('Take&Save/PoolCnt@Label').string = '積分池:'+this.m_PoolCnt;
  197. this.$('Take&Save/Label@Label').string = '取出:';
  198. this.$('Take&Save/EdCnt@EditBox').Placeholder = '輸入要取出的積分數';
  199. this.$('Take&Save/EdCnt/PLACEHOLDER_LABEL@Label').string = '輸入要取出的積分數';
  200. this.$('Take&Save/EdCnt/TEXT_LABEL@Label').string = '輸入要取出的積分數';
  201. },
  202. //首次设置银行密码
  203. OnClick_SetPsw:function(){
  204. var OldPsw = this.$('ScrollView/ScrollView3/EdOldPsw@EditBox').string;
  205. var NewPsw1 = this.$('ScrollView/ScrollView3/EdNewPsw@EditBox').string;
  206. var NewPsw2 = this.$('ScrollView/ScrollView3/EdNewPsw1@EditBox').string;
  207. if(NewPsw1!=NewPsw2) return this.ShowTips('請輸入相同的密碼!')
  208. if(NewPsw1.length!=6) return this.ShowTips('請輸入6比特密碼!')
  209. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  210. var webUrl = window.PHP_HOME+'/League.php?GetMark=54&dwUserID='+pGlobalUserData.dwUserID;
  211. webUrl += '&LogonPsw='+pGlobalUserData.szPassword;
  212. webUrl += '&ClubID='+this.m_Hook.m_SelClubInfo.dwClubID;
  213. webUrl += '&NewPsw='+hex_md5(NewPsw1);
  214. webUrl += '&OldPsw='+hex_md5(OldPsw);
  215. WebCenter.GetData(webUrl, null, function (data) {
  216. var Info = JSON.parse(data);
  217. this.ShowAlert(Info[1]);
  218. if(Info[0]==0){
  219. CLUB_SCORE_LOGON_PSW = NewPsw1;
  220. this.OnUpdateView();
  221. }
  222. }.bind(this));
  223. },
  224. OnClick_BtSend:function(){
  225. var EdGameID = this.$('ScrollView/ScrollView4/Edit1@EditBox');
  226. var EdScore = this.$('ScrollView/ScrollView4/Edit2@EditBox');
  227. var EdRemark = this.$('ScrollView/ScrollView4/Edit3@EditBox');
  228. var GameID = parseInt(EdGameID.string);
  229. if( GameID > 100000 && GameID < 1000000){ } else { return this.ShowTips('請輸入有效ID') };
  230. var SendScore = Number(EdScore.string);
  231. if(SendScore > 0) { } else { return this.ShowTips('請輸入有效數量') };
  232. var webUrl = window.PHP_HOME+'/UserFunc.php?GetMark=13&dwGameID='+GameID;
  233. WebCenter.GetData(webUrl, null, function (data) {
  234. var UserInfo = JSON.parse(data);
  235. if(UserInfo.UserID == null){
  236. return this.ShowTips('用戶査詢失敗');
  237. }else{
  238. this.OnSureDo(UserInfo.UserID, SendScore, UserInfo.NickName,EdRemark.string);
  239. }
  240. }.bind(this));
  241. },
  242. OnSureDo:function(UserID, Score, Nick,Remark){
  243. this.ShowAlert('確定贈送【'+Nick+'】 '+ Score+' 積分?', Alert_YesNo, function(Res) {
  244. if(Res) {
  245. this.m_Hook.OnGiveScore(UserID, 1, Score,Remark);
  246. this.HideView();
  247. }
  248. }.bind(this) )
  249. },
  250. //隐藏设置密码界面
  251. OnClick_SetPswHideView:function(){
  252. this.$('Toggle/3@Toggle').check();
  253. },
  254. //隐藏设置密码界面
  255. OnClick_SetTakeAndSaveHideView:function(){
  256. this.$('Take&Save').active = false;
  257. },
  258. OnClick_Sure:function(){
  259. this.$('Take&Save').active = false;
  260. var Score = Number (this.$('Take&Save/EdCnt@EditBox').string);
  261. if(Score <= 0||Score==NaN){
  262. this.ShowTips('請輸入有效數值!');
  263. return;
  264. }
  265. this.$('Take&Save/EdCnt@EditBox').string = '';
  266. //Score = Score * window.PLATFORM_RATIO;
  267. Score = parseFloat((Score*window.PLATFORM_RATIO).toPrecision(12));//window.PLATFORM_RATIO;
  268. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  269. var webUrl = window.PHP_HOME+'/League.php?GetMark='+(this.m_type == 0?52:53)+'&dwUserID='+pGlobalUserData.dwUserID;
  270. webUrl += '&Score='+Score;
  271. webUrl += '&ClubID='+this.m_Hook.m_SelClubInfo.dwClubID;
  272. webUrl += '&Psw='+hex_md5(CLUB_SCORE_LOGON_PSW);
  273. WebCenter.GetData(webUrl, null, function (data) {
  274. var Info = JSON.parse(data);
  275. //this.ShowAlert(Info[1]);
  276. this.ShowTips(Info[1]);
  277. if(Info[0]==0){
  278. this.OnUpdateView();
  279. this.m_Hook.UpdateScore(this.m_type == 0?-Score:Score);
  280. }
  281. this.m_Hook.OnClick_BtUpdate();
  282. }.bind(this));
  283. },
  284. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  285. OnClick_CloseSearch:function(){
  286. this.$('SearchNode/IDEditBox@EditBox').string = '';
  287. this._searchID = 0;
  288. this.$('SearchNode/BtSearch').active = true;
  289. this.$('SearchNode/BtBack').active = false;
  290. this.OnCheckChange(null, 2);
  291. },
  292. OnClick_Search:function(){
  293. var strGameID = this.$('SearchNode/IDEditBox@EditBox').string;
  294. if(strGameID.length < 6) {
  295. this.ShowTips('ID格式錯誤');
  296. return;
  297. }
  298. this._searchID = parseInt(strGameID);
  299. this._page = 1;
  300. this.$('SearchNode/BtSearch').active = false;
  301. this.$('SearchNode/BtBack').active = true;
  302. this.OnCheckChange(null, 2);
  303. },
  304. });