From f8a02b7f9f80ffc5ec727c32c89cb67534752437 Mon Sep 17 00:00:00 2001
From: fengerli <528575642@qq.com>
Date: Tue, 19 Aug 2025 11:48:12 +0800
Subject: [PATCH] =?UTF-8?q?=E5=B0=81=E8=A3=85=E5=AE=9E=E6=97=B6=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3=EF=BC=8C=E8=AF=B7=E6=B1=82=EF=BC=8C=E5=85=B1=E5=A4=9A?=
=?UTF-8?q?=E4=B8=AA=E9=A1=B5=E9=9D=A2=E8=B0=83=E7=94=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/6170/callPolice/index.vue | 773 ++++++++++++++---------------
pages/6170/deviceControl/index.vue | 162 +++---
pages/common/send/index.vue | 692 +++++++++++++-------------
utils/function.js | 74 ++-
4 files changed, 840 insertions(+), 861 deletions(-)
diff --git a/pages/6170/callPolice/index.vue b/pages/6170/callPolice/index.vue
index 99f4a2e..9bc4a43 100644
--- a/pages/6170/callPolice/index.vue
+++ b/pages/6170/callPolice/index.vue
@@ -47,448 +47,421 @@
\ No newline at end of file
diff --git a/pages/6170/deviceControl/index.vue b/pages/6170/deviceControl/index.vue
index 8ed74fe..de4b3ea 100644
--- a/pages/6170/deviceControl/index.vue
+++ b/pages/6170/deviceControl/index.vue
@@ -271,7 +271,8 @@
\ No newline at end of file
diff --git a/utils/function.js b/utils/function.js
index 1080018..e73e41f 100644
--- a/utils/function.js
+++ b/utils/function.js
@@ -2,15 +2,67 @@
* 生成短ID (16位字符)
*/
export const generateShortId = () => {
- const crypto = window.crypto || window.msCrypto;
-
- if (crypto?.getRandomValues) {
- return Array.from(crypto.getRandomValues(new Uint32Array(3)))
- .map(n => n.toString(36))
- .join('')
- .slice(0, 16);
- }
-
- return Date.now().toString(36) + Math.random().toString(36).substr(2, 8);
+ const crypto = window.crypto || window.msCrypto;
+
+ if (crypto?.getRandomValues) {
+ return Array.from(crypto.getRandomValues(new Uint32Array(3)))
+ .map(n => n.toString(36))
+ .join('')
+ .slice(0, 16);
+ }
+
+ return Date.now().toString(36) + Math.random().toString(36).substr(2, 8);
};
-export default generateShortId;
\ No newline at end of file
+export default generateShortId;
+
+// 获取设备实时状态的
+/**
+ * 获取设备状态(带自动轮询)
+ * @param {Object} options - 配置对象
+ * @param {number} options.functionMode - 功能模式
+ * @param {string} options.batchId - 批次ID
+ * @param {Object} options.sendInfo - 设备信息
+ * @param {string} options.sendInfo.typeName - 类型名称
+ * @param {string} options.sendInfo.deviceImei - 设备IMEI
+ * @param {number} [options.interval=500] - 轮询间隔(毫秒)
+ * @param {Function} apiClient - 接口调用函数
+ */
+export async function getdeviceSTatus({
+ functionMode,
+ batchId,
+ typeName,
+ deviceImei,
+ interval
+}, apiClient) {
+ const checkStatus = async () => {
+ try {
+ const res = await apiClient({
+ functionMode,
+ batchId,
+ typeName,
+ deviceImei
+ });
+ if (res.code !== 200) {
+ throw new Error(res.msg || '请求失败');
+ }
+ switch (res.data.functionAccess) {
+ case 'OK':
+ return res;
+ case 'ACTIVE':
+ await new Promise(r => setTimeout(r, interval));
+ return checkStatus();
+ case 'FAILED':
+ throw new Error('设备操作失败');
+ case 'TIMEOUT':
+ throw new Error('设备响应超时');
+ default:
+ throw new Error('未知状态');
+ }
+ } catch (error) {
+ console.error('设备状态轮询错误:', error);
+ throw error;
+ }
+ };
+
+ return checkStatus();
+}
\ No newline at end of file