Browse Source

更换获取ID插件;

liudan 3 months ago
parent
commit
833c9ae52a
2 changed files with 27 additions and 9 deletions
  1. BIN
      dist.zip
  2. 27 9
      src/pages/home/Index.jsx

BIN
dist.zip


+ 27 - 9
src/pages/home/Index.jsx

@@ -3,10 +3,16 @@ import Login from '@components/login/Index.jsx';
 import DoctorScreen from '@pages/doctorScreen/Index.jsx';
 import BigScreen from '@pages/bigScreen/Index.jsx';
 import OperateScreen from '@pages/operateScreen/Index.jsx';
-import FingerprintJS from '@fingerprintjs/fingerprintjs';
+// import FingerprintJS from '@fingerprintjs/fingerprintjs';
 import { initSocket } from '@api/index.js';
 import { AntOutline, SetOutline } from 'antd-mobile-icons';
+import { Toast } from 'antd-mobile';
 
+// // 安卓相关处理
+
+window.webGetDeviceId = function (callback) {
+  window.callback = callback;
+};
 class Home extends React.Component {
   constructor(props) {
     super(props);
@@ -29,14 +35,26 @@ class Home extends React.Component {
   componentDidMount() {
     this.initDevice();
   }
-  initDevice = async() => {
-    const fp = await FingerprintJS.load();
-    const AndroidInfo = await fp.get();
-    this.setState({
-      deviceID: AndroidInfo?.visitorId,
-    }, () => {
-      this.loginInit();
-    });
+  initDevice = async () => {
+    //接收Android端身份证信息函数
+    window.webGetDeviceId = (deviceId) => {
+      Toast.show({
+        duration: 10000,
+        content: deviceId + '安卓',
+      });
+      this.setState({
+        deviceID: deviceId,
+      }, () => {
+        this.loginInit();
+      });
+    };
+    const ua = navigator.userAgent.toLowerCase();
+    if (/android/.test(ua)) {
+      window.JavaClientCall && window.JavaClientCall.getDeviceID();
+    }
+    // const fp = await FingerprintJS.load();
+    // const AndroidInfo = await fp.get();
+    
   };
   // 改变颜色
   changeSwitch = () => {