From d13e470cf0256e3ffbc3b0ad34df27ce0b0b5e5f Mon Sep 17 00:00:00 2001
From: Novecane <2322740715@qq.com>
Date: 星期六, 15 二月 2025 15:08:36 +0800
Subject: [PATCH] second commit

---
 unpackage/dist/dev/mp-weixin/pages/router/deviceInfo/index.js |   41 +++++++++++++++++++++++++++++++++++------
 1 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/unpackage/dist/dev/mp-weixin/pages/router/deviceInfo/index.js b/unpackage/dist/dev/mp-weixin/pages/router/deviceInfo/index.js
index 3308655..22eb8fc 100644
--- a/unpackage/dist/dev/mp-weixin/pages/router/deviceInfo/index.js
+++ b/unpackage/dist/dev/mp-weixin/pages/router/deviceInfo/index.js
@@ -10,6 +10,8 @@
     const logEntry = common_vendor.ref([]);
     const temp = common_vendor.ref({});
     const controInfo = common_vendor.ref({});
+    const flag = common_vendor.ref(false);
+    let positionInterval;
     common_vendor.onMounted(async () => {
       const option = getCurrentPages()[getCurrentPages().length - 1].options;
       const deviceInfo = JSON.parse(decodeURIComponent(option.device));
@@ -23,9 +25,31 @@
           ...deviceInfo
         };
       } catch (error) {
-        common_vendor.index.__f__("error", "at pages/router/deviceInfo/index.vue:88", "Failed to fetch device info:", error);
+        common_vendor.index.__f__("error", "at pages/router/deviceInfo/index.vue:92", "Failed to fetch device info:", error);
       }
     });
+    const startGetPosition = () => {
+      if (positionInterval) {
+        clearInterval(positionInterval);
+      }
+      common_vendor.index.showToast({
+        title: "操作设备中",
+        icon: "loading",
+        mask: true,
+        duration: 3500
+      });
+      positionInterval = setInterval(() => {
+        api_index.getControlInfo(state.value.facilityCode).then((res) => {
+          if (res.data.position >= 100) {
+            flag.value = false;
+            clearInterval(positionInterval);
+          }
+        }).catch((error) => {
+          common_vendor.index.__f__("error", "at pages/router/deviceInfo/index.vue:115", "Error fetching control info:", error);
+          clearInterval(positionInterval);
+        });
+      }, 2e3);
+    };
     const removeSharedDevice = async () => {
       temp.value = {
         facilityCode: state.value.facilityCode
@@ -43,7 +67,7 @@
           });
         }
       } catch (error) {
-        common_vendor.index.__f__("error", "at pages/router/deviceInfo/index.vue:112", "Failed to delete device:", error);
+        common_vendor.index.__f__("error", "at pages/router/deviceInfo/index.vue:144", "Failed to delete device:", error);
       }
     };
     const handleControlChange = (e) => {
@@ -52,8 +76,12 @@
         destinationPosition: e.detail.value
       };
       api_index.deviceControlInfo(controInfo.value).then((res) => {
+        if (res.code === 200) {
+          flag.value = true;
+          startGetPosition();
+        }
       }).catch((error) => {
-        common_vendor.index.__f__("error", "at pages/router/deviceInfo/index.vue:124", "Failed to control device:", error);
+        common_vendor.index.__f__("error", "at pages/router/deviceInfo/index.vue:161", "Failed to control device:", error);
       });
     };
     const getOpeHistory = () => {
@@ -62,7 +90,7 @@
           logEntry.value = res.data;
         }
       }).catch((e) => {
-        common_vendor.index.__f__("log", "at pages/router/deviceInfo/index.vue:135", "fail info", e);
+        common_vendor.index.__f__("log", "at pages/router/deviceInfo/index.vue:175", "fail info", e);
       });
     };
     const getControlData = () => {
@@ -81,7 +109,8 @@
         f: common_vendor.t(state.value.rssi),
         g: common_vendor.o(handleControlChange),
         h: controlValue.value,
-        i: common_vendor.f(logEntry.value, (item, index, i0) => {
+        i: flag.value,
+        j: common_vendor.f(logEntry.value, (item, index, i0) => {
           return {
             a: common_vendor.t(item.operateName),
             b: common_vendor.t(item.operateStatus),
@@ -89,7 +118,7 @@
             d: index
           };
         }),
-        j: common_vendor.o(removeSharedDevice)
+        k: common_vendor.o(removeSharedDevice)
       });
     };
   }

--
Gitblit v1.9.3