From d7704349bbaf4eab3c8c9dd44f40e898623afc36 Mon Sep 17 00:00:00 2001 From: "3321822538@qq.com" <3321822538@qq.com> Date: Wed, 25 Feb 2026 18:01:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=87=E8=8A=B1=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/http.interceptor.js | 4 +- page_newyemian/wgkongzhi.vue | 56 ++- page_user/upload.vue | 16 +- pages/gateway/xq.vue | 714 +++++++++++++++++++++++++++-------- pages/index/index.vue | 453 +++++++++++++++++++--- 5 files changed, 1004 insertions(+), 239 deletions(-) diff --git a/common/http.interceptor.js b/common/http.interceptor.js index 8e011db..764fdfb 100644 --- a/common/http.interceptor.js +++ b/common/http.interceptor.js @@ -1,7 +1,7 @@ const install = (Vue, vm) => { Vue.prototype.$u.http.setConfig({ - // baseUrl: 'https://yxd.ccttiot.com/prod-api', - baseUrl: 'http://192.168.1.3:8081', + baseUrl: 'https://yxd.ccttiot.com/prod-api', + // baseUrl: 'http://192.168.1.4:8081', loadingText: '努力加载中~', loadingTime: 800, // 设置自定义头部content-type diff --git a/page_newyemian/wgkongzhi.vue b/page_newyemian/wgkongzhi.vue index 2396fac..1774e1c 100644 --- a/page_newyemian/wgkongzhi.vue +++ b/page_newyemian/wgkongzhi.vue @@ -15,7 +15,7 @@ 网关MAC号:{{obj.mac == undefined ? '--' : obj.mac}} 离线 在线 --> - + @@ -39,12 +39,12 @@ VER - {{obj.dataPoints && obj.dataPoints.VER ? obj.dataPoints.VER.value : '--'}} + {{obj.iotData && obj.iotData.VER ? obj.iotData.VER.value : '--'}} CSQ - {{obj.dataPoints && obj.dataPoints.CSQ ? obj.dataPoints.CSQ.value : '--'}} + {{obj.iotData && obj.iotData.CSQ ? obj.iotData.CSQ.value : '--'}} 更新 @@ -74,13 +74,13 @@ {{macobj.onlineStatus == '1' ? '在线' : '离线'}} - 版本: {{macobj.dataPoints.ver.value == null ? '--' : macobj.dataPoints.ver.value}} - 信号:{{macobj.dataPoints.RSSI.value == null ? '--' : macobj.dataPoints.RSSI.value}} + 版本: {{macobj.iotData.ver.value == null ? '--' : macobj.iotData.ver.value}} + 信号:{{macobj.iotData.RSSI.value == null ? '--' : macobj.iotData.RSSI.value}} - + {{macobj.bluetoothDbm}}dBm @@ -88,7 +88,7 @@ - 更新时间: {{macobj.dataPoints.RSSI.at == null ? '--' : macobj.dataPoints.RSSI.at}} + 更新时间: {{macobj.iotData.RSSI.at == null ? '--' : macobj.iotData.RSSI.at}} 状态信息 @@ -147,7 +147,8 @@ xshu:'1', x:'', macsb:'', - macobj:{} + macobj:{}, + btnflag:true } }, onLoad(options) { @@ -198,17 +199,17 @@ } }, getver() { - if (!this.macobj || !this.macobj.dataPoints) { + if (!this.macobj || !this.macobj.iotData) { return '--'; } - return this.macobj.dataPoints.ver + return this.macobj.iotData.ver }, - // 获取设备状态(根据dataPoints.d判断) + // 获取设备状态(根据iotData.d判断) getDeviceStatus() { - if (!this.macobj || !this.macobj.dataPoints) { + if (!this.macobj || !this.macobj.iotData) { return '--'; } - const d = this.macobj.dataPoints.water_sw.value; + const d = this.macobj.iotData.water_sw.value; if (d === 0 || d === '0') { return '关闭'; } else if (d === 1 || d === '1') { @@ -281,7 +282,7 @@ }, // 根据设备sn获取设备详情 getsn() { - this.$u.get(`/device/device/getDetail?sn=${this.storeId}`).then(res => { + this.$u.get(`/device/device/getDetail/specGateway?sn=${this.storeId}`).then(res => { if (res.code == 200) { if(res.data == null){ this.clearInterval() @@ -360,7 +361,7 @@ this.$u.get(`/system/config/configKey/device.gateway.test.mac`).then(res =>{ if(res.code == 200){ this.macsb = res.data - this.$u.get(`/device/device/getDetail?mac=${this.macsb}&gatewayMacList=${this.obj.mac}`).then(resp =>{ + this.$u.get(`/device/device/getDetail/specGateway?mac=${this.macsb}&gatewayMacList=${this.obj.mac}`).then(resp =>{ if(resp.code == 200){ this.getsn() this.id = resp.data.deviceId @@ -396,7 +397,7 @@ this.$u.get(`/system/config/configKey/device.gateway.test.mac`).then(res =>{ if(res.code == 200){ this.macsb = res.data - this.$u.get(`/device/device/getDetail?mac=${this.macsb}&gatewayMacList=${this.obj.mac}`).then(resp =>{ + this.$u.get(`/device/device/getDetail/specGateway?mac=${this.macsb}&gatewayMacList=${this.obj.mac}`).then(resp =>{ if(resp.code == 200){ this.id = resp.data.deviceId this.macobj = resp.data @@ -420,6 +421,11 @@ // 关闭 btngb() { + if(this.btnflag == false){ + + return + } + this.btnflag = false uni.showLoading({ title: '关闭中...', mask: true, @@ -439,6 +445,9 @@ icon: 'success', duration: 2000 }) + setTimeout(()=>{ + this.btnflag = true + },3000) } else { uni.hideLoading() uni.showToast({ @@ -446,11 +455,18 @@ icon: 'none', duration: 2000 }) + setTimeout(()=>{ + this.btnflag = true + },1000) } }) }, // 开启 btngbkq() { + if(this.btnflag == false){ + return + } + this.btnflag = false uni.showLoading({ title: '开启中...', mask: true, @@ -471,6 +487,9 @@ icon: 'success', duration: 2000 }) + setTimeout(()=>{ + this.btnflag = true + },1000) } else { uni.hideLoading() uni.showToast({ @@ -478,12 +497,15 @@ icon: 'none', duration: 2000 }) + setTimeout(()=>{ + this.btnflag = true + },3000) } }) }, // 刷新 btnsx() { - this.$u.get(`/device/device/getDetail?mac=${this.macsb}&gatewayMacList=${this.obj.mac}`).then(resp =>{ + this.$u.get(`/device/device/getDetail/specGateway?mac=${this.macsb}&gatewayMacList=${this.obj.mac}`).then(resp =>{ if(resp.code == 200){ this.id = resp.data.deviceId this.macobj = resp.data diff --git a/page_user/upload.vue b/page_user/upload.vue index 1281edb..5577b38 100644 --- a/page_user/upload.vue +++ b/page_user/upload.vue @@ -26,13 +26,13 @@ 固件更新 - + 点击更新 - 当前版本:{{ver == null ? '请连接蓝牙获取当前版本' : ver}} + 当前版本:{{ ver == null ? '请连接蓝牙获取当前版本' : (ver.length > 4 ? ver.slice(0,4) : ver) }} 最新版本:{{version == null ? '' : version}} @@ -277,6 +277,9 @@ if (res.code == 200) { this.pre = res.data.pre this.version = res.data.version + if(this.ver.length > 4){ + this.ver = this.ver.slice(0,4) + } console.log(this.ver,'当前蓝牙版本号',this.version,'最新蓝牙版本号'); this.file = res.data.asDeviceVersion.file console.log(this.file) @@ -405,6 +408,9 @@ duration: 2000 }) this.ver = this.version + if(this.ver.length > 4){ + this.ver = this.ver.slice(0,4) + } setTimeout(()=>{ this.shengjiflag = false uni.reLaunch({ @@ -486,10 +492,10 @@ console.log(showObject,'showObjectshowObject'); // 从 this.ver 中提取数字 const verNumber = parseInt(this.ver.replace(/\D/g, '')) || 0; - if(verNumber >= 290){ - this.xinpin = showObject.showArray[showObject.showArray.length - 1] - }else{ + if(showObject.showArray.length > 9){ this.xinpin = showObject.showArray[showObject.showArray.length - 2] + }else{ + this.xinpin = showObject.showArray[showObject.showArray.length - 1] } } break; diff --git a/pages/gateway/xq.vue b/pages/gateway/xq.vue index 442d10d..1347236 100644 --- a/pages/gateway/xq.vue +++ b/pages/gateway/xq.vue @@ -2,12 +2,30 @@ + + + + + 信号: + + {{ wgxq.iotData.CSQ.value }} + -- + + + + 版本: + + {{ getVersion() || '--' }} + + + - {{ wgxq.deviceName || '未命名设备' }} + {{ gatewayName || '网关' }} + {{ wgxq.onlineStatus == 1 ? '在线' : '离线' }} @@ -57,7 +75,16 @@ {{ item.deviceName || '未命名设备' }} {{ item.modelName || '--' }} - + + + + + + + + + 暂无设备 @@ -67,6 +94,19 @@ 解绑 + + + + + + 修改网关名称 + + + 取消 + 确定 + + + @@ -80,6 +120,9 @@ id:'', wgxq:{}, wglist:[], + gatewayName: '网关', + showEditName: false, + editNameValue: '', } }, onLoad(e) { @@ -125,18 +168,117 @@ this.$u.get(`/app/device/getDetail?deviceId=${this.id}`).then((res) => { if (res.code == 200) { this.wgxq = res.data + // 设置网关名称,如果设备名称为空或未命名,使用默认值"网关" + this.gatewayName = res.data.deviceName && res.data.deviceName !== '未命名设备' ? res.data.deviceName : '网关' console.log(11); this.getlist() } }) }, + // 获取RSSI信号值 + getRSSIValue() { + if (this.wgxq.iotData && this.wgxq.iotData.RSSI && this.wgxq.iotData.RSSI.value !== undefined) { + return this.wgxq.iotData.RSSI.value + } + return null + }, + // 获取版本信息 + getVersion() { + if (this.wgxq.version) { + return this.wgxq.version + } + if (this.wgxq.iotData && this.wgxq.iotData.version) { + return this.wgxq.iotData.version + } + return null + }, + // 计算信号强度格数(基于RSSI) + getSignalLevel(item) { + // 获取设备的信号强度(RSSI) + let rssiValue = null + if (item.rssi) { + rssiValue = parseFloat(item.rssi) + } else if (item.rssi !== undefined) { + rssiValue = parseFloat(item.rssi) + } + + if (rssiValue === null || isNaN(rssiValue)) { + return 0 + } + + // 根据RSSI信号强度返回格数 + // -60到0为4格 + if (rssiValue >= -60 && rssiValue <= 0) { + return 4 + } + // -60到-80为3格(不包括-60,不包括-80) + if (rssiValue > -80 && rssiValue < -60) { + return 3 + } + // -80到-100为2格(包括-80,包括-100) + if (rssiValue >= -100 && rssiValue <= -80) { + return 2 + } + // -100以下为1格 + if (rssiValue < -100) { + return 1 + } + + return 0 + }, + // 显示修改名称弹窗 + showEditNameDialog() { + this.editNameValue = this.gatewayName + this.showEditName = true + }, + // 关闭修改名称弹窗 + closeEditNameDialog() { + this.showEditName = false + this.editNameValue = '' + }, + // 确认修改名称 + confirmEditName() { + if (!this.editNameValue.trim()) { + uni.showToast({ + title: '请输入网关名称', + icon: 'none', + duration: 2000 + }) + return + } + + this.$u.put(`/app/editDeviceName?deviceId=${this.id}&deviceName=${this.editNameValue.trim()}`).then(res => { + if (res.code == 200) { + this.gatewayName = this.editNameValue.trim() + this.wgxq.deviceName = this.editNameValue.trim() + this.closeEditNameDialog() + uni.showToast({ + title: '修改成功', + icon: 'success', + duration: 2000 + }) + } else { + uni.showToast({ + title: res.msg || '修改失败', + icon: 'none', + duration: 2000 + }) + } + }).catch(err => { + uni.showToast({ + title: '修改失败', + icon: 'none', + duration: 2000 + }) + }) + }, // 查询网关下的设备 getlist(){ console.log(111); - let data = { - gatewayMacList: [this.wgxq.mac] - } - this.$u.post(`/app/device/gateway/list`, data).then((res) => { + // let data = { + // mac: + // } + this.$u.get(`/app/device/gateway/gateWaySubDeviceList?gatewayMac=${this.wgxq.mac}&pageNum=1&pageSize=99`).then((res) => { if (res.code == 200) { this.wglist = res.rows } @@ -147,37 +289,154 @@