ServerHandler.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. /*
  2. * @Author: mojunshou 1637302775@qq.com
  3. * @Date: 2025-04-11 10:16:41
  4. * @LastEditors: mojunshou 1637302775@qq.com
  5. * @LastEditTime: 2025-04-28 11:46:05
  6. * @Description:
  7. */
  8. // ServerHandler.ts
  9. import { smc } from '../SingletonModuleComp';
  10. import { GameEvent } from '../config/GameEvent';
  11. import { oops } from 'db://oops-framework/core/Oops';
  12. import { CocosHandler, CocosHandlerType } from './CocosHandler';
  13. import { ProtocolEvent } from './ProtocolEvent';
  14. import { DCHandler } from './DCHandler';
  15. export class ServerHandler {
  16. private static _inst: ServerHandler;
  17. public static get inst(): ServerHandler {
  18. if (!this._inst) {
  19. this._inst = new ServerHandler();
  20. }
  21. return this._inst;
  22. }
  23. private buildCallback(success: string, fail?: string) {
  24. const callback: any = { onSuccess: success };
  25. if (fail) callback.onFail = fail;
  26. return callback;
  27. }
  28. async sendMsgToServer(param: any) {
  29. const data: CocosHandlerType = {
  30. method: 'request.post',
  31. param: JSON.stringify(param)
  32. };
  33. return await CocosHandler.inst.sendMessageToAndroid(data, '服务器请求');
  34. }
  35. //微信登录
  36. wxLogin(code: string) {
  37. const param = {
  38. url: ProtocolEvent.WechatLogin,
  39. param: {
  40. code: code
  41. },
  42. callback: this.buildCallback('ServerHandler.inst.onWxLoginInfo', 'ServerHandler.inst.onRequestFail')
  43. };
  44. this.sendMsgToServer(param);
  45. }
  46. onWxLoginInfo(str: string) {
  47. console.log('[服务器] 微信登录返回', str);
  48. // let
  49. this.getAccountInfo();
  50. }
  51. getAccountInfo() {
  52. const param = {
  53. url: ProtocolEvent.AccountInfo,
  54. callback: this.buildCallback('ServerHandler.inst.onAccountInfo', 'ServerHandler.inst.onRequestFail')
  55. };
  56. this.sendMsgToServer(param);
  57. }
  58. onAccountInfo(str: string) {
  59. console.log('[服务器] 获取账号信息返回', str);
  60. const data = JSON.parse(str);
  61. const account = smc.account.AccountModel;
  62. const game = smc.game.GameModel;
  63. account.uid = data.uid;
  64. account.accountName = data.nickname;
  65. account.headUrl = data.headImgUrl;
  66. account.isLogined = data.isBand;
  67. account.curLevel = data.currentLevelInfo.level || 0;
  68. game.curScore = data.currentLevelInfo.score || 0;
  69. game.targetScore = data.currentLevelConf.score || 0;
  70. game.curLevelConfig = data.currentLevelConf;
  71. game.costInfo = data.handlingChargeConf;
  72. game.eventType = data.currentLevelConf.eventType || "";
  73. game.popupType = data.currentLevelConf.popupType || "";
  74. account.wxCoin = data.props['1005'];
  75. account.hbCoin = data.props['1004'];
  76. account.goldCoin = data.props['1006'];
  77. game.popupShow = data.currentLevelInfo.popupStatus
  78. game.skipAdConfig = data.currentLevelConf.skipCount || -1;
  79. oops.message.dispatchEvent(GameEvent.UserLogin);
  80. }
  81. getDailyReward(level: number) {
  82. const param = {
  83. url: ProtocolEvent.GetDailyReward,
  84. param: {
  85. level: level
  86. },
  87. callback: this.buildCallback('ServerHandler.inst.onDailyReward', 'ServerHandler.inst.onRequestFail')
  88. };
  89. this.sendMsgToServer(param);
  90. }
  91. onDailyReward(str: string) {
  92. console.log('[服务器] 每日奖励返回', str);
  93. let result = JSON.parse(str);
  94. smc.account.AccountModel.hbCoin = result.props["1004"];
  95. smc.account.AccountModel.xcCount = result.props["1007"]; //消除次数
  96. smc.account.AccountModel.goldCoin = result.props["1006"] //金砖数量
  97. smc.game.GameModel.wxCash = result.money;
  98. //status2在最后1在最前边0排第二
  99. let taskList = result.taskList.sort((a: any, b: any) => {
  100. if (a.status === 1 && b.status !== 1) return -1; // a 在前
  101. })
  102. smc.game.GameModel.taskList = taskList;
  103. oops.message.dispatchEvent(GameEvent.updateRedPackeTaskList);
  104. }
  105. //获取红包页信息
  106. getHbTxInfo() {
  107. const param = {
  108. url: ProtocolEvent.GetHbWithdrawInfo,
  109. callback: this.buildCallback('ServerHandler.inst.onHbTxInfo', 'ServerHandler.instonRequestFail')
  110. };
  111. this.sendMsgToServer(param);
  112. }
  113. onHbTxInfo(str: string) {
  114. console.log('[服务器] 获取红包页面信息返回', str);
  115. let result = JSON.parse(str);
  116. smc.account.AccountModel.hbCoin = result.props["1004"] || 0;
  117. smc.account.AccountModel.xcCount = result.props["1007"] || 0; //消除次数
  118. smc.account.AccountModel.goldCoin = result.props["1006"] || 0; //金砖数量
  119. //要根据taskList的status排序,可领取再在前边,领取完在最后0 进行中 1 可领取 2已经领取
  120. let taskList = result.taskList.sort((a: any, b: any) => {
  121. if (a.status === 1 && b.status !== 1) return -1; // a 在前
  122. })
  123. smc.game.GameModel.taskList = taskList;
  124. smc.game.GameModel.wxCash = result.money;
  125. oops.message.dispatchEvent(GameEvent.openView, "openRedBagView");
  126. }
  127. //获取用户信息
  128. getUserItemInfo() {
  129. const param = {
  130. url: ProtocolEvent.UserItemInfo,
  131. callback: this.buildCallback('ServerHandler.inst.onUserItemInfo', 'ServerHandler.instonRequestFail')
  132. };
  133. this.sendMsgToServer(param);
  134. }
  135. onUserItemInfo(str: string) {
  136. const result = JSON.parse(str);
  137. const props = result.props;
  138. const account = smc.account.AccountModel;
  139. const game = smc.game.GameModel;
  140. account.wxCoin = props['1005'] || 0;
  141. account.hbCoin = props['1004'] || 0;
  142. account.goldCoin = props['1006'] || 0;
  143. game.handlingCharge = props['1009'] || 0;
  144. //返回成功才登录
  145. }
  146. //获取提现记录
  147. getRecordList() {
  148. const param = {
  149. url: ProtocolEvent.GetWithdrawRecord,
  150. param: {
  151. offset: 0,
  152. limit: 10
  153. },
  154. callback: this.buildCallback('ServerHandler.inst.onRecordList', 'ServerHandler.inst.onRequestFail')
  155. };
  156. this.sendMsgToServer(param);
  157. }
  158. //提现列表
  159. onRecordList(str: string) {
  160. console.log('[服务器] 提现列表返回', str);
  161. const result = JSON.parse(str);
  162. if (result.count > 0) {
  163. smc.game.GameModel.recordList = result.list;
  164. }
  165. oops.message.dispatchEvent(GameEvent.openView, "openRecordView");
  166. }
  167. getGameAwardInfo() {
  168. const param = {
  169. url: ProtocolEvent.GetGameAward,
  170. callback: this.buildCallback('ServerHandler.inst.onGameAwardInfo', 'ServerHandler.inst.onRequestFail')
  171. };
  172. this.sendMsgToServer(param);
  173. }
  174. onGameAwardInfo(str: string) {
  175. console.log('[服务器] 获取通关信息', str);
  176. const result = JSON.parse(str);
  177. smc.game.GameModel.passViewInfo = result;
  178. oops.message.dispatchEvent(GameEvent.openView, 'openPassView');
  179. }
  180. getTxbfInfo() {
  181. const param = {
  182. url: ProtocolEvent.GetWithdrawReward,
  183. callback: this.buildCallback('ServerHandler.inst.onRebates', 'ServerHandler.inst.onRequestFail')
  184. };
  185. this.sendMsgToServer(param);
  186. }
  187. //提现返利
  188. onRebates(str: string) {
  189. console.log('[服务器] 提现返利信息', str);
  190. let result = JSON.parse(str);
  191. smc.game.GameModel.cashNum = result.props["1004"];
  192. smc.account.AccountModel.hbCoin = result.props["1004"];
  193. smc.game.GameModel.changeHbCoin = result.changes["1004"];
  194. oops.message.dispatchEvent(GameEvent.openView, "openRebateView")
  195. }
  196. //获取双倍奖励返回
  197. getDoubleSurprise() {
  198. const param = {
  199. url: ProtocolEvent.GetDoubleAwardInfo,
  200. callback: this.buildCallback('ServerHandler.inst.onDoubleSurprise', 'ServerHandler.inst.onRequestFail')
  201. };
  202. this.sendMsgToServer(param);
  203. }
  204. //双倍惊喜返回
  205. onDoubleSurprise(str: string) {
  206. console.log('[服务器] 恭喜翻倍信息', str);
  207. let result = JSON.parse(str);
  208. smc.game.GameModel.doubleRewardInfo = result;
  209. oops.message.dispatchEvent(GameEvent.openView, "openDoubleSurprise");
  210. }
  211. //更新消除奖励
  212. updateEliminationReward(data: { level: number, score: number, count: number }) {
  213. const param = {
  214. url: ProtocolEvent.GetEliminationReward,
  215. param: {
  216. eliminationCount: data.count,
  217. // level: data.level,
  218. score: data.score
  219. },
  220. callback: this.buildCallback('ServerHandler.inst.onEliminationSuccess', 'ServerHandler.inst.onRequestFail')
  221. };
  222. this.sendMsgToServer(param);
  223. }
  224. onEliminationSuccess(str: string) {
  225. console.log('[服务器] 消除成功返回', str);
  226. let result = JSON.parse(str);
  227. if (result?.props && result?.changes) {
  228. const props = result.props;
  229. const changes = result.changes;
  230. const account = smc.account.AccountModel;
  231. const game = smc.game.GameModel;
  232. //全部取小数点后两位
  233. account.hbCoin = props['1004'] || 0;
  234. account.wxCoin = props['1005'] || 0;
  235. game.changeHbCoin = changes['1004'] || 0;
  236. game.changeWxCoin = changes['1005'] || 0;
  237. oops.message.dispatchEvent(GameEvent.showCoinAnimation);
  238. //更新分数情况,判断是否可以通关
  239. oops.message.dispatchEvent(GameEvent.updateGameScore);
  240. }
  241. }
  242. getSign(price: number) {
  243. const param = {
  244. url: ProtocolEvent.AdVideoStart,
  245. param: { ecpm: price },
  246. callback: this.buildCallback('ServerHandler.inst.onSign')
  247. };
  248. this.sendMsgToServer(param);
  249. }
  250. onSign(str: string) {
  251. console.log('[服务器] 签名返回', str);
  252. let result = JSON.parse(str);
  253. smc.game.GameModel.sign = result?.sign || "";
  254. }
  255. //直接领取通关奖励
  256. getPassRewards() {
  257. // const level = smc.account.AccountModel.curLevel;
  258. const param = {
  259. url: ProtocolEvent.GetPassReward,
  260. // param: {
  261. // level: level,
  262. // },
  263. callback: this.buildCallback('ServerHandler.inst.onGetPassRewards', 'ServerHandler.inst.onRequestFail')
  264. }
  265. this.sendMsgToServer(param);
  266. }
  267. //直接领取通关奖励返回
  268. onGetPassRewards(str: string) {
  269. console.log('[服务器] 直接领取通关奖励成功返回', str);
  270. let result = JSON.parse(str);
  271. //全部取小数点后两位
  272. smc.game.GameModel.changeHbCoin = result.changes['1004'] || 0;
  273. smc.game.GameModel.changeWxCoin = result.changes['1005'] || 0;
  274. smc.account.AccountModel.hbCoin = result.props["1004"] || 0;
  275. smc.account.AccountModel.wxCoin = result.props["1005"] || 0;
  276. oops.message.dispatchEvent(GameEvent.showCoinAnimation);
  277. //请求下一局
  278. //如果是提现点,就展示提现,然后展示提现返利
  279. if (smc.game.GameModel.curLevelConfig.eventType && smc.game.GameModel.curLevelConfig.eventType == "WITHDRAW_POINT") {
  280. //展示提现信息
  281. this.WechatReward();
  282. smc.game.GameModel.curLevelConfig.eventType = "";
  283. } else {
  284. this.getNextLevel();
  285. }
  286. }
  287. //少量领取翻倍奖励
  288. getLittleRewards() {
  289. // const level = smc.account.AccountModel.curLevel;
  290. const param = {
  291. url: ProtocolEvent.GetLittlePassReward,
  292. // param: {
  293. // level: level,
  294. // },
  295. callback: this.buildCallback('ServerHandler.inst.onGetDoubleRewards', 'ServerHandler.inst.onRequestFail')
  296. }
  297. this.sendMsgToServer(param);
  298. }
  299. //少量领取翻倍奖励返回
  300. onGetDoubleRewards(str: string) {
  301. console.log('[服务器] 少量领取双倍奖励成功返回', str);
  302. let result = JSON.parse(str);
  303. smc.game.GameModel.changeHbCoin = result.changes['1004'] || 0;
  304. smc.game.GameModel.changeWxCoin = result.changes['1005'] || 0;
  305. smc.account.AccountModel.hbCoin = result.props["1004"] || 0;
  306. smc.account.AccountModel.wxCoin = result.props["1005"] || 0;
  307. smc.game.GameModel.skipAdCount = result.props["1008"] || 0;//广告跳过次数
  308. oops.message.dispatchEvent(GameEvent.showCoinAnimation);
  309. }
  310. //获取视频奖励
  311. getVideorReward() {
  312. const sign = smc.game.GameModel.sign;
  313. // const level = smc.account.AccountModel.curLevel;
  314. let type = smc.game.GameModel.viewType;
  315. console.log("获取视频奖励类型", type)
  316. const param = {
  317. url: ProtocolEvent.GetVideorReward,
  318. param: {
  319. // level: level,
  320. type: type,
  321. transId: "",
  322. sign: sign
  323. },
  324. callback: this.buildCallback('ServerHandler.inst.onGetVideorReward', 'ServerHandler.inst.onRequestFail')
  325. }
  326. this.sendMsgToServer(param);
  327. }
  328. onGetVideorReward(str: string) {
  329. console.log('[服务器] 获取视频奖励放回', str);
  330. let result = JSON.parse(str);
  331. if (result.tipThreshold) {
  332. oops.gui.toast("今日奖励已领取,请明天再来吧")
  333. return
  334. }
  335. if (result?.props) {
  336. const props = result.props;
  337. const changes = result.changes;
  338. const account = smc.account.AccountModel;
  339. const game = smc.game.GameModel;
  340. account.wxCoin = props['1005'] || 0;
  341. account.hbCoin = props['1004'] || 0;
  342. game.changeHbCoin = changes['1004'] || 0;
  343. game.changeWxCoin = changes['1005'] || 0;
  344. oops.message.dispatchEvent(GameEvent.showCoinAnimation);
  345. }
  346. }
  347. //下一关
  348. getNextLevel() {
  349. // const level = smc.account.AccountModel.curLevel;
  350. const param = {
  351. url: ProtocolEvent.NextLevel,
  352. // param: {
  353. // nextLevel: level + 1
  354. // },
  355. callback: this.buildCallback('ServerHandler.inst.onGetNextLevel', 'ServerHandler.inst.onRequestFail')
  356. }
  357. this.sendMsgToServer(param);
  358. }
  359. onGetNextLevel(str: string) {
  360. console.log('[服务器] 下一关数据返回', str);
  361. let result = JSON.parse(str);
  362. smc.account.AccountModel.curLevel = result.currentLevelData.level;
  363. smc.game.GameModel.curScore = result.currentLevelData.score;
  364. smc.game.GameModel.targetScore = result.currentLevelConf.score;
  365. smc.game.GameModel.eventType = result.currentLevelConf.eventType || "";
  366. smc.game.GameModel.curLevelConfig = result.currentLevelConf;
  367. smc.account.AccountModel.goldCoin = result.props["1006"] || 0//金砖数量
  368. smc.game.GameModel.popupType = result.currentLevelConf.popupType || "";
  369. smc.game.GameModel.popupShow = result.currentLevelData.popupStatus || false;
  370. smc.game.GameModel.skipAdConfig = result.currentLevelConf.skipCount || -1;
  371. oops.message.dispatchEvent(GameEvent.RestartGame);
  372. }
  373. //重新开始游戏
  374. RestartGame() {
  375. const param = {
  376. url: ProtocolEvent.RestartGame,
  377. callback: this.buildCallback('ServerHandler.inst.onRestartGame', 'ServerHandler.inst.onRequestFail')
  378. }
  379. this.sendMsgToServer(param);
  380. }
  381. onRestartGame(str: string) {
  382. console.log('[服务器] 重新开始游戏返回', str);
  383. let result = JSON.parse(str);
  384. smc.account.AccountModel.curLevel = result.currentLevelData.level;
  385. smc.game.GameModel.curScore = result.currentLevelData.score;
  386. smc.game.GameModel.targetScore = result.currentLevelConf.score;
  387. oops.message.dispatchEvent(GameEvent.RestartGame);
  388. }
  389. //微信提现页面
  390. WechatReward() {
  391. const param = {
  392. url: ProtocolEvent.GetWelfarePointCash,
  393. param: {
  394. level: smc.account.AccountModel.curLevel,
  395. riskToken: "",
  396. riskBusinessId: ""
  397. },
  398. callback: this.buildCallback('ServerHandler.inst.onWechatReward', 'ServerHandler.inst.onRequestFail')
  399. }
  400. this.sendMsgToServer(param);
  401. }
  402. onWechatReward(str: string) {
  403. console.log("[服务器] 微信提现请求成功", str);
  404. let result = JSON.parse(str);
  405. smc.game.GameModel.txNum = result.changes["8001"];
  406. smc.game.GameModel.txType = 1;
  407. oops.message.dispatchEvent(GameEvent.openView, "openCashWithdrawalView")
  408. const curLevel = smc.account.AccountModel.curLevel;
  409. DCHandler.inst.reportData(3000101, curLevel);
  410. }
  411. //红包币页提现
  412. HbReward() {
  413. const param = {
  414. url: ProtocolEvent.GetRedPacketCash,
  415. param: {
  416. riskToken: "",
  417. riskBusinessId: ""
  418. },
  419. callback: this.buildCallback('ServerHandler.inst.onHbReward', 'ServerHandler.inst.onHbRewardFail')
  420. }
  421. this.sendMsgToServer(param);
  422. }
  423. onHbReward(str: string) {
  424. console.log('[服务器] 红包币提现返回', str);
  425. let result = JSON.parse(str);
  426. const wxCash = result.changes["8001"];
  427. smc.game.GameModel.txNum = wxCash;
  428. smc.game.GameModel.txType = 2;
  429. smc.account.AccountModel.hbCoin = result.props["1004"];
  430. smc.account.AccountModel.wxCoin = result.props["1005"];
  431. smc.game.GameModel.wxCash = result.money || 0;
  432. oops.message.dispatchEvent(GameEvent.openView, "openCashWithdrawalView");
  433. oops.message.dispatchEvent(GameEvent.updateHbAndWxCoin);
  434. }
  435. onHbRewardFail(code: number, str: string) {
  436. oops.gui.toast(str);
  437. }
  438. //获取微信提现页信息
  439. getWechatTxInfo() {
  440. const param = {
  441. url: ProtocolEvent.GetWechatTxInfo,
  442. callback: this.buildCallback('ServerHandler.inst.onGetWechatTxInfo', 'ServerHandler.inst.onRequestFail')
  443. }
  444. this.sendMsgToServer(param);
  445. }
  446. onGetWechatTxInfo(str: string) {
  447. console.log('[服务器] 获取微信提现页信息返回', str);
  448. let result = JSON.parse(str);
  449. smc.game.GameModel.wechat_tx_info = result;
  450. oops.message.dispatchEvent(GameEvent.openView, "openWechatWithdrawalView");
  451. }
  452. //获取二倍速时长信息
  453. getDoubleSpeedTime() {
  454. const param = {
  455. url: ProtocolEvent.GetDoubleSpeedAward,
  456. callback: this.buildCallback('ServerHandler.inst.onGetDoubleSpeedTime', 'ServerHandler.inst.onRequestFail')
  457. }
  458. this.sendMsgToServer(param);
  459. }
  460. onGetDoubleSpeedTime(str: string) {
  461. console.log('[服务器] 获取二倍速时长返回', str);
  462. let result = JSON.parse(str);
  463. smc.game.GameModel.doubleSpeedTime = result.duration;
  464. oops.message.dispatchEvent(GameEvent.openView, "openDoubleSpeedView");
  465. }
  466. //获取引导界面信息
  467. getGuideInfo() {
  468. const param = {
  469. url: ProtocolEvent.GetGuideInfo,
  470. callback: this.buildCallback('ServerHandler.inst.onGetGuideInfo', 'ServerHandler.inst.onRequestFail')
  471. }
  472. this.sendMsgToServer(param);
  473. }
  474. onGetGuideInfo(str: string) {
  475. console.log('[服务器] 获取引导界面信息返回', str);
  476. let result = JSON.parse(str);
  477. smc.game.GameModel.loadbarInfo = result;
  478. }
  479. //更新弹出事件
  480. updatePopupState(data: { level: number, type: string }) {
  481. const param = {
  482. url: ProtocolEvent.UpdatePopUpState,
  483. param: {
  484. level: data.level,
  485. type: data.type,
  486. callback: this.buildCallback('ServerHandler.inst.onUpdatePopupState', 'ServerHandler.inst.onRequestFail')
  487. },
  488. }
  489. this.sendMsgToServer(param);
  490. oops.message.dispatchEvent(GameEvent.updateGameState, "playing");
  491. }
  492. onUpdatePopupState(str: string) {
  493. console.log('[服务器] 更新弹出事件返回', str);
  494. let result = JSON.parse(str);
  495. smc.game.GameModel.popupShow = result.status || true;
  496. }
  497. //领取手续费
  498. getFee() {
  499. const param = {
  500. url: ProtocolEvent.GetFee,
  501. // param: {
  502. // level: smc.account.AccountModel.curLevel,
  503. // },
  504. callback: this.buildCallback('ServerHandler.inst.onGetFee', 'ServerHandler.inst.onRequestFail')
  505. }
  506. this.sendMsgToServer(param);
  507. }
  508. onGetFee(str: string) {
  509. console.log('[服务器] 领取手续费返回', str);
  510. let result = JSON.parse(str);
  511. // smc.game.GameModel.fee = result.fee;
  512. }
  513. //保存当前关卡信息
  514. saveCurLevelInfo() {
  515. const param = {
  516. url: ProtocolEvent.SaveCurrentLevelInfo,
  517. param: {
  518. level: smc.account.AccountModel.curLevel,
  519. skipCount: smc.game.GameModel.curScore,
  520. },
  521. callback: this.buildCallback('ServerHandler.inst.onSaveCurLevelInfo', 'ServerHandler.inst.onRequestFail')
  522. }
  523. this.sendMsgToServer(param);
  524. }
  525. onSaveCurLevelInfo(str: string) {
  526. console.log('[服务器] 保存当前关卡信息返回', str);
  527. let result = JSON.parse(str);
  528. }
  529. onRequestFail(code: number, str: string) {
  530. console.log('[服务器] 请求失败', code, str);
  531. }
  532. }
  533. window["ServerHandler"] = ServerHandler;