PlatformBase.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. var s =
  5. (this && this.__awaiter) ||
  6. function (t, n, r, l) {
  7. return new (r = r || Promise)(function (i, e) {
  8. function s(t) {
  9. try {
  10. a(l.next(t));
  11. } catch (t) {
  12. e(t);
  13. }
  14. }
  15. function o(t) {
  16. try {
  17. a(l.throw(t));
  18. } catch (t) {
  19. e(t);
  20. }
  21. }
  22. function a(t) {
  23. var e;
  24. t.done ?
  25. i(t.value) :
  26. ((e = t.value) instanceof r ?
  27. e :
  28. new r(function (t) {
  29. t(e);
  30. })
  31. ).then(s, o);
  32. }
  33. a((l = l.apply(t, n || [])).next());
  34. });
  35. };
  36. Object.defineProperty(i, "__esModule", { value: !0 }),
  37. (i.DiamondCostType = i.save_prop_Const = i.LoginDataSaveKey = void 0);
  38. const l = t("App"),
  39. o = t("GameText"),
  40. a = t("Toast"),
  41. n = t("NotificationConst"),
  42. r = t("ViewConst"),
  43. h = t("ADController"),
  44. c = t("ADManageBase"),
  45. d = t("TipView");
  46. (i.LoginDataSaveKey = { loginCache: "cars" }),
  47. ((t = i.save_prop_Const || (i.save_prop_Const = {}))[(t.YINDAO_LEVEL = 99)] = "YINDAO_LEVEL"),
  48. (t[(t.LEVEL = 1)] = "LEVEL"),
  49. ((t = i.DiamondCostType || (i.DiamondCostType = {}))[(t.SHOP_NORMAL_BOX = 0)] = "SHOP_NORMAL_BOX"),
  50. (t[(t.SHOP_HEIGHT_BOX = 1)] = "SHOP_HEIGHT_BOX"),
  51. (t[(t.EQUIPMENT_UPGRADE = 2)] = "EQUIPMENT_UPGRADE"),
  52. (t[(t.EQUIPMENT_GRADE_UPGRADE = 3)] = "EQUIPMENT_GRADE_UPGRADE"),
  53. (t[(t.ABILITY_UPGRADE = 4)] = "ABILITY_UPGRADE"),
  54. (t[(t.BUFF_DOUBLE__RATE_GOLD = 5)] = "BUFF_DOUBLE__RATE_GOLD"),
  55. (t[(t.BUFF_FIVE_RATE_GOLD = 6)] = "BUFF_FIVE_RATE_GOLD"),
  56. (t[(t.BUFF_FOUR_HOUR_GOLD = 7)] = "BUFF_FOUR_HOUR_GOLD"),
  57. (i.default = class {
  58. constructor() {
  59. (this.loginInfo = {}),
  60. (this._videoManage = null),
  61. (this.compelADVideoManage = null),
  62. (this.insterTime = 0),
  63. (this.insterFullTime = 0),
  64. (this.msgCache = []),
  65. (this._playrSpendMoney = 0),
  66. (l.default.Platform = this),
  67. l.default.SaveManage.add(this, i.LoginDataSaveKey.loginCache, !1, !1),
  68. l.default.SaveManage.load(i.LoginDataSaveKey.loginCache);
  69. }
  70. init() {
  71. this.initProductConfig(), this.initAd(), l.default.AnalyticMgr.sentDayRetain();
  72. }
  73. initProductConfig() {
  74. var t = l.default.ConfigManager.getConfig("ProductConfig");
  75. this._productConfigs = {};
  76. for (const e of t) this._productConfigs[e.payId] = e;
  77. }
  78. initAccountServer() { }
  79. getProductConfigByPayString(t) {
  80. return this._productConfigs[t];
  81. }
  82. getProductConfigById(t) {
  83. for (var e in this._productConfigs) {
  84. e = this._productConfigs[e];
  85. if (e.id == t) return e;
  86. }
  87. return null;
  88. }
  89. setEvent(t) { }
  90. showInteractionAd(t = h.InterAdType.normal, e) {
  91. return !0;
  92. }
  93. isAutoShowInteractionAd() {
  94. return !1;
  95. }
  96. isGetRemoteRes() {
  97. return !1;
  98. }
  99. isShowDebugUI() {
  100. return (-1 < this.getVersionStr().indexOf("debug") ||
  101. -1 < this.getVersionStr().indexOf("test") ||
  102. -1 < this.getVersionStr().indexOf("gm")
  103. );
  104. }
  105. vibrator(t = 0) { }
  106. resetGame() {
  107. window.location.reload();
  108. }
  109. checkIsNotch() {
  110. return !1;
  111. }
  112. exitGame() {
  113. this.saveData();
  114. }
  115. cal(t) { }
  116. initAd() {
  117. this._videoManage = new c.ADManageBase();
  118. }
  119. share(t, e) { }
  120. showBanner() { }
  121. hideBanner() { }
  122. showExpressAd(t) { }
  123. hideExpressAd() { }
  124. showAD(t, e) {
  125. this._videoManage && this._videoManage.show();
  126. }
  127. showCompelAD(t, e, i) { }
  128. isWXLogin() {
  129. return s(this, void 0, void 0, function* () {
  130. return !0;
  131. });
  132. }
  133. startGameRecorder(t) { }
  134. stopGameRecorder() { }
  135. shareRecorder() { }
  136. jumpToOtherGame(t, e) { }
  137. loadZipFile(t) {
  138. return Promise.resolve(!1);
  139. }
  140. isCanShare() {
  141. return !0;
  142. }
  143. getPackVersion() {
  144. return "test";
  145. }
  146. getPackVersionCode() {
  147. return 9999;
  148. }
  149. getDefaultLang() {
  150. return "0";
  151. }
  152. syncDataCallBack() { }
  153. getServerTime() {
  154. return s(this, void 0, void 0, function* () {
  155. let t = 3;
  156. do {
  157. try {
  158. var e = l.default.GameDataMsr.playerInfo,
  159. i = yield l.default.Http.requestAsync(
  160. l.default.ConfigManager.gameConf.serverInfos.interface + "/api/time", { token: e.token }
  161. ),
  162. s = JSON.parse(i);
  163. return l.default.DateUtils.setServerTime(1e3 * s.data.now_time), !0;
  164. } catch (t) {
  165. Log.error("获取后台时间失败", t), yield l.default.TimerManager.sleep(1e3);
  166. }
  167. } while (--t);
  168. return !1;
  169. });
  170. }
  171. saveDataToLocal() {
  172. (l.default.GameDataMsr.playerInfo.localSaveTime = Math.ceil(l.default.DateUtils.Now() / 1e3)),
  173. l.default.SaveManage.saveAll();
  174. }
  175. saveData() {
  176. return s(this, void 0, void 0, function* () {
  177. let t = l.default.GameDataMsr.playerInfo;
  178. (t.localSaveTime = t.saveTime = Math.ceil(l.default.DateUtils.Now() / 1e3)),
  179. (t.saveDevice = this.getDeviceId());
  180. var e = t.token;
  181. l.default.ConfigManager.gameConf.serverInfos.game, (t.token = null);
  182. var i = l.default.SaveManage.getAllAutoSaveData();
  183. // if (((t.token = e), t.token))
  184. // try {
  185. // var s = yield l.default.Http.post(
  186. // l.default.ConfigManager.gameConf.serverInfos.interface + "/api/user/file",
  187. // {api_token: t.token, file: l.default.StringUtil.zipStr(i), loginTime: t.timestamp},
  188. // 3
  189. // ),
  190. // o = JSON.parse(s);
  191. // if (o && 0 == o.code) return !0;
  192. // } catch (t) {
  193. // Log.error("存储数据失败", t);
  194. // }
  195. return !1;
  196. });
  197. }
  198. showLoginFailTipView() {
  199. return new Promise(t => {
  200. l.default.ViewManager.open(14, {
  201. curState: d.TIPSTATE.SURE,
  202. leftBtnText: o.GameText.getText(17),
  203. leftFunc: () => {
  204. t();
  205. },
  206. leftThisObj: this,
  207. tipsStr: o.GameText.getText(53)
  208. });
  209. });
  210. }
  211. isUseServerSave(i, s) {
  212. return new Promise(t => {
  213. var e = l.default.GameDataMsr.playerInfo;
  214. e.godsTotalPower && e.saveTime ?
  215. l.default.ViewManager.open(r.ViewConst.SaveSelectView, i, s, e.saveTime, e.godsTotalPower, t) :
  216. t(!0);
  217. });
  218. }
  219. getDeviceId() {
  220. let t = cc.sys.localStorage.getItem("DEVICEID");
  221. return t || ((t = "wx" + l.default.DateUtils.Now()), cc.sys.localStorage.setItem("DEVICEID", t)), t;
  222. }
  223. isShowGameCircle() {
  224. return !1;
  225. }
  226. getUseInfoFinish(t) { }
  227. getUserSaveData(i) {
  228. console.log('getUserSaveData同步数据');
  229. // return s(this, void 0, void 0, function*() {
  230. // let t = 3;
  231. // do {
  232. // var e = yield l.default.Http.requestAsync(
  233. // l.default.ConfigManager.gameConf.serverInfos.game + "/api/user/file", { api_token: i },
  234. // "GET"
  235. // ),
  236. // e = JSON.parse(e);
  237. // if (0 == e.code) return e.data;
  238. // } while (--t);
  239. // return null;
  240. // });
  241. }
  242. syncData() {
  243. console.log('syncData同步数据11111111111111111111111111');
  244. return s(this, void 0, void 0, function* () {
  245. let e = l.default.GameDataMsr,
  246. t = 3;
  247. {
  248. console.error('强制修改钻石数据');
  249. console.error(e);
  250. e.playerInfo.diamond = 19
  251. l.default.SaveManage.getAllAutoSaveData();
  252. }
  253. // do {
  254. // try {
  255. // let t = e.playerInfo;
  256. // Log.trace("获取登陆信息");
  257. // var i = yield this.login();
  258. // (t.account = this.loginInfo.unionid),
  259. // (t.openid = this.loginInfo.openid),
  260. // Log.trace("向管理后台请求用户数据", i.loginKey);
  261. // var s,
  262. // o,
  263. // a = yield l.default.Http.requestAsync(
  264. // l.default.ConfigManager.gameConf.serverInfos.interface + "/api/user", { api_token: i.loginKey },
  265. // "GET"
  266. // ),
  267. // n = JSON.parse(a);
  268. // if (
  269. // (!this.loginInfo.unionid && i.loginKey && (this.loginInfo.unionid = n.account),
  270. // 0 !== n.code)
  271. // ) {
  272. // -1001 === n.code || -1003 === n.code ?
  273. // this.logout() :
  274. // Log.trace("向管理后台获取数据失败!!!", n.code);
  275. // continue;
  276. // }
  277. // (t.id = n.data.id),
  278. // (t.token = i.loginKey),
  279. // (t.registerTime = 1e3 * n.data.reg_time),
  280. // (t.registerDaynumber = Math.ceil(
  281. // (l.default.DateUtils.Now() - 1e3 * n.data.reg_time) / 864e5
  282. // )),
  283. // l.default.DateUtils.setServerTime(1e3 * t.timestamp),
  284. // l.default.SaveManage.setSaveKey(t.id + ""),
  285. // l.default.AnalyticMgr.activityLogin();
  286. // const r = yield this.getUserSaveData(i.loginKey);
  287. // if (!r) return !1;
  288. // r.file &&
  289. // ((o = (s = JSON.parse(r.file.includes("{") ? r.file : l.default.StringUtil.unzip(r.file)))
  290. // .PLAYER_INFO),
  291. // (t.saveTime < r.time || (null != s && s.ISREPLACE)) &&
  292. // (l.default.SaveManage.syncByData(s),
  293. // (t.saveTime = r.time),
  294. // (t.localSaveTime = o.localSaveTime),
  295. // (t.finishTaskCnt = o.finishTaskCnt),
  296. // (t.head = o.head),
  297. // (t.nickName = o.nickName),
  298. // (t.diamond = o.diamond),
  299. // (t.gold = o.gold))),
  300. // this.syncDataCallBack(),
  301. // Log.trace("向管理后台请求用户数据成功!!!");
  302. // break;
  303. // } catch (t) {
  304. // Log.error("同步数据失败", t && t.toString());
  305. // }
  306. // Log.trace("请求数据失败!!!!,", t), yield l.default.TimerManager.sleep(1e3);
  307. // } while (--t);
  308. return (e.tempData.isSyncDataByServer = !0), !!t;
  309. });
  310. }
  311. getVersionStr() {
  312. return `v ${versionInfo.packVersion}_${versionInfo.version}`;
  313. }
  314. createMemento(t) {
  315. return this.loginInfo || {};
  316. }
  317. getAdTypeNum() {
  318. return 1;
  319. }
  320. getAdState(t) {
  321. return this._videoManage.adState;
  322. }
  323. setMemento(t, e) {
  324. this.loginInfo = t || {};
  325. }
  326. getAccountInfoSync() { }
  327. logout() {
  328. (this.loginInfo = {}), l.default.SaveManage.save(i.LoginDataSaveKey.loginCache);
  329. }
  330. getChannel() {
  331. return "cjkg";
  332. }
  333. tourist() {
  334. return s(this, void 0, void 0, function* () {
  335. if (this.loginInfo.token) return Promise.resolve({ code: 0, loginKey: this.loginInfo.token });
  336. var t = yield l.default.Http.requestAsync(
  337. l.default.ConfigManager.gameConf.serverInfos.interface + "/api/login/simple", { channel: this.getChannel() },
  338. "GET"
  339. );
  340. Log.trace(">>>>>>>>>>>>>>>游客登录", t);
  341. t = JSON.parse(t);
  342. return (
  343. (this.loginInfo.playerid = t.data.id),
  344. (this.loginInfo.token = t.token),
  345. l.default.SaveManage.save(i.LoginDataSaveKey.loginCache),
  346. (l.default.GameDataMsr.isNew = !0),
  347. 0 === t.code ?
  348. (this.setChannel(t.token), { code: t.code, loginKey: t.token }) : { code: t.code, loginKey: null }
  349. );
  350. });
  351. }
  352. buy(t) {
  353. return s(this, void 0, void 0, function* () {
  354. return a.default.launch("支付功能还在开发中!!!!"), !1;
  355. });
  356. }
  357. getPrice(t) {
  358. t = this.getProductConfigByPayString(t);
  359. return t ? "$ " + t.cost : null;
  360. }
  361. getPriceNum(t) {
  362. return this.getProductConfigByPayString(t).cost;
  363. }
  364. getCurrency(t) {
  365. var e,
  366. t = this.getPrice(t);
  367. if (!t) return "";
  368. let i = "";
  369. for (e of t) {
  370. if (("0" <= e && e <= "9") || "." === e) break;
  371. i += e;
  372. }
  373. return i;
  374. }
  375. getTitle(t) {
  376. return "";
  377. }
  378. isSignIn() {
  379. return cc.sys.localStorage.getItem("is_SignIn_Game");
  380. }
  381. signInSuccess(t) {
  382. cc.sys.localStorage.setItem("is_SignIn_Game", t);
  383. }
  384. signInFail() {
  385. cc.sys.localStorage.removeItem("is_SignIn_Game");
  386. }
  387. googleLogin() {
  388. return s(this, void 0, void 0, function* () {
  389. return !1;
  390. });
  391. }
  392. signOut() {
  393. l.default.EasyLoading.showLoadingByTime(10),
  394. this.clearAndResetGame(!0),
  395. cc.sys.localStorage.removeItem("is_SignIn_Game"),
  396. l.default.EasyLoading.hideLoading();
  397. }
  398. clearAndResetGame(t = !1) {
  399. return s(this, void 0, void 0, function* () {
  400. t && (yield this.saveData()),
  401. l.default.SaveManage.clear(),
  402. l.default.SaveManage.clearAllItem(),
  403. cc.audioEngine.stopAll(),
  404. cc.game.restart();
  405. });
  406. }
  407. isHaveAnomalyOrder(t) {
  408. return !1;
  409. }
  410. getOrderDataByPayId(t) {
  411. return null;
  412. }
  413. openAppReview() {
  414. return s(this, void 0, void 0, function* () {
  415. return !0;
  416. });
  417. }
  418. set playerSpendMoney(t) {
  419. (this._playrSpendMoney += t),
  420. (l.default.GameDataMsr.playerInfo.vipRecharge = this._playrSpendMoney),
  421. l.default.NotificationCenter.dispatch(n.NotificationConst.PAY_SUCCESS);
  422. }
  423. get playerSpendMoney() {
  424. return this._playrSpendMoney;
  425. }
  426. updatePlayerSpendMoeny() {
  427. return s(this, void 0, void 0, function* () {
  428. if (!this.isShowDebugUI() || !cc.sys.localStorage.getItem("vipTest")) {
  429. let t = 3;
  430. do {
  431. try {
  432. var e = yield l.default.Http.requestAsync(
  433. l.default.ConfigManager.gameConf.serverInfos.interface +
  434. "/Interface/recharge/total_amount.php", { token: l.default.GameDataMsr.playerInfo.token }
  435. ),
  436. i = JSON.parse(e);
  437. if (0 === i.code)
  438. return (
  439. (this.playerSpendMoney = i.data.amount),
  440. void (l.default.GameDataMsr.playerInfo.vipRecharge = i.data.amount)
  441. );
  442. } catch (t) { }
  443. } while ((yield l.default.TimerManager.sleep(1e3), --t));
  444. l.default.TimerManager.doTimer(12e4, 1, this.updatePlayerSpendMoeny, this);
  445. }
  446. });
  447. }
  448. setChannel(t) { }
  449. recordDiamondCost(t, e, i) {
  450. e = 0 < e ? -e : e;
  451. l.default.Http.requestAsync(
  452. l.default.ConfigManager.gameConf.serverInfos.interface + "/Interface/money/save.php", {
  453. token: l.default.GameDataMsr.playerInfo.token,
  454. type: t,
  455. money_type: 0,
  456. money_num: e,
  457. item_type: 0,
  458. item_id: i || 0,
  459. item_num: 1
  460. }
  461. );
  462. }
  463. record(t) {
  464. try {
  465. t.token = l.default.GameDataMsr.playerInfo.token;
  466. } catch (t) {
  467. Log.error("统计出错:", t);
  468. }
  469. }
  470. getIsShowPay() {
  471. return !0;
  472. }
  473. saveWxUserInfo() {
  474. return s(this, void 0, void 0, function* () { });
  475. }
  476. isAuthorization() {
  477. return s(this, void 0, void 0, function* () {
  478. return !0;
  479. });
  480. }
  481. resumOrder() {
  482. return s(this, void 0, void 0, function* () { });
  483. }
  484. });