From ab696c3076bfc02cff487b846421448189684f07 Mon Sep 17 00:00:00 2001 From: liub Date: Tue, 23 Sep 2025 16:57:31 +0800 Subject: [PATCH] =?UTF-8?q?670=E5=B0=8F=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 3 +- pages/670/HBY670.vue | 98 +++++++++++++++-------------- pages/common/addBLE/addEquip.vue | 6 +- pages/common/shareDevices/index.vue | 14 ++--- utils/BleHelper.js | 28 ++++++--- utils/Common.js | 2 +- utils/request.js | 2 +- 7 files changed, 84 insertions(+), 69 deletions(-) diff --git a/App.vue b/App.vue index a40ea6f..54b79b5 100644 --- a/App.vue +++ b/App.vue @@ -30,8 +30,9 @@ uni.getSystemInfo({success:function(res){ if(res.uniPlatform=='app'){ - upgrade.checkAndUpdateWgt(); bleTool.getBleTool(); + upgrade.checkAndUpdateWgt(); + } }}); }, diff --git a/pages/670/HBY670.vue b/pages/670/HBY670.vue index a229aa5..3314997 100644 --- a/pages/670/HBY670.vue +++ b/pages/670/HBY670.vue @@ -406,7 +406,7 @@ rgb565Data: [], videoHexArray: [], picPath: "", - permissions:[]//权限列表 + permissions: [] //权限列表 } }, created() { @@ -438,13 +438,13 @@ var device = data.data; these.Status.apiType = data.apiType; these.device = device; - if(data.apiType!=='listA'){ - Common.getdeviceShareId(data.data.id).then(res=>{ - if(res.code==200){ - if(res.data.permission){ - these.permissions=res.data.permission.split(','); - } - } + if (data.apiType !== 'listA') { + Common.getdeviceShareId(data.data.id).then(res => { + if (res.code == 200) { + if (res.data.permission) { + these.permissions = res.data.permission.split(','); + } + } }); } if (these.device.deviceImei) { @@ -611,10 +611,12 @@ }, success: (res) => { debugger; - let json={persissonType:'670'}; - Object.assign(json,this.device); + let json = { + persissonType: '670' + }; + Object.assign(json, this.device); res.eventChannel.emit('share', { - data:json + data: json }); } }) @@ -863,8 +865,8 @@ }, lightSetting: function(type) { - if(!this.permissions.includes('1') && this.Status.apiType!=='listA'){ - + if (!this.permissions.includes('1') && this.Status.apiType !== 'listA') { + this.showPop({ message: '无操作权限', iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", @@ -1050,9 +1052,9 @@ }); }, sosSetting: function(type) { - - if(!this.permissions.includes('42') && this.Status.apiType!=='listA'){ - +debugger; + if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') { + this.showPop({ message: '无操作权限', iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", @@ -1063,7 +1065,7 @@ }) return; } - + if (this.formData.SOS == type) { type = "close"; } @@ -1183,16 +1185,16 @@ if (type == 'rb') { //红蓝报警 - console.log("11111"); + console.log("11111"); let sendRb = () => { this.formData.SOS = type; bleSendCmd(); - these.formData.qzwarn=false; - this.Status.staticWarn.time=0; + these.formData.qzwarn = false; + this.Status.staticWarn.time = 0; return; } - if (these.formData.qzwarn) { - console.log("222222"); + if (these.formData.qzwarn && these.Status.staticWarn.inteval) { + console.log("222222"); these.showQzWarn(sendRb); } else { sendRb(); @@ -1212,7 +1214,7 @@ return; } else if (type == 'close') { - if (this.formData.SOS = 'sg') { //解除声光报警 + if (this.formData.SOS = 'sg' && this.Status.staticWarn.inteval) { //解除声光报警 this.CloseWarn(true); } else { this.formData.SOS = type; @@ -1227,8 +1229,8 @@ setTimeout(task, 0); }, GearSetting: function(type) { //档位设置 - if(!this.permissions.includes('41') && this.Status.apiType!=='listA'){ - + if (!this.permissions.includes('41') && this.Status.apiType !== 'listA') { + this.showPop({ message: '无操作权限', iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", @@ -1323,27 +1325,27 @@ setTimeout(task, 0); }, - proDetail:function(type){ - if(!this.permissions.includes('41') && this.Status.apiType!=='listA'){ - - this.showPop({ - message: '无操作权限', - iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", - borderColor: "#e034344d", - buttonBgColor: "#E03434", - okCallback: null, - buttonText: "确定" - }) - return; - } + proDetail: function(type) { + if (!this.permissions.includes('41') && this.Status.apiType !== 'listA') { + + this.showPop({ + message: '无操作权限', + iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", + borderColor: "#e034344d", + buttonBgColor: "#E03434", + okCallback: null, + buttonText: "确定" + }) + return; + } uni.navigateTo({ - url: '/pages/common/'+type+'/index?id=' + this.device.id, + url: '/pages/common/' + type + '/index?id=' + this.device.id, success(ev) { - + } }); }, - + checkImgUpload: function(type, index) { console.log("123213213213"); let f = these.getDevice(); @@ -1881,8 +1883,8 @@ }, ShowUpload: function() { - if(!this.permissions.includes('3') && this.Status.apiType!=='listA'){ - + if (!this.permissions.includes('3') && this.Status.apiType !== 'listA') { + this.showPop({ message: '无操作权限', iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", @@ -1987,8 +1989,8 @@ this.Status.Pop.showPop = true; }, sendUsr: function(ReSendNo) { - - if(!this.permissions.includes('4') && this.Status.apiType!=='listA'){ + + if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') { this.showPop({ message: '无操作权限', @@ -2194,9 +2196,9 @@ }, sendUrgent(type) { - - if(!this.permissions.includes('5') && this.Status.apiType!=='listA'){ - + + if (!this.permissions.includes('5') && this.Status.apiType !== 'listA') { + this.showPop({ message: '无操作权限', iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", diff --git a/pages/common/addBLE/addEquip.vue b/pages/common/addBLE/addEquip.vue index 11afffd..51867c2 100644 --- a/pages/common/addBLE/addEquip.vue +++ b/pages/common/addBLE/addEquip.vue @@ -152,6 +152,7 @@ these = this; this.EquipMents = []; ble = bleTool.getBleTool(); + ble.addDeviceFound((arr) => { arr = arr.devices; @@ -201,7 +202,10 @@ // this.EquipMents = []; this.PairEquip = []; - ble && ble.StartSearch().catch((ex) => { + ble && ble.StartSearch().then(res=>{ + console.log("开始搜索成功",res); + }).catch((ex) => { + console.log("开始搜索出现异常",ex); if (ex.code == 10001) { these.showOpenSetting(); } diff --git a/pages/common/shareDevices/index.vue b/pages/common/shareDevices/index.vue index 95b361f..4010408 100644 --- a/pages/common/shareDevices/index.vue +++ b/pages/common/shareDevices/index.vue @@ -200,13 +200,13 @@ const selectedPermissions = this.permissions.filter(permission => permission.checked).map( permission => permission.value); - // const res = await deviceShareAdd({ - // phonenumber: this.phone, - // smsCode: this.code, - // deviceId: this.itemInfo.id, - // permission: selectedPermissions.join(',') - // }) - let res={code:200}; + const res = await deviceShareAdd({ + phonenumber: this.phone, + smsCode: this.code, + deviceId: this.itemInfo.id, + permission: selectedPermissions.join(',') + }) + if (res.code == 200) { this.shareShow = true uni.hideLoading() diff --git a/utils/BleHelper.js b/utils/BleHelper.js index a2f27f5..323e2aa 100644 --- a/utils/BleHelper.js +++ b/utils/BleHelper.js @@ -1,16 +1,17 @@ import receivTool from "@/utils/BleReceive.js" var recei = null; const serviceDic = [ //合作供应商的蓝牙主服务 +{ + "serviceId": "0000FFE0-0000-1000-8000-00805F9B34FB", + "writeId": "0000FFE1-0000-1000-8000-00805F9B34FB", + "notifyId": "0000FFE2-0000-1000-8000-00805F9B34FB" + }, { "serviceId": "0000AE30-0000-1000-8000-00805F9B34FB", "writeId": "0000AE03-0000-1000-8000-00805F9B34FB", "notifyId": "0000AE02-0000-1000-8000-00805F9B34FB" - }, - { - "serviceId": "0000FFE0-0000-1000-8000-00805F9B34FB", - "writeId": "0000FFE1-0000-1000-8000-00805F9B34FB", - "notifyId": "0000FFE2-0000-1000-8000-00805F9B34FB" } + ]; class BleHelper { @@ -39,7 +40,10 @@ class BleHelper { } setTimeout(() => { - this.linkAllDevices(); + this.OpenBlue().then(()=>{ + this.linkAllDevices(); + }); + }, 10); this.data = { isOpenBlue: false, //蓝牙模块是否开启 @@ -185,7 +189,7 @@ class BleHelper { key = new Date().getTime(); } if (key) { - console.log("key=" + key); + // console.log("key=" + key); let f = this.cfg.onDeviceFound.findIndex((v) => { return v.key == key; }); @@ -366,6 +370,7 @@ class BleHelper { return new Promise((resolve, reject) => { if (this.data.available) { + console.log("蓝牙模块是可用状态"); resolve({ available: this.data.available, discovering: this.data.discovering @@ -373,6 +378,7 @@ class BleHelper { return; } if (!this.data.isOpenBlue) { + console.log("蓝牙模块未打开"); resolve({ available: false, discovering: false @@ -381,12 +387,13 @@ class BleHelper { } uni.getBluetoothAdapterState({ success: (info) => { + console.log("蓝牙状态获取成功,",info) this.data.available = info.available; this.data.discovering = info.discovering; resolve(info); }, fail: (ex1) => { - ////console.log("ex1", ex1); + console.log("蓝牙状态获取失败", ex1); let res1 = { available: false, discovering: false @@ -472,7 +479,7 @@ class BleHelper { }); uni.onBluetoothDeviceFound((devices) => { - // console.log("发现新设备:" + JSON.stringify(devices)); + console.log("发现新设备:" + JSON.stringify(devices)); this.data.searchList = this.data.searchList.concat( devices); if (this.cfg.onDeviceFound) { @@ -706,8 +713,9 @@ class BleHelper { // for (let i = 0; i < serviceIds.length; i++) { // promises.push(RunSearch(serviceIds[i])); + // } - promises.push(RunSearch()); + promises.push(RunSearch()); Promise.all(promises).then(resolve).catch(reject); }); diff --git a/utils/Common.js b/utils/Common.js index 071df7d..db0ae79 100644 --- a/utils/Common.js +++ b/utils/Common.js @@ -257,7 +257,7 @@ export default { value: "42", label: "SOS", checked: false, - type: ['210', '6170', '670'] + type: ['670'] } ] diff --git a/utils/request.js b/utils/request.js index 7d28d86..9bdd4b6 100644 --- a/utils/request.js +++ b/utils/request.js @@ -1,5 +1,5 @@ import config from '../config/index.js'; -const env = 'production'; //production development //开发of线上 改这里就行 +const env = 'development'; //production development //开发of线上 改这里就行 const BASE = config[env]; const request = (options) => { console.log("options"+JSON.stringify(options),BASE.BASE_URL)