From fe5545b642fc7339fb91ace144addf5fdc4c3b12 Mon Sep 17 00:00:00 2001 From: fengerli <528575642@qq.com> Date: Sat, 16 Aug 2025 13:59:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96mqtt=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/index.js | 4 +- pages.json | 6 +- pages/6170/callPolice/index.vue | 77 +- pages/6170/deviceControl/index.vue | 2780 ++++++++++++++-------------- pages/common/send/index.vue | 18 +- pages/common/user/index.vue | 2 +- utils/request.js | 4 +- 7 files changed, 1443 insertions(+), 1448 deletions(-) diff --git a/config/index.js b/config/index.js index a655ae5..e977462 100644 --- a/config/index.js +++ b/config/index.js @@ -6,7 +6,7 @@ const config = { API_PREFIX: '', // MQTT 配置 MQTT_HOST: '47.120.79.150', - MQTT_PORT: 8083, + MQTT_PORT: 9083, MQTT_USERNAME: 'admin', MQTT_PASSWORD: '#YtvpSfCNG' }, @@ -16,7 +16,7 @@ const config = { API_PREFIX: '', // MQTT 配置 MQTT_HOST: '47.120.79.150', - MQTT_PORT: 8083, + MQTT_PORT: 9083, MQTT_USERNAME: 'admin', MQTT_PASSWORD: '#YtvpSfCNG' } diff --git a/pages.json b/pages.json index afe1ed9..ff2076b 100644 --- a/pages.json +++ b/pages.json @@ -36,7 +36,8 @@ { "path": "pages/common/send/index", "style": { - "navigationBarTitleText": "发送信息" + "navigationBarTitleText": "发送信息", + "enablePullDownRefresh": true } }, { @@ -66,7 +67,8 @@ { "path": "pages/6170/callPolice/index", "style": { - "navigationBarTitleText": "报警" + "navigationBarTitleText": "报警", + "enablePullDownRefresh": true } }, diff --git a/pages/6170/callPolice/index.vue b/pages/6170/callPolice/index.vue index d496b60..2fda5e2 100644 --- a/pages/6170/callPolice/index.vue +++ b/pages/6170/callPolice/index.vue @@ -3,9 +3,9 @@ 全选 - + - + @@ -81,45 +81,6 @@ } }, methods: { - /** - * 获取设备状态(带自动轮询) - * @param {number} val - 功能模式 - * @param {string} batchId - 批次ID - * @param {number} [interval=1000] - 轮询间隔(毫秒) - */ - async getdeviceSTatus(val, batchId, interval = 800) { - let retries = 0; - const checkStatus = async () => { - try { - const data = { - functionMode: val, //批量的传2 - batchId: batchId, - typeName: this.sendInfo.typeName, - deviceImei: this.sendInfo.deviceImei - }; - const res = await deviceRealTimeStatus(data); - 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) { - throw error; - } - }; - return checkStatus(); - }, onclosePopup() { this.showPopupFlag = false }, @@ -142,7 +103,7 @@ this.loading = true; let data = { pageNum: 1, - pageSize: 30, + pageSize: 50, deviceType: deviceType } deviceInfo(data).then((res) => { @@ -195,33 +156,20 @@ const selectedDevices = this.deviceList.filter(item => item.checked); const deviceIds = selectedDevices.map(item => item.id); const deviceImeiList = selectedDevices.map(item => item.deviceImei); - const isAlarming = this.pendingAlarmAction == 1; + const isAlarming = this.pendingAlarmAction == 1; try { uni.showLoading({ title: isAlarming ? '设备报警中...' : '解除报警中...', mask: true }); - // 2. 准备请求数据 - const batchId = generateShortId(); const data = { deviceIds: deviceIds, - batchId: batchId, typeName: this.sendInfo.typeName, deviceImeiList: deviceImeiList, instructValue: this.pendingAlarmAction == 1 ? '1' : '0' }; - // 3.人员信息 const registerRes = await deviceSendAlarmMessage(data); - if (registerRes.code !== 200) { - uni.showToast({ - title: registerRes.msg, - icon: 'none' - }) - return - } - // 4. 获取设备状态 - const statusRes = await this.getdeviceSTatus(2, batchId); - if (statusRes.data.functionAccess === 'OK') { + if (registerRes.code == 200) { uni.showToast({ title: statusRes.msg, icon: 'none' @@ -231,6 +179,11 @@ setTimeout(() => { uni.navigateBack() }, 500) + } else { + uni.showToast({ + title: registerRes.msg, + icon: 'none' + }); } } catch (error) { uni.showToast({ @@ -479,4 +432,14 @@ border: 1px solid rgba(255, 255, 255, 0.87); background: rgba(18, 18, 18, 1); } + .checkbox.disabled { + opacity: 0.5; + background-color: rgba(255, 255, 255, 0.1) !important; + border-color: rgba(255, 255, 255, 0.2) !important; + pointer-events: none; /* 阻止点击事件 */ + } + /* 可选:离线设备的卡片整体置灰 */ + .device-card[data-offline="true"] { + opacity: 0.6; + } \ No newline at end of file diff --git a/pages/6170/deviceControl/index.vue b/pages/6170/deviceControl/index.vue index 6fe0ff0..176f31c 100644 --- a/pages/6170/deviceControl/index.vue +++ b/pages/6170/deviceControl/index.vue @@ -269,311 +269,318 @@ \ No newline at end of file diff --git a/pages/common/send/index.vue b/pages/common/send/index.vue index 370cf1c..7861a5c 100644 --- a/pages/common/send/index.vue +++ b/pages/common/send/index.vue @@ -2,9 +2,9 @@ - + - + @@ -71,6 +71,10 @@ } }, methods: { + onPullDownRefresh() { + // 执行下拉刷新时的操作,比如重新获取数据 + this.getData(); + }, /** * 获取设备状态(带自动轮询) * @param {number} val - 功能模式 @@ -419,4 +423,14 @@ border-radius: 50rpx; width: 90%; } + .checkbox.disabled { + opacity: 0.5; + background-color: rgba(255, 255, 255, 0.1) !important; + border-color: rgba(255, 255, 255, 0.2) !important; + pointer-events: none; /* 阻止点击事件 */ + } + /* 可选:离线设备的卡片整体置灰 */ + .device-card[data-offline="true"] { + opacity: 0.6; + } \ No newline at end of file diff --git a/pages/common/user/index.vue b/pages/common/user/index.vue index d3dfa59..1ff2974 100644 --- a/pages/common/user/index.vue +++ b/pages/common/user/index.vue @@ -6,7 +6,7 @@ - 富源晟科技 + 武汉研创 ID:123456 diff --git a/utils/request.js b/utils/request.js index a5f55e2..b113555 100644 --- a/utils/request.js +++ b/utils/request.js @@ -1,5 +1,5 @@ import config from '../config/index.js'; -const env = 'development'; //production development //开发of线上 改这里就行 +const env = 'production'; //production development //开发of线上 改这里就行 const BASE = config[env]; const request = (options) => { console.log("options"+JSON.stringify(options),BASE.BASE_URL) @@ -20,7 +20,7 @@ const request = (options) => { method: options.method || 'GET', data: options.method !== 'GET' ? options.data : {}, header: options.header || {}, - timeout: 10000, + timeout: 30000, success: (res) => { resolve(res.data); },