diff --git a/components/global-loading/global-loading.vue b/components/global-loading/global-loading.vue index 0848bec..2a73aab 100644 --- a/components/global-loading/global-loading.vue +++ b/components/global-loading/global-loading.vue @@ -100,6 +100,7 @@ if (options.dotColors) { this.colorIndex = 0 } + this.visible = true; }, // 阻止触摸移动事件 diff --git a/manifest.json b/manifest.json index 9058167..e142c32 100644 --- a/manifest.json +++ b/manifest.json @@ -24,7 +24,8 @@ "Geolocation" : {}, "Maps" : {}, "Record" : {}, - "VideoPlayer" : {} + "VideoPlayer" : {}, + "Push" : {} }, /* 应用发布信息 */ "distribute" : { diff --git a/pages/102/HBY102.vue b/pages/102/HBY102.vue index c11daab..6b0816d 100644 --- a/pages/102/HBY102.vue +++ b/pages/102/HBY102.vue @@ -48,8 +48,9 @@ 闯入报警! - + {{getWarDevice(formData.sta_sosadd)}} + @@ -171,10 +172,9 @@ hideLoading, updateLoading } from '@/utils/loading.js' - import { - request, + import request, { baseURL - } from '../../utils/request'; + } from '@/utils/request.js' import Common from '@/utils/Common.js' const pagePath = "/pages/102/HBY102"; @@ -432,6 +432,7 @@ }, methods: { + actionSett(item, index) { if (item.group == 'sta_LedType') { this.sosSetting(item, index); @@ -736,20 +737,7 @@ urls: [img] }) }, - getWarDevice(macStr){//获取正在报警的设备名 - let f = this.groupDevices.find(v => { - return v.deviceMac === macStr; - }); - if (f) { - return f.deviceName; - } - - if(macStr == this.device.deviceMac) { - return this.device.deviceName; - } - - return ''; - }, + bleValueNotify(receive, device, path, recArr) { //订阅消息 if (receive.deviceId !== this.formData.deviceId) { return; @@ -770,14 +758,21 @@ this.formData[key] = json[key]; } }); + let msg = []; if (this.formData.sta_PowerPercent <= 20) { msg.push("设备电量低"); } - + if (json.sta_sosadd_off == this.formData.sta_sosadd) { + this.formData.sta_sosadd = ""; + let name=this.getWarDevice(json.sta_sosadd_off); + msg.push('"' + name + '"取消报警'); + } if (this.formData.sta_sosadd !== "") { + console.log("查询设备中"); this.searchDevice(this.formData.sta_sosadd).catch(ex => {}).then(dev => { + console.log("dev=", dev); if (dev) { msg.push('"' + dev.deviceName + '"闯入报警中'); } else { @@ -798,9 +793,9 @@ // this.formData.sta_IntrusTime=instrusionTime; // }, 1000); } else { - clearInterval(instrusionTime); - instrusionTime = 0; - this.formData.sta_IntrusTime = 0; + // clearInterval(instrusionTime); + // instrusionTime = 0; + // this.formData.sta_IntrusTime = 0; } if (msg.length > 0) { this.showMsg(msg.join(',')); @@ -808,6 +803,26 @@ }, + + getWarDevice(macStr) { + if (macStr) { + + if (!macStr.includes(':')) { + macStr = macStr.replace(/(.{2})/g, '$1:').slice(0, -1) + } + + let f = this.groupDevices.find(v => { + return v.deviceMac === macStr; + }); + + if (f) { + return f.deviceName; + } + } + + return ""; + }, + searchDevice(macStr) { return new Promise((resolve, reject) => { if (macStr.includes(':')) { @@ -819,45 +834,59 @@ let f = this.groupDevices.find(v => { return v.deviceMac === macStr; }); + console.log("111111111"); if (f) { + console.log("找到设备", f); resolve(f); return; } - + console.log("111111111"); if (macStr == this.device.deviceMac) { + console.log("当前设备", this.device); resolve(this.device); return; } + console.log("111111111"); + try { - request({ - url: '/app/device/getDeviceInfoByDeviceMac', - method: 'GET', - data: { - deviceMac: these.device.macAddress - } - }).then(res => { - console.log("获取设备信息", res); - if (res && res.code == 200) { - console.log("res=", res); - let data = res.data; - if (data) { - this.groupDevices.push({ - deviceMac: data.deviceMac, - deviceName: data.deviceName - }) - resolve(data); - return; + request({ + url: '/app/device/getDeviceInfoByDeviceMac', + method: 'GET', + data: { + deviceMac: macStr } - } + }).then(res => { + console.log("获取设备信息", res); + if (res && res.code == 200) { + console.log("res=", res); + let data = res.data; + if (data) { + this.groupDevices.push({ + deviceMac: data.deviceMac, + deviceName: data.deviceName + }) + resolve(data); + return; + } + } else { + console.log("222222222"); + } + + resolve(null); + + }).catch(ex => { + console.error("查询设备出现异常:", ex); + resolve(null); + + }).finally(com => { + console.log("complete") + }); + } catch (err) { + console.error("err=", err); resolve(null); - - }).catch(ex => { - - resolve(null); - - }); + } }); }, diff --git a/pages/6155/deviceDetail.vue b/pages/6155/deviceDetail.vue index d31c03c..9745cca 100644 --- a/pages/6155/deviceDetail.vue +++ b/pages/6155/deviceDetail.vue @@ -175,7 +175,7 @@ baseURL } from '@/utils/request.js'; - var pagePath = "/pages/6155/HBY6155"; + var pagePath = "/pages/6155/deviceDetail"; var ble = null; var these = null; @@ -575,7 +575,7 @@ keys.forEach((key) => { if (key in these.formData) { // 确保响应式更新 - console.log(`更新字段 ${key}: ${these.formData[key]} -> ${json[key]}`); + // console.log(`更新字段 ${key}: ${these.formData[key]} -> ${json[key]}`); these.$set(these.formData, key, json[key]); } else { console.log(`字段 ${key} 不在 formData 中,跳过更新`); @@ -584,7 +584,7 @@ // 强制触发视图更新,确保电量显示同步 these.$forceUpdate(); - console.log("更新后的电量:", these.formData.battary); + // console.log("更新后的电量:", these.formData.battary); if (this.formData.battary <= 20) { this.showPop({ @@ -911,7 +911,7 @@ "clientid": clientid }, formData: { - code: 2, + code: 1, width: width, height: height }, @@ -942,6 +942,8 @@ resolve(res.data); return; + }else{ + console.log("res.data=",res.data); } } @@ -1087,7 +1089,7 @@ dataView.setUint8(packetSize - 1, 0xFF); } let inteval = parseInt(this.inteval ? this.inteval : 80); - console.log(inteval, 'intevalinteval'); + // console.log(inteval, 'intevalinteval'); ble.sendData(f.deviceId, buffer, f.writeServiceId, f .wirteCharactId).then(() => { if (ReSendNo) { diff --git a/pages/BlueTooth/ModeSetting/HBY6155.vue b/pages/BlueTooth/ModeSetting/HBY6155.vue deleted file mode 100644 index 3ff9f9a..0000000 --- a/pages/BlueTooth/ModeSetting/HBY6155.vue +++ /dev/null @@ -1,1947 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/BlueTooth/ModeSetting/HBY6155V1.vue b/pages/BlueTooth/ModeSetting/HBY6155V1.vue deleted file mode 100644 index 06aa86a..0000000 --- a/pages/BlueTooth/ModeSetting/HBY6155V1.vue +++ /dev/null @@ -1,1925 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/BlueTooth/ModeSetting/HBY650.vue b/pages/BlueTooth/ModeSetting/HBY650.vue deleted file mode 100644 index 07ebe45..0000000 --- a/pages/BlueTooth/ModeSetting/HBY650.vue +++ /dev/null @@ -1,1892 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/BlueTooth/ModeSetting/HBY650_1.vue b/pages/BlueTooth/ModeSetting/HBY650_1.vue deleted file mode 100644 index 8338463..0000000 --- a/pages/BlueTooth/ModeSetting/HBY650_1.vue +++ /dev/null @@ -1,1899 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/BlueTooth/ModeSetting/HBY670V1.vue b/pages/BlueTooth/ModeSetting/HBY670V1.vue deleted file mode 100644 index c457ae4..0000000 --- a/pages/BlueTooth/ModeSetting/HBY670V1.vue +++ /dev/null @@ -1,2837 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/BlueTooth/ModeSetting/ModeSetting.vue b/pages/BlueTooth/ModeSetting/ModeSetting.vue deleted file mode 100644 index c464993..0000000 --- a/pages/BlueTooth/ModeSetting/ModeSetting.vue +++ /dev/null @@ -1,1499 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/BlueTooth/ModeSetting/VideoSend.vue b/pages/BlueTooth/ModeSetting/VideoSend.vue deleted file mode 100644 index 3ea69bb..0000000 --- a/pages/BlueTooth/ModeSetting/VideoSend.vue +++ /dev/null @@ -1,472 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/BlueTooth/ModeSetting/VideoSend_1.vue b/pages/BlueTooth/ModeSetting/VideoSend_1.vue deleted file mode 100644 index 1c1eadb..0000000 --- a/pages/BlueTooth/ModeSetting/VideoSend_1.vue +++ /dev/null @@ -1,517 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/BlueTooth/ModeSetting/VideoSend_670.vue b/pages/BlueTooth/ModeSetting/VideoSend_670.vue deleted file mode 100644 index 1e8bc89..0000000 --- a/pages/BlueTooth/ModeSetting/VideoSend_670.vue +++ /dev/null @@ -1,537 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/BlueTooth/ModeSetting/index.vue b/pages/BlueTooth/ModeSetting/index.vue deleted file mode 100644 index d0edfba..0000000 --- a/pages/BlueTooth/ModeSetting/index.vue +++ /dev/null @@ -1,115 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/BlueTooth/ModeSetting/update.vue b/pages/BlueTooth/ModeSetting/update.vue deleted file mode 100644 index e814728..0000000 --- a/pages/BlueTooth/ModeSetting/update.vue +++ /dev/null @@ -1,273 +0,0 @@ - - - - - diff --git a/pages/common/addBLE/addEquip.vue b/pages/common/addBLE/addEquip.vue index a9cac65..d4fd506 100644 --- a/pages/common/addBLE/addEquip.vue +++ b/pages/common/addBLE/addEquip.vue @@ -171,6 +171,7 @@ }, onLoad(option) { let search = option.search; + ble = bleTool.getBleTool(); these = this; eventChannel = this.getOpenerEventChannel(); const systemInfo = uni.getSystemInfoSync(); @@ -216,7 +217,7 @@ } let StartSubsrib = () => { these.EquipMents = []; - ble = bleTool.getBleTool(); + //蓝牙不可用的回调 ble.addStateBreakCallback(res => { if (these.Status.isPageHidden) { @@ -291,7 +292,9 @@ }, pagePath); //搜索到新设备的回调 + ble.addDeviceFound((arr) => { + // console.log("发现设备", arr); if (these.Status.isPageHidden) { return; } @@ -352,17 +355,18 @@ }, pagePath); - } - if (search) { - StartSubsrib(); - } + + + StartSubsrib(); + eventChannel.on('detailData', function(rec) { console.log("接收到父页面的参数:", rec); these.device = rec.data; - StartSubsrib(); + console.log("11111") + these.refreshBleList(); }); @@ -386,11 +390,11 @@ Promise.allSettled(promis).finally(() => { ble.StopSearch().finally(res => { - console.log("停止搜索成功"); + console.log("停止搜索成功"); these.EquipMents = []; these.PairEquip = []; ble.StartSearch().then(result => { - console.log("开始搜索成功"); + console.log("开始搜索成功"); }).catch(err => { console.error("开始搜索失败,err=", err); if (err.code === 10001) { diff --git a/static/images/common/BJQ4877.png b/static/images/common/BJQ4877.png index dff8be2..a8db8a6 100644 Binary files a/static/images/common/BJQ4877.png and b/static/images/common/BJQ4877.png differ diff --git a/utils/BleHelper.js b/utils/BleHelper.js index cd65153..a03532b 100644 --- a/utils/BleHelper.js +++ b/utils/BleHelper.js @@ -74,9 +74,9 @@ class BleHelper { stateRecoveryCallback: [], //蓝牙适配器恢复可用事件 stateBreakCallback: [] //蓝牙适配器不可用事件 } - // this.addReceiveCallback((a, b, c) => { - // recei.ReceiveData(a, b, c); - // }, "BleReceiveData"); + this.addReceiveCallback((receive, f, path, recArr) => { + recei.ReceiveData(receive, f, path, recArr); + }, "BleReceiveData"); this.dic = { errRemarks: [{ key: '10000', @@ -639,7 +639,7 @@ class BleHelper { console.log("111111111") uni.onBluetoothDeviceFound((res) => { - // console.log("发现新设备:" + JSON.stringify(res,'name')); + //console.log("发现新设备:" + JSON.stringify(res,'name')); let arr = []; for (var i = 0; i < res.devices.length; i++) { let item = res.devices[i]; @@ -653,7 +653,7 @@ class BleHelper { }); if (f) { - // console.log("发现目标设备:", item); + // console.log("发现目标设备:", item); arr.push(item); } @@ -678,12 +678,14 @@ class BleHelper { }); } + }else{ + console.error("无人订阅发现设备的回调"); } }); uni.onBLECharacteristicValueChange((receive) => { //订阅消息 - console.log("收到订阅消息", receive); + // console.log("收到订阅消息", receive); let f = this.data.LinkedList.find((v) => { return v.deviceId == receive.deviceId; }) @@ -838,10 +840,10 @@ class BleHelper { } }) } else { - console.log("无人订阅消息"); + console.error("无人订阅消息"); } } else { - console.log("无人订阅receivDataCallback,不处理数据"); + console.error("无人订阅receivDataCallback,不处理数据"); } } catch (ex) { console.error("处理订阅消息失败,ex=", ex); diff --git a/utils/BleReceive.js b/utils/BleReceive.js index 36aaea6..45ef6f7 100644 --- a/utils/BleReceive.js +++ b/utils/BleReceive.js @@ -46,20 +46,20 @@ class BleReceive { let handler = null; let keys = Object.keys(this.HandlerMap); let devKey = f.device.detailPageUrl ? f.device.detailPageUrl.replace(/\//g, '').toLowerCase() : ''; - console.log("查找handler - detailPageUrl:", f.device.detailPageUrl, "转换后:", devKey); + // console.log("查找handler - detailPageUrl:", f.device.detailPageUrl, "转换后:", devKey); for (let index = 0; index < keys.length; index++) { let devKey = f.device.detailPageUrl ? f.device.detailPageUrl.replace(/\//g, "").toLowerCase() : ''; let key = keys[index].replace(/\//g, '').toLowerCase(); if (key == devKey) { handler = this.HandlerMap[keys[index]]; - console.log("找到匹配的handler:", keys[index]); + // console.log("找到匹配的handler:", keys[index]); break; } } if (handler) { let data = handler(receive, f, path, recArr); - console.log("设备"+f.device.deviceName+"收到消息,handler返回的数据:", data); + // console.log("设备"+f.device.deviceName+"收到消息,数据:", data); return data; } else { console.error("已收到消息,但无指定处理程序, deviceUrl:", f.device.detailPageUrl, "可用handlers:", keys); @@ -162,7 +162,7 @@ class BleReceive { if (iswarn) { uni.showModal({ - content: "环境存在漏电电源", + content: "'"+f.device.deviceName+"'环境存在漏电电源", title: "警告", success(res) { if (res.confirm) { @@ -330,7 +330,7 @@ class BleReceive { if (this.formData.staticWarn) { //有静止报警 uni.showModal({ title: "警告", - content: "设备静止报警中", + content: "设备'"+f.device.deviceName+"'静止报警中", showCancel: false }); } @@ -420,19 +420,23 @@ class BleReceive { let name = ""; switch (type) { case 0x02: - name = '弱光'; + // name = '弱光'; + name=1; break; case 0x04: name = '工作光'; break; case 0x01: - name = '强光'; + // name = '强光'; + name=0; break; case 0x03: - name = '爆闪'; + // name = '爆闪'; + name=2; break; case 0x00: - name = '关闭'; + // name = '关闭'; + name=3; break; } return name; @@ -472,8 +476,7 @@ class BleReceive { formData.statu = warn; formData.xuhang = lightingTime; - console.log("7305解析结果 - 电量:", batteryLevel, "续航:", lightingTime, "完整数据:", formData); - + let recCnt = recArr.find(v => { return v.key.replace(/\//g, "").toLowerCase() === f.device.detailPageUrl.replace(/\//g, '').toLowerCase(); @@ -484,10 +487,10 @@ class BleReceive { if (!recCnt) { if (batteryLevel <= 20) { // 会弹出两个框,暂且注释掉这段代码 - // uni.showModal({ - // content: "设备电量低", - // title: "提示" - // }); + uni.showModal({ + content: "设备'"+f.device.deviceName+"'电量低", + title: "提示" + }); } } @@ -518,7 +521,7 @@ class BleReceive { if (receiveData.sta_PowerPercent<=20) { uni.showModal({ title: "提示", - content: "设备电量低", + content: "设备'"+f.device.deviceName+"'电量低", showCancel: false }); } @@ -547,7 +550,7 @@ class BleReceive { if (receiveData.sta_battery<=20) { uni.showModal({ title: "提示", - content: "设备电量低", + content: "设备'"+f.device.deviceName+"'电量低", showCancel: false }); } @@ -577,7 +580,7 @@ class BleReceive { if (receiveData.sta_PowerPercent<=20) { uni.showModal({ title: "提示", - content: "设备电量低", + content: "设备'"+f.device.deviceName+"'电量低", showCancel: false }); } diff --git a/utils/request.js b/utils/request.js index a25cc90..6faf71e 100644 --- a/utils/request.js +++ b/utils/request.js @@ -1,5 +1,5 @@ import config from '../config/index.js'; -export const env = 'production'; //production development //开发of线上 改这里就行 +export const env = 'development'; //production development //开发of线上 改这里就行 const BASE = config[env]; const request = (options) => { console.log("options" + JSON.stringify(options), BASE.BASE_URL)