CommonParams.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { sys, view } from 'cc';
  2. import { localStorageGet } from '../utils/Helper';
  3. import { LOCAL_ACTIVITY_C, LOCAL_FINGERPRINT_KEY, LOCAL_SIGN } from '../constants/Localkey';
  4. import AppConfig from '../app/AppConfig';
  5. import { AppKernel } from '../app/AppKernel';
  6. function getSign() {
  7. return localStorageGet(LOCAL_SIGN, '');
  8. }
  9. function getC() {
  10. return localStorageGet(LOCAL_ACTIVITY_C, "");
  11. }
  12. function getFF() {
  13. const platform = AppKernel.platform;
  14. const uuid = platform.getUUID();
  15. return uuid;
  16. //// h5 平台初始化的时候 使用fingerprintjs写入本地
  17. // return localStorageGet(LOCAL_FINGERPRINT_KEY, "");
  18. }
  19. function getBFP() {
  20. const platform = AppKernel.platform;
  21. const uuid = platform.getUUID();
  22. return uuid;
  23. }
  24. export function getComParams() {
  25. const params: any = {};
  26. params.bfp = getBFP();
  27. const ff = getFF();
  28. if (!!ff) params.ff = ff;
  29. params.regionid = AppConfig.ProductName;
  30. const sign = getSign();
  31. if (!!sign) params.sign = sign;
  32. const c = getC();
  33. if (!!c) params.c = c;
  34. const size = view.getVisibleSize();
  35. params._d = sys.isMobile ? 'm' : 'd';
  36. params._t = `${Date.now()}_${Math.round(size.width)}_${Math.round(size.height)}`;
  37. // params.pwa = 1;
  38. // params.act = act;
  39. return params;
  40. }