ソースを参照

feat(gate): 添加闸机灯光效果控制功能

新增灯光效果配置文件 Light.js,包含不同状态的灯光效果定义
在 ControlGate.vue 中根据闸机命令调用对应的灯光效果
yangzhijie 5 ヶ月 前
コミット
e12e2c0a57
2 ファイル変更65 行追加1 行削除
  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,
+}