Global.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. import i18n from './locales/index';
  2. import { LOCAL_AREA_ID, LOCAL_WD_PASS, LOCAL_WD_PASS_SET_TIME } from "@constants/localkey";
  3. import { decrypt, encrypt, getUrlParamsAsJsonManual, localStorageGet, localStorageSet } from "@utils/helpers";
  4. // import symbol from "@assets/symbol-defs.svg";
  5. // import symbol_m from "@assets/symbol-mobile.svg";
  6. import area from "@db/area";
  7. import tracker from "@utils/adjust";
  8. global.tracker = tracker;
  9. global.enterRechargeType = 0; // 进入充值界面的状态
  10. global.adjustId = 0;
  11. global.i18n = i18n;
  12. // global.symbol=symbol;
  13. // global.symbol_m=symbol_m;
  14. global.CASH_BASE = 100;
  15. global.DOLLAR = "R$";
  16. global.currency = "";
  17. global.dispatch = null;
  18. global.curGoods = null;
  19. global.curPayUrl = null;
  20. global.isNewUser = false;
  21. /// 返回忽略弹窗
  22. global.ignorePopup = false;
  23. global.newUserPrompted = false;
  24. ///免费提现额度
  25. global.freeTxTotal = 40;
  26. global.bindPhoneCallback = null;
  27. global.msgBox = null;
  28. global.msgBoxShow = (params) => {
  29. if (global.msgBox) global.msgBox.show(params);
  30. };
  31. global.msgBoxHide = () => {
  32. if (global.msgBox) global.msgBox.hide();
  33. };
  34. global.authLockPath = null;
  35. global.device = "mobile";
  36. global.width = 100;
  37. global.height = 100;
  38. global.isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
  39. //游客id 指纹
  40. global.BFP = null;
  41. //指纹Fingerprint2
  42. global.FF = null;
  43. //wd pass
  44. global.getWDPass = () => {
  45. let pass = localStorageGet(LOCAL_WD_PASS, "");
  46. if (pass != null && pass !== "") {
  47. pass = decrypt(pass);
  48. let lsettime = localStorageGet(LOCAL_WD_PASS_SET_TIME, "");
  49. if (lsettime != null) {
  50. lsettime = Number(lsettime);
  51. let now = Date.now();
  52. let during = now - lsettime;
  53. //10m
  54. let deadline = 10 * 60 * 1000;
  55. if (during < deadline) return pass;
  56. else {
  57. localStorageSet(LOCAL_WD_PASS, "");
  58. localStorageSet(LOCAL_WD_PASS_SET_TIME, "");
  59. }
  60. }
  61. }
  62. return "";
  63. };
  64. global.setWDPass = (value) => {
  65. if (value == null) return;
  66. if (value !== "") {
  67. value = encrypt(value);
  68. }
  69. localStorageSet(LOCAL_WD_PASS, value);
  70. localStorageSet(LOCAL_WD_PASS_SET_TIME, Date.now());
  71. };
  72. global.showDropCoins = () => {
  73. if (global.dropCoins) global.dropCoins.show();
  74. };
  75. global.hideDropCoins = () => {
  76. if (global.dropCoins) global.dropCoins.hide();
  77. };
  78. global.showMailNew = () => {
  79. if (global.mailNew) global.mailNew.show();
  80. };
  81. global.hideMailNew = () => {
  82. if (global.mailNew) global.mailNew.hide();
  83. };
  84. global.showInstallBox = () => {
  85. if (global.installBox) global.installBox.show();
  86. };
  87. global.hideInstallBox = () => {
  88. if (global.installBox) global.installBox.hide();
  89. };
  90. global.showBindPhone = (callback) => {
  91. global.bindPhoneCallback = callback;
  92. if (global.bindPhone) {
  93. global.bindPhone.show();
  94. // adjust 打开绑定手机
  95. global.tracker.trackEvent("enter_bind_phone");
  96. global.tracker.trackEvent("enter_bind_phone_count");
  97. }
  98. };
  99. global.hideBindPhone = () => {
  100. if (global.bindPhone) global.bindPhone.hide();
  101. };
  102. global.showNewUserPrompt = () => {
  103. if (global.newUserPrompt) {
  104. global.newUserPrompt.show();
  105. // adjust 打开注册弹窗
  106. global.tracker.trackEvent("enter_register_panel");
  107. }
  108. };
  109. global.hideNewUserPrompt = () => {
  110. if (global.newUserPrompt) global.newUserPrompt.hide();
  111. };
  112. global.showNewUserBonus = () => {
  113. if (global.newUserBonus) {
  114. global.newUserBonus.show();
  115. // adjust 打开进入游戏引导
  116. global.tracker.trackEvent("enter_game");
  117. }
  118. };
  119. global.hideNewUserBonus = () => {
  120. if (global.newUserBonus) global.newUserBonus.hide();
  121. };
  122. global.showBindPrompt = () => {
  123. if (global.bindPrompt) global.bindPrompt.show();
  124. };
  125. global.hideBindPrompt = () => {
  126. if (global.bindPrompt) global.bindPrompt.hide();
  127. };
  128. global.showGameWithdrawTips = (type = 1) => {
  129. ///1.距离提现还差x 2.提现未解锁 3.可提现
  130. if (global.gameWithdrawTips) global.gameWithdrawTips.show(type);
  131. };
  132. global.hideGameWithdrawTips = () => {
  133. if (global.gameWithdrawTips) global.gameWithdrawTips.hide();
  134. };
  135. global.showWithdrawLimit = () => {
  136. if (global.withdrawLimit) {
  137. global.withdrawLimit.show();
  138. // adjust 打开进入游戏引导
  139. global.tracker.trackEvent("enter_deposit_panel");
  140. global.tracker.trackEvent("enter_deposit_panel_count");
  141. }
  142. };
  143. global.hideWithdrawLimit = () => {
  144. if (global.withdrawLimit) global.withdrawLimit.hide();
  145. };
  146. global.showFirstCashoutTips = () => {
  147. if (global.firstCashoutTips) global.firstCashoutTips.show();
  148. };
  149. global.hideFirstCashoutTips = () => {
  150. if (global.firstCashoutTips) global.firstCashoutTips.hide();
  151. };
  152. global.showProtectReward = () => {
  153. if (global.protectReward) global.protectReward.show();
  154. };
  155. global.hideProtectReward = () => {
  156. if (global.protectReward) global.protectReward.hide();
  157. };
  158. global.showLoadingCircular = (showMask = false) => {
  159. if (global.loadingCircular) global.loadingCircular.show(showMask);
  160. };
  161. global.hideLoadingCircular = () => {
  162. if (global.loadingCircular) global.loadingCircular.hide();
  163. };
  164. global.showFirstPay = () => {
  165. if (global.firstPay) {
  166. global.firstPay.show();
  167. // adjust 曝光首充礼包
  168. global.tracker.trackEvent("enter_first_pay");
  169. global.tracker.trackEvent("enter_first_pay_count");
  170. }
  171. };
  172. global.hideFirstPay = () => {
  173. if (global.firstPay) global.firstPay.hide();
  174. };
  175. global.showFirstDepositTips = () => {
  176. if (global.firstDepositTips) global.firstDepositTips.show();
  177. };
  178. global.hideFirstDepositTips = () => {
  179. if (global.firstDepositTips) global.firstDepositTips.hide();
  180. };
  181. global.showMusicSettings = () => {
  182. if (global.musicSettings) global.musicSettings.show();
  183. };
  184. global.hideMusicSettings = () => {
  185. if (global.musicSettings) global.musicSettings.hide();
  186. };
  187. global.showCheckIn = () => {
  188. if (global.checkIn) global.checkIn.show();
  189. };
  190. global.hideCheckIn = () => {
  191. if (global.checkIn) global.checkIn.hide();
  192. };
  193. global.showAreaSelect = (allowClose = true) => {
  194. if (global.areaSelect) global.areaSelect.show(allowClose);
  195. };
  196. global.hideAreaSelect = () => {
  197. if (global.areaSelect) global.areaSelect.hide();
  198. };
  199. global.showHolidaysGift = () => {
  200. if (global.holidaysGift) global.holidaysGift.show();
  201. };
  202. global.hideHolidaysGift = () => {
  203. if (global.holidaysGift) global.holidaysGift.hide();
  204. };
  205. global.showHolidaysAct = () => {
  206. if (global.holidaysAct) global.holidaysAct.show();
  207. };
  208. global.hideHolidaysAct = () => {
  209. if (global.holidaysAct) global.holidaysAct.hide();
  210. };
  211. global.showCommonTextTip = (textArr) => {
  212. if (global.commonTextTip) global.commonTextTip.show(textArr);
  213. };
  214. global.hideCommonTextTip = () => {
  215. if (global.commonTextTip) global.commonTextTip.hide();
  216. };
  217. global.checkDomainArea = () => {
  218. let areaID = 0;
  219. let host = window.location.host;
  220. for (let i = 0; i < area.length; i++) {
  221. let item = area[i];
  222. if (item) {
  223. let code = item.code;
  224. if (host.startsWith(code)) {
  225. areaID = item.id;
  226. break;
  227. }
  228. }
  229. }
  230. return areaID;
  231. };
  232. global.getLocalAreaID = () => {
  233. //let areaID = Number(localStorageGet(LOCAL_AREA_ID, 0));
  234. let areaID = Number(localStorageGet(LOCAL_AREA_ID, 1));
  235. if (areaID === 0) {
  236. let dAreaID = global.checkDomainArea();
  237. if (dAreaID !== 0) {
  238. localStorageSet(LOCAL_AREA_ID, dAreaID + "");
  239. areaID = dAreaID;
  240. }
  241. }
  242. return areaID;
  243. };
  244. global.setLocalAreaID = (value) => {
  245. localStorageSet(LOCAL_AREA_ID, value + "");
  246. window.location.reload();
  247. };
  248. global.getLocalAreaItem = () => {
  249. let areaID = global.getLocalAreaID();
  250. for (let i = 0; i < area.length; i++) {
  251. let item = area[i];
  252. if (item) {
  253. if (item.id === areaID) {
  254. return item;
  255. }
  256. }
  257. }
  258. return null;
  259. };
  260. global.getLocalAreaAlCode = () => {
  261. let code = 'en-US';
  262. let item = global.getLocalAreaItem();
  263. if (item) {
  264. code = item.alcode;
  265. }
  266. return code;
  267. };
  268. global.showSaveAccount = (info) => {
  269. if (global.saveAccount) global.saveAccount.show(info);
  270. };
  271. global.hideSaveAccount = () => {
  272. if (global.saveAccount) global.saveAccount.hide();
  273. };
  274. global.showBonusPack = () => {
  275. if (global.bonusPack) global.bonusPack.show();
  276. };
  277. global.hideBonusPack = () => {
  278. if (global.bonusPack) global.bonusPack.hide();
  279. };
  280. //初始化urlvars
  281. global.checkUrlvars = () => {
  282. let urlvars = localStorageGet("urlvars", "");
  283. if (urlvars == null || urlvars === "") {
  284. let json = getUrlParamsAsJsonManual();
  285. if (json != null) {
  286. urlvars = JSON.stringify(json);
  287. localStorageSet("urlvars", urlvars);
  288. }
  289. }
  290. else {
  291. let json = getUrlParamsAsJsonManual();
  292. if (json != null) {
  293. let orijson = JSON.parse(urlvars);
  294. orijson = Object.assign({}, orijson, json);
  295. urlvars = JSON.stringify(orijson);
  296. localStorageSet("urlvars", urlvars);
  297. }
  298. }
  299. return urlvars;
  300. };
  301. global.getUrlvars = () => {
  302. return localStorageGet("urlvars", "");
  303. };
  304. global.showDownBox = () => {
  305. if (global.downloadBox) global.downloadBox.show();
  306. };
  307. global.hideDownBox = () => {
  308. if (global.downloadBox) global.downloadBox.hide();
  309. };
  310. global.showShortcutGuide = () => {
  311. if (global.shortcutGuide) global.shortcutGuide.show();
  312. };
  313. global.hideShortcutGuide = () => {
  314. if (global.shortcutGuide) global.shortcutGuide.hide();
  315. };
  316. global.updateGameScore = (score) => {
  317. if (global.onUpdateGameScore) global.onUpdateGameScore(score);
  318. };
  319. global.onGameBack = () => {
  320. global.authLockPath = null;
  321. global.onUpdateGameScore = null;
  322. };
  323. global.openRecommandGame = () => {
  324. };
  325. global.showExclusiveGift = () => {
  326. if (global.exclusiveGift) global.exclusiveGift.show();
  327. };
  328. global.hideExclusiveGift = () => {
  329. if (global.exclusiveGift) global.exclusiveGift.hide();
  330. };
  331. global.shwoComebackWithdraw = () => {
  332. if (global.comebackWithdraw) global.comebackWithdraw.show();
  333. };
  334. global.hideComebackWithdraw = () => {
  335. if (global.comebackWithdraw) global.comebackWithdraw.hide();
  336. };
  337. global.showRecallGift = () => {
  338. if (global.recallGift) global.recallGift.show();
  339. };
  340. global.hideRecallGift = () => {
  341. if (global.recallGift) global.recallGift.hide();
  342. };
  343. global.showSidebar = () => {
  344. if (global.homeSidebar) global.homeSidebar.show();
  345. };
  346. //wd pass
  347. var popupFlow = [];
  348. global.addPopupFlow = (func) => {
  349. popupFlow.push(func);
  350. };
  351. global.clearPopupFlow = () => {
  352. popupFlow = [];
  353. };
  354. global.isEmptyPopups = () => {
  355. return popupFlow.length === 0;
  356. };
  357. global.openNextPopup = async () => {
  358. while (popupFlow.length > 0) {
  359. await Promise.resolve();
  360. const popup = popupFlow.shift();
  361. if (!!popup && popup()) {
  362. return;
  363. }
  364. }
  365. };
  366. global.showSecurityScan=()=>{
  367. if (global.securityScan) global.securityScan.show();
  368. };
  369. global.hideSecurityScan = () => {
  370. if (global.securityScan) global.securityScan.hide();
  371. }
  372. global.showQuickInstall=()=>{
  373. if (global.quickInstall) global.quickInstall.show();
  374. }
  375. global.hideQuickInstall = () => {
  376. if (global.quickInstall) global.quickInstall.hide();
  377. }