Global.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. global.i18n=i18n;
  8. // global.symbol=symbol;
  9. // global.symbol_m=symbol_m;
  10. global.CASH_BASE=100;
  11. global.DOLLAR="R$";
  12. global.currency="";
  13. global.dispatch=null;
  14. global.msgBox=null;
  15. global.msgBoxShow=(params)=>{
  16. if (global.msgBox)global.msgBox.show(params);
  17. }
  18. global.msgBoxHide=()=>{
  19. if (global.msgBox)global.msgBox.hide();
  20. }
  21. global.authLockPath=null;
  22. global.device="mobile";
  23. global.width=100;
  24. global.height=100;
  25. global.isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
  26. //游客id 指纹
  27. global.BFP=null;
  28. //wd pass
  29. global.getWDPass=()=>{
  30. let pass=localStorageGet(LOCAL_WD_PASS,"");
  31. if (pass!=null&&pass!==""){
  32. pass=decrypt(pass);
  33. let lsettime=localStorageGet(LOCAL_WD_PASS_SET_TIME,"");
  34. if (lsettime!=null){
  35. lsettime=Number(lsettime);
  36. let now=Date.now();
  37. let during=now-lsettime;
  38. //10m
  39. let deadline=10*60*1000;
  40. if (during<deadline)return pass;
  41. else {
  42. localStorageSet(LOCAL_WD_PASS,"");
  43. localStorageSet(LOCAL_WD_PASS_SET_TIME,"");
  44. }
  45. }
  46. }
  47. return "";
  48. }
  49. global.setWDPass=(value)=>{
  50. if (value==null)return;
  51. if (value!==""){
  52. value=encrypt(value);
  53. }
  54. localStorageSet(LOCAL_WD_PASS,value);
  55. localStorageSet(LOCAL_WD_PASS_SET_TIME,Date.now());
  56. }
  57. global.showDropCoins=()=>{
  58. if (global.dropCoins)global.dropCoins.show();
  59. }
  60. global.hideDropCoins=()=>{
  61. if (global.dropCoins)global.dropCoins.hide();
  62. }
  63. global.showMailNew=()=>{
  64. if (global.mailNew)global.mailNew.show();
  65. }
  66. global.hideMailNew=()=>{
  67. if (global.mailNew)global.mailNew.hide();
  68. }
  69. global.showInstallBox=()=>{
  70. if (global.installBox)global.installBox.show();
  71. }
  72. global.hideInstallBox=()=>{
  73. if (global.installBox)global.installBox.hide();
  74. }
  75. global.showBindPhone=()=>{
  76. if (global.bindPhone)global.bindPhone.show();
  77. }
  78. global.hideBindPhone=()=>{
  79. if (global.bindPhone)global.bindPhone.hide();
  80. }
  81. global.showBindPrompt=()=>{
  82. if (global.bindPrompt)global.bindPrompt.show();
  83. }
  84. global.hideBindPrompt=()=>{
  85. if (global.bindPrompt)global.bindPrompt.hide();
  86. }
  87. global.showProtectReward=()=>{
  88. if (global.protectReward)global.protectReward.show();
  89. }
  90. global.hideProtectReward=()=>{
  91. if (global.protectReward)global.protectReward.hide();
  92. }
  93. global.showLoadingCircular=(showMask=false)=>{
  94. if (global.loadingCircular)global.loadingCircular.show(showMask);
  95. }
  96. global.hideLoadingCircular=()=>{
  97. if (global.loadingCircular)global.loadingCircular.hide();
  98. }
  99. global.showFirstPay=()=>{
  100. if (global.firstPay)global.firstPay.show();
  101. }
  102. global.hideFirstPay=()=>{
  103. if (global.firstPay)global.firstPay.hide();
  104. }
  105. global.showAreaSelect=(allowClose=true)=>{
  106. if (global.areaSelect)global.areaSelect.show(allowClose);
  107. }
  108. global.hideAreaSelect=()=>{
  109. if (global.areaSelect)global.areaSelect.hide();
  110. }
  111. global.checkDomainArea=()=>{
  112. let areaID=0;
  113. let host=window.location.host;
  114. for (let i = 0; i < area.length; i++) {
  115. let item=area[i];
  116. if (item){
  117. let code=item.code;
  118. if (host.startsWith(code))
  119. {
  120. areaID=item.id;
  121. break;
  122. }
  123. }
  124. }
  125. return areaID;
  126. }
  127. global.getLocalAreaID=()=>{
  128. let areaID=Number(localStorageGet(LOCAL_AREA_ID,0));
  129. if (areaID===0){
  130. let dAreaID=global.checkDomainArea();
  131. if (dAreaID!==0){
  132. localStorageSet(LOCAL_AREA_ID,dAreaID+"");
  133. areaID=dAreaID;
  134. }
  135. }
  136. return areaID;
  137. }
  138. global.setLocalAreaID=(value)=>{
  139. localStorageSet(LOCAL_AREA_ID,value+"");
  140. window.location.reload();
  141. }
  142. global.getLocalAreaItem=()=>{
  143. let areaID=global.getLocalAreaID();
  144. for (let i = 0; i < area.length; i++) {
  145. let item=area[i];
  146. if (item){
  147. if (item.id===areaID){
  148. return item;
  149. }
  150. }
  151. }
  152. return null;
  153. }
  154. global.getLocalAreaAlCode=()=>{
  155. let code='en-US';
  156. let item=global.getLocalAreaItem();
  157. if (item){
  158. code=item.alcode;
  159. }
  160. return code;
  161. }
  162. global.showSaveAccount=(info)=>{
  163. if (global.saveAccount)global.saveAccount.show(info);
  164. }
  165. global.hideSaveAccount=()=>{
  166. if (global.saveAccount)global.saveAccount.hide();
  167. }
  168. global.showBonusPack=()=>{
  169. if (global.bonusPack)global.bonusPack.show();
  170. }
  171. global.hideBonusPack=()=>{
  172. if (global.bonusPack)global.bonusPack.hide();
  173. }
  174. //初始化urlvars
  175. global.checkUrlvars=()=>{
  176. let urlvars=localStorageGet("urlvars","");
  177. if (urlvars==null||urlvars===""){
  178. let json=getUrlParamsAsJsonManual();
  179. if (json!=null){
  180. urlvars=JSON.stringify(json);
  181. localStorageSet("urlvars",urlvars);
  182. }
  183. }
  184. return urlvars;
  185. }
  186. global.getUrlvars=()=>{
  187. return localStorageGet("urlvars", "");
  188. }
  189. //wd pass