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 1/3] =?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); }, From 64529bf573ee9b436084770c535fec1074185158 Mon Sep 17 00:00:00 2001 From: fengerli <528575642@qq.com> Date: Sat, 16 Aug 2025 14:28:21 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=91=E9=80=81?= =?UTF-8?q?=E4=BF=A1=E6=81=AFbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/6170/deviceControl/index.vue | 31 +++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/pages/6170/deviceControl/index.vue b/pages/6170/deviceControl/index.vue index 176f31c..bc2ce87 100644 --- a/pages/6170/deviceControl/index.vue +++ b/pages/6170/deviceControl/index.vue @@ -1033,9 +1033,10 @@ this.isSharedDevice = false; this.activePermissions = []; // 非分享设备清空权限 } - - // 关闭加载中 - uni.hideLoading() + if (!isUpdate) { + // 关闭加载中 + uni.hideLoading() + } } }, // 检查权限的方法 @@ -1050,18 +1051,22 @@ async fetchDeviceDetail(id, isUpdate = false) { try { const res = await deviceDetail(id) - if(res.code==200){ + if (res.code == 200) { this.handleDeviceData(res, false, isUpdate) - }else{ + } else { uni.showToast({ - title: error.msg, + title: res.msg, icon: 'none' }) + if (!isUpdate) { + uni.hideLoading() + } + } + + } catch (error) { + if (!isUpdate) { uni.hideLoading() } - - } catch (error) { - uni.hideLoading() // uni.showToast({ // title: error.msg, // icon: 'none' @@ -1072,15 +1077,15 @@ async fetchSharedDeviceDetail(id) { try { const res = await deviceShareId(id) - if(res.code==200){ + if (res.code == 200) { this.handleDeviceData(res, true) - }else{ + } else { uni.showToast({ - title: error.msg, + title: res.msg, icon: 'none' }) } - + } catch (error) { uni.showToast({ title: error.msg, From 823c54aed77fd5e3413c9663451a2801846d6a29 Mon Sep 17 00:00:00 2001 From: fengerli <528575642@qq.com> Date: Sat, 16 Aug 2025 17:37:24 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=8A=A5=E8=AD=A6?= =?UTF-8?q?=EF=BC=8C=E8=8E=B7=E5=8F=96=E8=AE=BE=E5=A4=87=E5=AE=9E=E6=97=B6?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/6170/allShare/index.vue | 6 +- pages/6170/callPolice/index.vue | 753 +++++++++++++++-------------- pages/6170/deviceControl/index.vue | 93 ++-- pages/common/send/index.vue | 1 - 4 files changed, 465 insertions(+), 388 deletions(-) diff --git a/pages/6170/allShare/index.vue b/pages/6170/allShare/index.vue index bb6a4ef..cc0307e 100644 --- a/pages/6170/allShare/index.vue +++ b/pages/6170/allShare/index.vue @@ -249,14 +249,10 @@ }, onLoad() { this.onIntall() - // 绑定页面做了监听,新增成功,刷新页面 - uni.$on('refreshDeviceList', () => { - this.onIntall() - }); }, beforeDestroy() { // 组件销毁前移除监听器 - uni.$off('refreshDeviceList'); + }, } diff --git a/pages/6170/callPolice/index.vue b/pages/6170/callPolice/index.vue index 2fda5e2..99f4a2e 100644 --- a/pages/6170/callPolice/index.vue +++ b/pages/6170/callPolice/index.vue @@ -3,9 +3,10 @@ 全选 - + - + @@ -46,400 +47,448 @@ \ No newline at end of file diff --git a/pages/6170/deviceControl/index.vue b/pages/6170/deviceControl/index.vue index bc2ce87..8ed74fe 100644 --- a/pages/6170/deviceControl/index.vue +++ b/pages/6170/deviceControl/index.vue @@ -309,6 +309,7 @@ lightModeB: false, lightModeC: false, //激光提示框 items: [], + pendingMainMode: null, // 选中的索引 isFormExpanded: true, // 默认展开 deviceID: '', itemInfo: {}, @@ -553,21 +554,38 @@ toggleForm() { this.isFormExpanded = !this.isFormExpanded; }, + // onItemClick(index) { + // const selectedItem = this.items[index]; + // if (selectedItem.text === '激光') { + // this.lightModeC = true; + // } else { + // // 更新选中状态 + // this.items = this.items.map((item, i) => ({ + // ...item, + // selected: i === index + // })); + // this.currentMainMode = selectedItem.text; + // this.selectedItemIndex = index; + // // 强制更新视图(如果需要) + // this.$forceUpdate(); + // } + // }, onItemClick(index) { - const selectedItem = this.items[index]; - if (selectedItem.text === '激光') { + const item = this.items[index]; + // 激光模式特殊处理 + if (item.text === '激光') { this.lightModeC = true; - } else { - // 更新选中状态 - this.items = this.items.map((item, i) => ({ - ...item, - selected: i === index - })); - this.currentMainMode = selectedItem.text; - this.selectedItemIndex = index; - // 强制更新视图(如果需要) - this.$forceUpdate(); + return; } + // 只更新临时选中状态 + this.selectedItemIndex = index; + // UI高亮效果(不影响实际模式) + this.items = this.items.map((item, i) => ({ + ...item, + selected: i === index + })); + // 显示临时选中的模式名称(视觉反馈) + this.pendingMainMode = item.text; }, // 灯光模式的确认 handleSumbit() { @@ -589,7 +607,6 @@ this.isProcessing = true if (this.selectedItemIndex === null) return; const selectedItem = this.items[this.selectedItemIndex]; - // 准备请求数据 let data = { deviceId: this.computedDeviceId, instructValue: selectedItem.instructValue, @@ -598,6 +615,9 @@ }; lightModeSettings(data).then((res) => { if (res.code == 200) { + // 只有确认成功才更新实际模式,选中模式 + this.currentMainMode = this.pendingMainMode; + this.selectedItemIndex = selectedItem; uni.showToast({ title: res.msg, icon: 'none' @@ -914,20 +934,29 @@ }; // 3.解除告警状态 const registerRes = await deviceSendAlarmMessage(data); - if (registerRes.code == 200) { + 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') { uni.showToast({ title: statusRes.msg, icon: 'none' }); - // 刷新详情接口 - this.fetchDeviceDetail(this.computedDeviceId, true); uni.$emit('deviceStatusUpdate', {}); this.showPopupFlag = false - } else { - uni.showToast({ - title: registerRes.message, - icon: 'none' - }); + if (this.apiType === 'listA') { + this.fetchDeviceDetail(this.computedDeviceId) + } else { + // 分享权限详情 + this.fetchSharedDeviceDetail(this.itemInfo.id) + } + } } catch (error) { uni.showToast({ @@ -1091,6 +1120,7 @@ title: error.msg, icon: 'none' }) + uni.hideLoading() } }, // 操作说明 @@ -1187,15 +1217,18 @@ this.deviceInfo.batteryRemainingTime = deviceState[5]; } setTimeout(() => { - this.fetchDeviceDetail(data.data.id, true).then( - () => { - if (this.deviceInfo.batteryPercentage < - 20) { - this.popupType = 'bettery'; - this.popupMessage = '请及时充电'; - this.showPopupFlag = true; - } - }); + if (this.deviceInfo.batteryPercentage < + 20) { + this.popupType = 'bettery'; + this.popupMessage = '请及时充电'; + this.showPopupFlag = true; + } + if (this.apiType === 'listA') { + this.fetchDeviceDetail(data.data.id) + } else { + // 分享权限详情 + this.fetchSharedDeviceDetail(data.data.id) + } }, 10000); // 上报电量,在列表里面同步 uni.$emit('deviceStatusUpdate', { diff --git a/pages/common/send/index.vue b/pages/common/send/index.vue index 7861a5c..5d35263 100644 --- a/pages/common/send/index.vue +++ b/pages/common/send/index.vue @@ -82,7 +82,6 @@ * @param {number} [interval=1000] - 轮询间隔(毫秒) */ async getdeviceSTatus(val, batchId, interval = 800) { - let retries = 0; const checkStatus = async () => { try { const data = {