Browse Source

fingerprint 换uuid

zhejiushizhuce 1 year ago
parent
commit
9ea8f3e562
2 changed files with 20 additions and 14 deletions
  1. 2 1
      package.json
  2. 18 13
      src/features/mainSlice.js

+ 2 - 1
package.json

@@ -89,7 +89,8 @@
     "swiper": "^11.1.4",
     "ua-parser-js": "^1.0.38",
     "use-gauge": "^0.5.0",
-    "use-mobile-detect-hook": "^1.0.5"
+    "use-mobile-detect-hook": "^1.0.5",
+    "uuid": "^11.0.3"
   },
   "scripts": {
     "start": "craco start",

+ 18 - 13
src/features/mainSlice.js

@@ -46,6 +46,7 @@ import {
 import {reqPayConfig} from "@features/paySlice";
 import FingerprintJS from '@fingerprintjs/fingerprintjs'
 import {APP_LOGIN_TYPE} from "@constants/app";
+import { v4 as uuidv4 } from 'uuid';
 const i18n=global.i18n;
 const generateNavs=(routes)=>{
     const navs=[];
@@ -996,22 +997,26 @@ export const getBFP=()=>{
             global.BFP=bfp;
             return bfp;
         }
+        bfp=uuidv4();
+        localStorageSet(LOCAL_VISTOR_ID,bfp);
+        global.BFP=bfp;
         // const fpPromise = FingerprintJS.load({
         //     apiKey: "W7zWifGvJhjacPekHi64"
         // })
-        const fpPromise =FingerprintJS.load();
-        try {
-            let fp=await fpPromise;
-            let result=await fp.get();
-            if (result!=null){
-                bfp=result.visitorId;
-                localStorageSet(LOCAL_VISTOR_ID,bfp);
-                global.BFP=bfp;
-            }
-        }
-        catch (err){
-            console.log(err);
-        }
+        //换成uuid
+        // const fpPromise =FingerprintJS.load();
+        // try {
+        //     let fp=await fpPromise;
+        //     let result=await fp.get();
+        //     if (result!=null){
+        //         bfp=result.visitorId;
+        //         localStorageSet(LOCAL_VISTOR_ID,bfp);
+        //         global.BFP=bfp;
+        //     }
+        // }
+        // catch (err){
+        //     console.log(err);
+        // }
         return bfp;
     }
 }