2 Commits b1bd1a2d3d ... d43d3f8f71

Auteur SHA1 Message Date
  yangzhijie d43d3f8f71 style(gate): 统一代码缩进和引号格式 il y a 5 mois
  yangzhijie e12e2c0a57 feat(gate): 添加闸机灯光效果控制功能 il y a 5 mois
2 fichiers modifiés avec 65 ajouts et 1 suppressions
  1. 11 1
      src/gate/ControlGate.vue
  2. 54 0
      src/gate/Light.js

+ 11 - 1
src/gate/ControlGate.vue

@@ -145,7 +145,7 @@ import { ref, onMounted } from 'vue';
 import { useRouter } from 'vue-router';
 import { showNotify } from 'vant';
 import { controlGate, controlGateByBigInv, getGateStatus } from '../api/gate.js';
-
+import { LIGHT_NORMAL, LIGHT_OPEN, LIGHT_CLOSE, LIGHT_ALARM, LIGHT_RESTART } from '../gate/Light.js';
 // 图片资源
 import bgImg from '../assets/images/bj.png';
 // import { plugin } from 'postcss';
@@ -162,6 +162,7 @@ const goHome = () => {
     router.push('/home');
 };
 
+
 // 执行闸机控制
 const handleControl = async (command, actionName, isBigInv) => {
     loading.value = true;
@@ -174,6 +175,15 @@ const handleControl = async (command, actionName, isBigInv) => {
         //     res = await controlGate(command);
         // }
         plugin.gateConfig.controlGate(command);
+        if(command == 'OPEN' || command == 'SHOTOPEN'){
+            plugin.gateConfig.controlLight(JSON.stringify(LIGHT_OPEN));
+        }else if(command == 'CLOSE'){
+            plugin.gateConfig.controlLight(JSON.stringify(LIGHT_CLOSE));
+        }else if(command == 'REBOOT'){
+            plugin.gateConfig.controlLight(JSON.stringify(LIGHT_RESTART));
+        }else if(command == 'ALARM'){
+            plugin.gateConfig.controlLight(JSON.stringify(LIGHT_ALARM));
+        }
         showNotify({ type: 'success', message: `${actionName}操作成功`, duration: 2000 });
         // if (res.errorCode === 0) {
         //     showNotify({ type: 'success', message: `${actionName}操作成功`, duration: 2000 });

+ 54 - 0
src/gate/Light.js

@@ -0,0 +1,54 @@
+
+const LIGHT_NORMAL = {
+    'lightEffect': 'BREATH',
+    'breathParams': {
+        'color': 6399885,
+        'speed': 3,
+        'lightOffInterval': 1000,
+    },
+};
+
+const LIGHT_OPEN = {
+    'lightEffect': 'FLOW',
+    'flowParams': {
+        'color': 16777215,
+        'repeat': false,
+        'flowInterval': 1,
+    },
+};
+
+const LIGHT_CLOSE = {
+    'lightEffect': 'FLOW_RESERVE',
+    'flowParams': {
+        'color': 16777215,
+        'repeat': false,
+        'flowInterval': 1,
+    },
+};
+
+const LIGHT_ALARM = {
+    'lightEffect': 'FLASH',
+    'flashParameters': {
+        'color': 16711680,
+        'lightOnInterval': 1000,
+        'lightOffInterval': 1000,
+    },
+};
+
+
+const LIGHT_RESTART = {
+    'lightEffect': 'FLASH',
+    'flashParameters': {
+        'color': 0xFFFFFF,
+        'lightOnInterval': 1000,
+        'lightOffInterval': 1000,
+    },
+};
+
+export {
+    LIGHT_NORMAL,
+    LIGHT_OPEN,
+    LIGHT_CLOSE,
+    LIGHT_ALARM,
+    LIGHT_RESTART,
+};