From dfb6f296833c3de3b4685a90facfcb18529c0af6 Mon Sep 17 00:00:00 2001 From: liub Date: Tue, 26 Aug 2025 15:42:26 +0800 Subject: [PATCH] =?UTF-8?q?670=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 25 +- api/6155/BlueHelper.js | 708 -------------- api/670/HBY670.js | 44 + manifest.json | 2 +- pages.json | 32 +- pages/670/HBY670.vue | 901 ++++++++++++------ .../ModeSetting/{HBY670.vue => HBY670V1.vue} | 0 pages/BlueTooth/ModeSetting/VideoSend_670.vue | 4 +- pages/BlueTooth/ModeSetting/index.vue | 2 +- pages/common/login/index.vue | 44 +- static/images/670/jieN.png | Bin 0 -> 1339 bytes static/images/670/jieNActive.png | Bin 0 -> 1873 bytes static/images/670/qiang.png | Bin 0 -> 2064 bytes static/images/670/qiangActive.png | Bin 0 -> 3127 bytes static/images/670/rb.png | Bin 0 -> 754 bytes static/images/670/rbActive.png | Bin 0 -> 999 bytes static/images/670/ruo.png | Bin 0 -> 1684 bytes static/images/670/ruoActive.png | Bin 0 -> 2662 bytes static/images/670/sg.png | Bin 0 -> 968 bytes static/images/670/sgActive.png | Bin 0 -> 1303 bytes utils/BleHelper.js | 5 + utils/BleReceive.js | 46 +- 22 files changed, 767 insertions(+), 1046 deletions(-) delete mode 100644 api/6155/BlueHelper.js create mode 100644 api/670/HBY670.js rename pages/BlueTooth/ModeSetting/{HBY670.vue => HBY670V1.vue} (100%) create mode 100644 static/images/670/jieN.png create mode 100644 static/images/670/jieNActive.png create mode 100644 static/images/670/qiang.png create mode 100644 static/images/670/qiangActive.png create mode 100644 static/images/670/rb.png create mode 100644 static/images/670/rbActive.png create mode 100644 static/images/670/ruo.png create mode 100644 static/images/670/ruoActive.png create mode 100644 static/images/670/sg.png create mode 100644 static/images/670/sgActive.png diff --git a/App.vue b/App.vue index bb9d0c3..04e9188 100644 --- a/App.vue +++ b/App.vue @@ -5,8 +5,31 @@ export default { onLaunch: function() { + var ble = bleTool.getBleTool(); + //以下代码仅在开发时使用,否则会出现不可预知的问题。 // uni.clearStorageSync(); - var ble = bleTool.getBleTool(); + // let store=uni.getStorageInfoSync(); + // store.keys.forEach((val,index,array)=>{ + // if(val=="tokenTime"){ + // let time=uni.getStorageSync(val); + // if(!time){ + // time=0; + // } + // let currTime=new Date().getTime(); + // if(currTime>=time){ + // uni.removeStorageSync(val); + // uni.removeStorageSync("token"); + // uni.removeStorageSync("clientID"); + // } + // } + // else if(val=="token" || val=="clientID"){ + // console.log("忽略登陆信息"); + // }else{ + // uni.removeStorageSync(val); + // } + // }); + + }, onShow: function() { console.log('App Show'); diff --git a/api/6155/BlueHelper.js b/api/6155/BlueHelper.js deleted file mode 100644 index a855d9e..0000000 --- a/api/6155/BlueHelper.js +++ /dev/null @@ -1,708 +0,0 @@ -export default { - featrueValueCallback: null, //蓝牙特征变化回调 - BleChangeCallback: null, //蓝牙状态变化回调 - //引导用户打开蓝牙 - showBluetoothGuide: function(showTip) { - let platform = process.env.UNI_PLATFORM; - - - var openBlueSetting = function() { - // 判断平台类型 - if (platform === 'mp-weixin') { - uni.openSetting(); - } else if (platform === 'app-plus' || platform === 'app') { - //---------------------------------------------------------------- - const osName = plus.os.name; - - if (osName === 'iOS') { - // iOS 平台打开蓝牙设置 - plus.runtime.openURL('App-Prefs:root=Bluetooth', function() { - console.log('成功打开蓝牙设置'); - }, function(err) { - console.error('打开蓝牙设置失败:' + err.message); - uni.showModal({ - title: '提示', - content: '无法自动打开蓝牙设置,请手动前往设置 > 蓝牙 进行操作。', - showCancel: false - }); - }); - } else if (osName === 'Android') { - // Android 平台打开蓝牙设置 - try { - const Intent = plus.android.importClass('android.content.Intent'); - const Settings = plus.android.importClass('android.provider.Settings'); - const main = plus.android.runtimeMainActivity(); - const intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS); - main.startActivity(intent); - } catch (e) { - console.error('打开蓝牙设置失败:' + e.message); - // 尝试使用通用设置页面作为备选方案 - plus.runtime.openURL('settings://', function() { - console.log('打开系统设置成功,请手动找到蓝牙选项'); - }, function() { - uni.showModal({ - title: '提示', - content: '无法自动打开蓝牙设置,请手动前往设置页面开启蓝牙。', - showCancel: false - }); - }); - } - } else { - uni.showModal({ - title: '提示', - content: '当前系统不支持自动打开蓝牙设置,请手动操作。', - showCancel: false - }); - } - - - //-------------------------------------------------------------------- - } else if (platform === 'mp-alipay') { - uni.openSetting(); - } - - } - - if (showTip !== undefined) { - openBlueSetting(); - return; - } - if (platform === 'mp-weixin' || platform === 'app-plus' || platform === 'mp-alipay' || platform === 'app') { - uni.showModal({ - title: '蓝牙未开启', - content: '请在系统设置中打开蓝牙以使用此功能', - success: (res) => { - if (res.confirm) { - openBlueSetting(); - } - } - }); - } else { - console.log("当前平台不支持打开系统设置" + platform); - } - - - }, - //获取蓝牙适配器状态 - CheckBlue: function(callback) { - - uni.getBluetoothAdapterState({ - success(res1) { - - //console.log("当前蓝牙适配器状态:" + JSON.stringify(res1)) - if (callback) { - callback(res1); - } - - }, - fail(ex1) { - console.log("检查蓝牙状态异常:" + JSON.stringify(ex1)); - if (callback) { - if (ex1.code == 10000) { - console.log("未初始化蓝牙适配器"); - } - let res1 = { - available: false, - discovering: false - } - callback(res1); - } - }, - complete() { - - } - }); - }, - //初始化蓝牙模块 - OpenBlue: function(isCheckState, callback, availCallback) { - - var these = this; - - var init = function() { - uni.openBluetoothAdapter({ - success: (res) => { - console.log("蓝牙初始化成功:" + JSON.stringify(res)); - if (callback) { - callback(); - } - uni.onBluetoothAdapterStateChange(function(state) { - //console.log('蓝牙状态发生变化:' + JSON.stringify(state)); - if (this.BleChangeCallback) { - this.BleChangeCallback() - } - }) - }, - fail: function(ex2) { - console.log("蓝牙初始化失败:" + JSON.stringify(ex2)) - if (ex2.code == '10001') { - console.log("手机蓝牙未打开或设备不支持蓝牙"); - - - if (availCallback) { - availCallback(); - } else { - these.showBluetoothGuide(); - } - } - } - }); - } - if (isCheckState) { - this.CheckBlue(function(res1) { - if (res1.available) { - if (callback) { - callback(); - } - return; - } - init(); - }) - } else { - init(); - } - - - - }, - //关闭蓝牙模块,停止搜索、断开所有连接 - CloseBlue: function(callback) { - - this.StopSearch(); - - this.disconnectDevice(); - - uni.closeBluetoothAdapter({ - success: () => { - console.log("蓝牙模块已关闭"); - if (callback) { - callback(); - } - } - }); - }, - //开始搜索新设备 - StartSearch: function(callback) { - - var these = this; - - //发现新设备 - var onDeviceFound = function() { - uni.onBluetoothDeviceFound(function(res) { - console.log("发现新设备:" + JSON.stringify(res)); - if (callback) { - callback(res); - } - }) - } - //开始搜索 - var Search = function() { - uni.startBluetoothDevicesDiscovery({ - services: ["0xFFE0"], - allowDuplicatesKey: false, - success: (res) => { - console.log('开始搜索蓝牙设备成功'); - onDeviceFound(); - }, - fail: (err) => { - console.log(`搜索蓝牙设备失败: ${err.errMsg}`); - } - }); - - } - //先检查蓝牙状态是可用 - this.CheckBlue(function(res1) { - if (res1.available) { - if (!res1.discovering) { - Search(); - } else { - console.log("当前蓝牙正在搜索设备") - } - - } else { - these.OpenBlue(false, Search, () => { - these.showBluetoothGuide(); - }); - } - }); - - - - }, - //停止搜索 - StopSearch: function() { - uni.stopBluetoothDevicesDiscovery({ - success: (res) => { - //console.log("停止搜索蓝牙设备成功") - }, - fail() { - console.log("无法停止蓝牙搜索") - } - }); - }, - //获取已连接的设备 - getLinkBlue: function(callback) { - uni.getConnectedBluetoothDevices({ - success: (res) => { - if (callback) { - callback(res); - - } - }, - fail: function(ex) { - console.log("获取已连接设备异常",ex); - if (callback) { - callback({ - devices: [] - }); - } - } - }) - }, - //连接某个设备 - LinkBlue: function(deviceId, callback, error) { - //console.log("deviceId="+deviceId) - this.StopSearch(); - var these = this; - let key = "linkedDevices"; - var store = uni.getStorageInfoSync(); - var f = store.keys.find(function(v) { - return v == key; - }); - var linkedDevices = []; - if (f) { - var str = uni.getStorageSync(key); - if (str) { - linkedDevices = JSON.parse(str); - } else { - linkedDevices = []; - } - - } - //连接成功的回调 - var lindedCallback = function(id,flag) { - - let c = linkedDevices.find(function(v) { - return v.deviceId == deviceId; - }); - - if (c && !flag) { - console.log("连接成功开始监听特征变化,deviceid="+deviceId+',serviceId='+c.notifyServiceid+',characteristicId='+c.notifyCharactId) - //监听设备的特征变化 - setTimeout(()=>{ - uni.notifyBLECharacteristicValueChange({ - deviceId: deviceId, - serviceId: c.notifyServiceid, - characteristicId: c.notifyCharactId, - state: true, - success: function(res) { - console.log("开始监听成功。。。。",res) - //订阅特征值 - - uni.onBLECharacteristicValueChange(function(data) { - // data.characteristicId - // data.deviceId - // data.serviceId - // data.value - console.log("监听到特征值:" + JSON.stringify(data)); - - if (these.featrueValueCallback) { - these.featrueValueCallback(data); - } - }); - - - } - }); - - },1000); - - } - - if (callback) { - callback(deviceId,flag); - } - } - - var linkState = function(res) { - //console.log("获取已连接的设备回调" + JSON.stringify(res)) - let flag = res.devices.find(function(v) { - if (v.deviceId == deviceId) { - return true; - } - return false; - }); - if (flag) { - //console.log("设备状态已连接"); - - lindedCallback(deviceId,true); - - return; - } else { - console.log("设备未连接:"+deviceId); - linkDevice(deviceId); - } - } - - var linkDevice = function() { - console.log("正在连接" + deviceId); - uni.createBLEConnection({ - deviceId: deviceId, - timeout: 30000, - success: function(info) { - - console.log("连接成功"); - - var call = () => { - if (linkedDevices) { - console.log("11111" + JSON.stringify(linkedDevices)); - f = linkedDevices.find(function(v) { - return v.deviceId == deviceId; - }); - } else { - console.log("22222") - f = null; - } - - - - if (!f) { - console.log("缓存中没有找到该设备") - - these.getLinkBlue(function(res) { - if (res.devices && res.devices.length) { - let f = res.devices.find(function(v) { - return v.deviceId == deviceId; - }); - linkedDevices.push(f); - uni.setStorageSync(key, JSON.stringify( - linkedDevices)); - - getService(deviceId); - - } - - }); - - - } else { - console.log("缓存中已连接过"); - if (!f.services) { - getService(deviceId); - } else { - - lindedCallback(deviceId,false); - - } - } - - } - let os = uni.getSystemInfoSync().osName; - if (os == 'android') { - uni.setBLEMTU({ - deviceId: deviceId, - mtu: 512, - success: () => { - //console.log("mtu设置成功"); - }, - fail: function() { - console.log("mtu设置失败") - }, - complete: function() { - call(); - } - }); - } else { - call(); - } - - }, - fail: function(ex) { - if (ex) { - console.log("蓝牙连接失败" + JSON.stringify(ex)); - if(error){ - error(ex); - } - - } - } - }); - } - //获取服务 - var getService = function(id) { - - var repeatCnt = 0; - var startgetService = function() { - uni.getBLEDeviceServices({ - deviceId: id, - success: function(res) { - if (res.services && res.services.length > 0) { - console.log("获取到服务:" + JSON.stringify(res)); - - linkedDevices.find(function(v) { - if (v.deviceId == id) { - v.services = res.services; - } - }); - uni.setStorageSync(key, JSON.stringify(linkedDevices)); - var promises = []; - for (var i = 0; i < res.services.length; i++) { - let service = res.services[i]; - promises.push(getFeatrus(id, service.uuid)); - } - - Promise.all(promises) - .then(results => { - console.log('所有操作成功完成', results); - - lindedCallback(id,false); - - }) - .catch(error => { - console.error('至少一个操作失败', error); - }); - - - } else { - repeatCnt++; - if (repeatCnt > 5) { - - lindedCallback(id,false); - - return; - } - setTimeout(function() { - startgetService(id); - }, 500); - } - } - }) - } - - setTimeout(function() { - startgetService(id); - }, 1000); - } - //获取特性 - var getFeatrus = function(id, serviceId) { - var promise = new Promise((resolve, reject) => { - uni.getBLEDeviceCharacteristics({ - deviceId: id, - serviceId: serviceId, - success: (res) => { - console.log("获取到特征:" + JSON.stringify(res)); - - //写特征 - let writeChar = res.characteristics.find(char => - char.uuid.indexOf("FFE1") > -1 - ); - //通知特征 - let notiChar = res.characteristics.find(char => - char.uuid.indexOf("FFE2") > -1 - ); - - linkedDevices.find(function(v) { - if (v.deviceId == id) { - if (!v.Characteristics) { - v.Characteristics = []; - } - v.Characteristics = v.Characteristics.concat(res - .characteristics); - - if (writeChar) { - v.writeServiceId = serviceId; - v.wirteCharactId = writeChar.uuid; - } - - if (notiChar) { - v.notifyServiceid = serviceId; - v.notifyCharactId = notiChar.uuid; - - - } - } - }); - - - - uni.setStorageSync(key, JSON.stringify(linkedDevices)); - resolve(res); - }, - fail: (ex) => { - console.log("获取特征出现异常:" + JSON.stringify(ex)); - resolve(ex); - } - }); - }); - return promise; - } - - //监测蓝牙状态变化 - uni.onBLEConnectionStateChange(function(res) { - if (!res.connected) { - console.log("蓝牙断开连接" + res.deviceId + ""); - // lindDevice(res.deviceId); - } - }); - - //console.log("正在获取蓝牙适配器状态") - this.CheckBlue((res) => { - //console.log("蓝牙状态:" + JSON.stringify(res)); - if (res.available) { - this.getLinkBlue(linkState); - } else { - console.log("蓝牙适配器不可用,正在初始化"); - this.OpenBlue(false, () => { - this.getLinkBlue(linkState); - }, () => { - console.log("请引导用户打开蓝牙"); - these.showBluetoothGuide(); - }) - } - - }); - - - }, - //断开连接 - disconnectDevice: function(deviceId) { - - var disconnect = function(id) { - uni.closeBLEConnection({ - deviceId: id, - success: (res) => { - console.log("蓝牙连接已断开"); - - } - }); - } - if (deviceId) { - disconnect(deviceId); - return; - } - //断开所有已连接的设备 - this.getLinkBlue(function(res) { - if (res.devices && res.devices.length > 0) { - for (var i = 0; i < res.devices.length; i++) { - let item = res.devices[i]; - disconnect(item.deviceId); - } - - } else { - console.log("无连接设备"); - } - }); - - }, - //发送二进制数据 - sendData: function(deviceid, buffer) { - - console.log("准备向设备发送数据,deviceid=" + deviceid); - return new Promise((resolve, reject) => { - if (!deviceid) { - reject(`deviceid为空,请输入要发送的设备`); - return; - } - console.log("准备发送数据包"); - let key = "linkedDevices"; - var store = uni.getStorageInfoSync(); - var f = store.keys.find(function(v) { - return v == key; - }); - console.log("倒计时:5"); - var linkedDevices = []; - if (f) { - var str = uni.getStorageSync(key); - if (str) { - linkedDevices = JSON.parse(str); - } - - } - console.log("倒计时:4"); - if (linkedDevices && linkedDevices.length && linkedDevices.length > 0) { - console.log("倒计时:3"); - f = linkedDevices.find(function(v) { - return v.deviceId == deviceid; - - }); - console.log("f=" + JSON.stringify(f)); - // console.log("deviceid=" + deviceid); - console.log("倒计时:2"); - if (f) { - console.log("倒计时:1"); - these.sendDataNew(f.deviceId,f.writeServiceId,f.wirteCharactId,buffer).then(succ).catch(err); - } else { - reject(`已连接设备中无法找到此设备`); - // console.log("警报:已连接设备中无法找到此设备") - } - - } else { - console.log("检测到未与设备建立连接"); - reject(`检测到未与设备建立连接`); - } - - - }); - - - }, - sendDataNew: function(deviceid, serviceId, characteristicId, buffer) { - - //console.log("准备向设备发送数据,deviceid=" + deviceid+',serviceId='+serviceId+',characteristicId='+characteristicId); - return new Promise((resolve, reject) => { - let promise = new Promise((succ, err) => { - uni.writeBLECharacteristicValue({ - deviceId: deviceid, - serviceId: serviceId, - characteristicId: characteristicId, - value: buffer, - success: () => { - //console.log("发送数据成功"); - succ(); - }, - fail: (ex) => { - console.log("发送数据失败" + JSON.stringify(ex)); - err(ex); - } - }); - - }); - - if (uni.getSystemInfoSync().osName.toLowerCase() == 'ios') { - - //专业给IOS填坑,uni.writeBLECharacteristicValue在IOS上不进入任何回调 - - function timeout(ms) { - return new Promise((_, err) => { - setTimeout(() => { - err({ - code: -1, - errMsg: '超时了' - }) - }, ms); - }); - } - - Promise.race([promise, timeout(50)]).then(resolve).catch((ex) => { - console.log("ex=", ex); - if (ex.code == -1) { - resolve(); - } else { - reject(ex); - } - - }).finally(() => { - console.log("完成了") - }); - } else { - promise.then(resolve).catch(reject); - } - - - - }); - - - - } - -} \ No newline at end of file diff --git a/api/670/HBY670.js b/api/670/HBY670.js new file mode 100644 index 0000000..2f2ee24 --- /dev/null +++ b/api/670/HBY670.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +function getdata(url,method,data){ + return new Promise((resolve,reject)=>{ + if(!url){ + reject('url为空'); + return; + } + if(!method){ + method='POST'; + } + request({ + url: url, + method: method, + data:data + }).then((res)=>{ + resolve(res); + }).catch(ex=>{ + reject(ex); + }); + }); + +} +//档位设置 + function gearSetting(data){ + let url=""; + return getdata(url,"POST",data); +} + +//人员信息设置 +function sendUsr(data){ + let url="/app/xinghan/device/registerPersonInfo"; + return getdata(url,"POST",data); +} + +export default{ + gearSetting:gearSetting, + sendUsr:sendUsr +} + + + + + diff --git a/manifest.json b/manifest.json index f34c52a..9f1e24b 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "name" : "晶全-物联", "appid" : "__UNI__A21EF43", "description" : "设备管控", - "versionName" : "1.0.8", + "versionName" : "1.0.9", "versionCode" : "100", "transformPx" : false, /* 5+App特有相关 */ diff --git a/pages.json b/pages.json index 1267e35..f2cf5b8 100644 --- a/pages.json +++ b/pages.json @@ -1,12 +1,11 @@ { "pages": [ - - { - "path": "pages/common/login/index", - "style": { - "navigationStyle": "custom" - } - }, + { + "path": "pages/common/login/index", + "style": { + "navigationStyle": "custom" + } + }, { "path" : "pages/BlueTooth/ModeSetting/index", "style" : @@ -14,6 +13,15 @@ "navigationBarTitleText" : "设备类型" } }, + { + "path" : "pages/670/HBY670", + "style" : + { + "navigationBarTitleText" : "HBY670" + } + }, + + { "path": "pages/common/index/index", "style": { @@ -200,13 +208,7 @@ "navigationBarTitleText": "呼叫" } }, - { - "path" : "pages/670/HBY670", - "style" : - { - "navigationBarTitleText" : "HBY670" - } - }, + @@ -271,7 +273,7 @@ } }, { - "path": "pages/BlueTooth/ModeSetting/HBY670", + "path": "pages/BlueTooth/ModeSetting/HBY670V1", "style": { "navigationBarTitleText": "HBY670" } diff --git a/pages/670/HBY670.vue b/pages/670/HBY670.vue index df45013..2f1551a 100644 --- a/pages/670/HBY670.vue +++ b/pages/670/HBY670.vue @@ -2,7 +2,7 @@ - + @@ -23,50 +23,89 @@ - 蓝牙名称 - {{formData.blename}} + 设备IMEI + {{device.deviceImei}} 设备名称 - {{formData.deviceName}} + {{device.deviceName}} - 预警级别 - {{formData.warnLevel}} + 定位信息 + + {{formData.lon}}  {{formData.lat}} + {{formData.address}} + + - - 警告!环境存在漏电电源! - - - - - - - + + 设备自动报警中! + {{Status.staticWarn.time}}s + + + + 档位 - + @click="GearSetting('low','staticBattery')"> 低档 + @click="GearSetting('center','staticBattery')"> 中档 + @click="GearSetting('hight','staticBattery')"> 高档 - - 关闭 + + + + SOS + + + + + + + 声光报警 + + + + + + 红蓝闪烁 - - + + 照明模式 + + + + + + + 强光 + + + + + + 弱光 + + + + + + 关闭 + + + + 人员信息登记 @@ -110,7 +149,7 @@ 姓名: - + 职位: @@ -118,7 +157,7 @@ ID号: - + @@ -168,6 +207,8 @@ import gbk from '@/utils/gbk.js' import BleTool from '@/utils/BleHelper.js' import BleReceive from '@/utils/BleReceive'; + import api from '@/api/670/HBY670.js'; + import MqttClient from '@/utils/mqtt.js'; import { showLoading, hideLoading, @@ -177,11 +218,15 @@ var ble = null; var these = null; var recei = null; + var mqttClient=null; export default { data() { return { Status: { - + staticWarn:{ + time:0, + inteval:null + }, Pop: { showPop: false, //是否显示弹窗 popType: 'custom', @@ -238,25 +283,44 @@ usrToggle: true, }, formData: { - img: '/static/images/6155/DeviceDetail/equip.png', - battary: '', - xuhang: '', - blename: '', - deviceId: '', - deviceName: '', - RSSI: '', - statu: '', - liangDu: '', - warnLevel: '', - macAddress: '', - cMode: false, - modeCurr: 'low', - - company: '黄石消防支队', - name: '菜英俊', - job: '小队长', - id: 'HSXF01061', - iswarn: false + battary: "", //电量 + xuhang: "", //续航 + imei: "", //imei + Lon: "", //经度 + Lat: "", //纬度 + address: "", //地址 + modeCurr: "", //档位 + SOS: "sg", //sos + lightCurr: "qiang", //照明模式 + company: "", //单位 + usrname: "", //姓名 + job: "", //职位 + id: "", //id + msgTxt: "", //消息1 + qzwarn: false, //是否报警 + warnLevel: "", //报警级别 + staticWarn:false,//静止报警 + fourGStrenth:0,//4G信号强度 + deviceId: "" + }, + device: { + id: "", + deviceName: "", + deviceImei: "", + deviceMac: "", + communicationMode: 0, + devicePic: "", + typeName: "", + bluetoothName: null, + deviceStatus: null, + bindingTime: "", + onlineStatus: 0, + battery: "0", + latitude: null, + longitude: null, + alarmStatus: null, + detailPageUrl: "/pages/670/HBY670", + showConfirm: false }, rgb565Data: [], videoHexArray: [] @@ -268,6 +332,7 @@ ble.removeReceiveCallback(pagePath); }, onLoad: function() { + console.log("670页面加载"); these = this; recei = BleReceive.getBleReceive(); ble = BleTool.getBleTool(); @@ -278,24 +343,19 @@ console.log("收到父页面的参数:" + JSON.stringify(data)); var device = data.data; - + these.device=device; + if(these.device.deviceImei){ + these.initMQ(); + } let f = ble.data.LinkedList.find((v) => { if (v.macAddress == device.deviceMac) { console.log("找到设备了", v); - these.formData.deviceId = v.deviceId; + return true; } return false; }); if (!f) { - - - these.showPop({ - message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备", - iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", - borderColor: "#e034344d", - buttonBgColor: "#E03434", - }); return; } let form = f.formData; @@ -306,16 +366,13 @@ these.formData[key] = form[key]; } } - these.formData.blename = f.name ? f.name : "Unname"; - these.formData.deviceName = device.deviceName; - these.formData.img = device.devicePic; - these.formData.id = device.id; - these.formData.deviceId = f.deviceId; + if(these.formData['imei'] && !these.device.deviceImei){ + these.initMQ(); + } + else if(these.device.deviceImei){ + these.formData['imei'] =these.device.deviceImei; + } ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId); - these.setBleFormData(); - - - }); }, @@ -344,39 +401,86 @@ } }, methods: { - getWarnStyle(index) { - let className = ""; - switch (this.formData.warnLevel) { - case "无预警": - break; - case "弱预警": - if (index <= 1) { - className = "active"; - } - break; - case "中预警": - if (index <= 3) { - className = "active"; - } - break; - case "强预警": - if (index <= 4) { - className = "active"; - } - break; - case "非常强预警": - if (index <= 5) { - className = "active"; - } - break; - } - - return className; + initMQ() { + + return new Promise((resolve, reject) => { + console.log("正在初始化MQtt") + if (mqttClient) { + console.log("无需再次初始化") + resolve(); + return; + } + mqttClient = new MqttClient(); + mqttClient.connect(() => { + console.log("连接成功,开始订阅消息") + // 订阅来自设备的状态更新 + const statusTopic = `A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`; + mqttClient.subscribe(statusTopic, (payload, receive) => { + + try { + + let json = JSON.parse(payload); + let keys = Object.keys(json); + console.log("keys=", keys); + if (keys.indexOf('sta_DetectGrade') > -1) { //上报的报文 + console.log("收到设备上报的数据", payload); + // this.parseDataMQ(json); + } else if (keys.indexOf('sta_PicTrans') > -1) { //发送开机画面 + console.log("收到开机画面答复", payload); + // this.SendImgMQ(json); + } else if (keys.indexOf('sta_TexTrans') > -1) { //发送文本信息 + console.log("收到文本回复", payload); + // this.SendTxtMQ(json); + } else if (keys.indexOf('sta_BreakNews') > -1) { //紧急通知 + console.log("收到紧急消息回复", payload); + // this.sendUrgentMQ(json); + } else { + console.log("收到不能处理的数据", payload); + } + + + } catch (error) { + console.log("无法解析此消息", error); + } + }); + resolve(); + }); + }); }, + + sendMQ(message) { + message=JSON.stringify(message); + const topic = `B/${this.formData.imei?this.formData.imei:this.device.deviceImei}`; + return new Promise((resolve, reject) => { + if (!mqttClient) { + reject("MQTT未连接"); + console.log("MQTT未连接") + return; + } + try { + let flag = mqttClient.publish(topic, message, { + qos: 1 + }); + if (flag) { + resolve(); + return; + } + console.log("MQTT未连接,无法发布消息") + reject("MQTT未连接,无法发布消息"); + } catch (error) { + console.log("出现了异常",error); + mqttClient.unsubscribe(`A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`); + mqttClient.disconnect(); + this.initMQ(); + reject(error); + } + }); + }, + bleValueNotify: function(receive, device, path) { //订阅消息 let data = recei.ReceiveData(receive, device, pagePath); -console.log("收到设备的数据",data) + console.log("收到设备的数据", data) if (data) { if ("staBlue_picture" in data) { //重发图片 @@ -403,31 +507,36 @@ console.log("收到设备的数据",data) let keys = Object.keys(data); for (var i = 0; i < keys.length; i++) { let key = keys[i]; - if(key in these.formData){ - these.formData[key] = data[key]; + if (key in these.formData) { + these.formData[key] = data[key]; } - } - - if (these.formData.iswarn) { + if(this.formData.imei){ + this.initMQ(); + } + if (these.formData.staticWarn) {//有静止报警 these.showPop({ - message: "环境存在漏电电源", + message: "自动报警", iconUrl: "/static/images/6155/DeviceDetail/warnning.png", borderColor: "#e034344d", buttonBgColor: "#E03434", + buttonText:"解除报警", + clickEvt:"staticWarn" }); + this.Status.staticWarn.time=180; + this.Status.staticWarn.inteval=setInterval(()=>{ + if(this.Status.staticWarn.time===0){ + clearInterval(this.Status.staticWarn.inteval); + this.formData.staticWarn=false; + return; + } + this.Status.staticWarn.time=this.Status.staticWarn.time-1; + },1000) + } these.setBleFormData(); } - - - // // 转换为字节数组 - // const bytes = receive.bytes; - // parseData(bytes); - - - }, getDevice: function() { @@ -440,7 +549,7 @@ console.log("收到设备的数据",data) return f; }, setBleFormData() { - ble.data.LinkedList.find((v) => { + let f=ble.data.LinkedList.find((v) => { if (v.deviceId == these.formData.deviceId) { v.formData = these.formData; @@ -448,110 +557,242 @@ console.log("收到设备的数据",data) } return false; }); - - uni.setStorageSync(ble.StorageKey, ble.data.LinkedList); + if(f){ + uni.setStorageSync(ble.StorageKey, ble.data.LinkedList); + } + }, - MainModeSetting: function(type, byteType) { - if (this.formData.modeCurr == type) { + lightSetting:function(type){ + if (this.formData.lightCurr == type) { return; } + + showLoading(this, { + text: "请稍候..." + }); + let task = () => { + this.formData.lightCurr = type; + let dic = { + ble: { + qiang: 0x6D, + ruo: 0x6E, + jieneng:0x6E, + close: 0x6F + }, + mqtt: { + qiang: 1, + ruo: 2, + jieneng:2, + close: 0 + } + }; + console.log("type=",type); + let json= { + ins_SOSGrade: [dic.mqtt[type]] + }; + + let requestSend=()=>{ + this.sendMQ(json).then((res)=>{ + console.log("4g发送成功"); + }).catch((ex)=>{ + these.showPop({ + message: "通信异常,请检查手机或设备网络", + iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", + borderColor: "#e034344d", + buttonBgColor: "#E03434", + }); + + }).finally(()=>{ + hideLoading(these); + these.setBleFormData(); + }); + + + } + + let f = this.getDevice(); + let buffer=null; + if (f) { + // 发送数据 + buffer = new ArrayBuffer(6); + let dataView = new DataView(buffer); + dataView.setUint8(0, 0x55); // 帧头 + dataView.setUint8(1, 0x01); // 帧类型 + dataView.setUint8(2, 0x01); // 包序号 + dataView.setUint8(3, 0x00); // 数据长度 + dataView.setUint8(4, 0x01); // 数据长度 + dataView.setUint8(5, dic.ble[type]); // 数据 + + ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(() => { + console.log("蓝牙发送成功了"); + hideLoading(these); + these.setBleFormData(); + }).catch((ex) => { + //使用4G发送 + console.log("蓝牙发送失败,转4g发送",ex); + requestSend(); + }); + } else { + requestSend(); + } + } + + setTimeout(task, 0); + }, + sosSetting:function(type){ + if (this.formData.SOS == type) { + type="close"; + } + + showLoading(this, { + text: "请稍候..." + }); + let task = () => { + this.formData.SOS = type; + let dic = { + ble: { + sg: 0x68, + rb: 0x69, + close: 0x6A + }, + mqtt: { + sg: 2, + rb: 1, + close: 0 + } + + } + console.log("type=",type); + let json= { + ins_SOSGrade: [dic.mqtt[type]] + }; + + let requestSend=()=>{ + this.sendMQ(json).then((res)=>{ + console.log("4g发送成功"); + }).catch((ex)=>{ + these.showPop({ + message: "通信异常,请检查手机或设备网络", + iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", + borderColor: "#e034344d", + buttonBgColor: "#E03434", + }); + + }).finally(()=>{ + hideLoading(these); + these.setBleFormData(); + }); + + + } + + let f = this.getDevice(); + let buffer=null; + if (f) { + // 发送数据 + buffer = new ArrayBuffer(6); + let dataView = new DataView(buffer); + dataView.setUint8(0, 0x55); // 帧头 + dataView.setUint8(1, 0x05); // 帧类型 + dataView.setUint8(2, 0x01); // 包序号 + dataView.setUint8(3, 0x00); // 数据长度 + dataView.setUint8(4, 0x01); // 数据长度 + dataView.setUint8(5, dic.ble[type]); // 数据 + + ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(() => { + console.log("蓝牙发送成功了"); + hideLoading(these); + these.setBleFormData(); + }).catch((ex) => { + //使用4G发送 + console.log("蓝牙发送失败,转4g发送",ex); + requestSend(); + }); + } else { + requestSend(); + } + } + + setTimeout(task, 0); + }, + GearSetting: function(type) {//档位设置 + if (this.formData.modeCurr == type) { + type="close"; + } showLoading(this, { text: "请稍候..." }); let task = () => { this.formData.modeCurr = type; - let dataValue = 0x00; - let btype = 0x00; - switch (type) { - case "low": //低档 - dataValue = 0x67; - break; - case "center": //中档 - dataValue = 0x66; - break; - case "hight": //高档 - dataValue = 0x65; - break; - case "close": //关闭 - dataValue = 0x68; - break; - case true: //开灯 - dataValue = 0x6E; - break; - case false: //关灯 - dataValue = 0x6F; - break; - default: //未知 - dataValue = 0x00; - break; + let dic = { + ble: { + hight: 0x65, + center: 0x66, + low: 0x67, + close: 0x68 + }, + mqtt: { + hight: 3, + center: 2, + low: 1, + close: 0 + } } - switch (byteType) { - case "staticBattery": - btype = 0x00; - break; - case "lamp": - btype = 0x01; - break; - default: - break; + console.log("type=",type); + let json= { + ins_DetectGrade: [dic.mqtt[type]] } - let buffer = new ArrayBuffer(6); - let dataView = new DataView(buffer); - - dataView.setUint8(0, 0x55); // 帧头 - dataView.setUint8(1, btype); // 帧类型 - dataView.setUint8(2, 0x01); // 包序号 - dataView.setUint8(3, 0x00); // 数据长度 - dataView.setUint8(4, 0x01); // 数据长度 - dataView.setUint8(5, dataValue); // 数据 - - - - let f = this.getDevice(); - - if (f) { - // 发送数据 - - ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(() => { - - - console.log("发送成功了"); - }).catch((ex) => { - + let requestSend=()=>{ + this.sendMQ(json).then((res)=>{ + console.log("4g发送成功"); + }).catch((ex)=>{ these.showPop({ - message: ex.msg, + message: "通信异常,请检查手机或设备网络", iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", borderColor: "#e034344d", buttonBgColor: "#E03434", }); - - }).finally(() => { - + + }).finally(()=>{ hideLoading(these); - these.setBleFormData(); }); - } else { - these.showPop({ - message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备", - iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", - borderColor: "#e034344d", - buttonBgColor: "#E03434", + + + } + + let f = this.getDevice(); + let buffer=null; + if (f) { + // 发送数据 + buffer = new ArrayBuffer(6); + let dataView = new DataView(buffer); + + dataView.setUint8(0, 0x55); // 帧头 + dataView.setUint8(1, 0x00); // 帧类型 + dataView.setUint8(2, 0x01); // 包序号 + dataView.setUint8(3, 0x00); // 数据长度 + dataView.setUint8(4, 0x01); // 数据长度 + dataView.setUint8(5, dic.ble[type]); // 数据 + + ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(() => { + console.log("蓝牙发送成功了"); + hideLoading(these); + these.setBleFormData(); + }).catch((ex) => { + //使用4G发送 + console.log("蓝牙发送失败,转4g发送",ex); + requestSend(); }); - hideLoading(these); + } else { + requestSend(); } } setTimeout(task, 0); - - - }, - LampToggle: function() { - - this.formData.cMode = !this.formData.cMode; - this.MainModeSetting(this.formData.cMode, "lamp"); }, + proParam: function() { uni.navigateTo({ @@ -606,11 +847,12 @@ console.log("收到设备的数据",data) iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png", }); if (!ReSendNo) { - setTimeout(()=>{ - these.HoldYouHand("transmit complete", 0, f.deviceId, f + setTimeout(() => { + these.HoldYouHand("transmit complete", 0, f + .deviceId, f .writeServiceId, f.wirteCharactId); - },500); - + }, 500); + } resolve(); @@ -635,7 +877,7 @@ console.log("收到设备的数据",data) const packetData = these.rgb565Data.slice(startIndex, endIndex); // 构建数据包 - const bufferSize =505;// 5 + packetData.length * 2; // 头部5字节 + 数据部分 + const bufferSize = 505; // 5 + packetData.length * 2; // 头部5字节 + 数据部分 const buffer = new ArrayBuffer(bufferSize); const dataView = new DataView(buffer); @@ -771,18 +1013,20 @@ console.log("收到设备的数据",data) this.totalPackets = totalPackets; // 发送单个数据包 const sendNextVideoPacket = () => { - console.log("准备发送一段数据"); + console.log("准备发送一段数据"); if (currentPacket > totalPackets) { if (!ReSendNo) { - setTimeout(()=>{ - these.HoldYouHand("transmit complete", 0, f.deviceId, f - .writeServiceId, f.wirteCharactId).then(()=>{ + setTimeout(() => { + these.HoldYouHand("transmit complete", 0, f + .deviceId, f + .writeServiceId, f.wirteCharactId).then( + () => { console.log("全部发送完毕") - }).catch((ex)=>{ - console.log("出现异常",ex); - }); - },500); - + }).catch((ex) => { + console.log("出现异常", ex); + }); + }, 500); + } these.Status.BottomMenu.show = false; hideLoading(these); @@ -793,7 +1037,7 @@ console.log("收到设备的数据",data) }); - + resolve(); @@ -837,10 +1081,10 @@ console.log("收到设备的数据",data) } let inteval = 50; - console.log("开始发送一段视频"); // + console.log("开始发送一段视频"); // ble.sendData(f.deviceId, buffer, f.writeServiceId, f .wirteCharactId, 10).then(() => { - + updateLoading(these, { text: "正在发送:" + currentPacket + "/" + totalPackets @@ -1064,11 +1308,9 @@ console.log("收到设备的数据",data) }, HidePop: function() { - if (this.Status.Pop.clickEvt == 'SendUsr') { - + if (this.Status.Pop.clickEvt == 'staticWarn') { + this.Status.staticWarnTime=0; } - - this.Status.Pop.showPop = false; }, showPop: function(option) { @@ -1091,7 +1333,45 @@ console.log("收到设备的数据",data) }, sendUsr: function(ReSendNo) { - + let requestSend=()=>{ + let json = { + deviceId: '1942386314582163705', + deviceImei: '862419074249128', + name: this.formData.company, + position: this.formData.name, + unitName: this.formData.job, + code: this.formData.id + }; + api.sendUsr(json).then((res)=>{ + these.showPop({ + showPop: true, //是否显示弹窗 + popType: 'custom', + bgColor: '#383934bd', + borderColor: '#BBE600', + textColor: '#ffffffde', + buttonBgColor: '#BBE600', + buttonTextColor: '#232323DE', + iconUrl: '/static/images/6155/DeviceDetail/sendSucc.png', + message: '人员信息发送成功', + buttonText: '确定', + clickEvt: 'SendUsr', + visiblePrompt: false, + promptTitle: '', + modelValue: '', + visibleClose: true + }); + these.setBleFormData(); + }).catch((ex)=>{ + these.showPop({ + message: "文字发送失败," + ex.msg, + iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", + borderColor: "#e034344d", + buttonBgColor: "#E03434", + }); + }).finally(()=>{ + hideLoading(these); + }); + } var textLines = [ this.formData.company, @@ -1103,12 +1383,8 @@ console.log("收到设备的数据",data) let f = this.getDevice(); if (!f) { - these.showPop({ - message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备", - iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", - borderColor: "#e034344d", - buttonBgColor: "#E03434", - }); + //走4G通道 + requestSend(); return; } showLoading(this, { @@ -1127,14 +1403,15 @@ console.log("收到设备的数据",data) // console.log("currentPacket=",currentPacket); // 发送单个数据包 const sendNextPacket = () => { - + if (currentPacket > totalPackets) { if (!ReSendNo) { - setTimeout(()=>{ - these.HoldYouHand("transmit complete", 0, f.deviceId, f.writeServiceId, f - .wirteCharactId); - },500); - + setTimeout(() => { + these.HoldYouHand("transmit complete", 0, f.deviceId, f + .writeServiceId, f + .wirteCharactId); + }, 500); + } these.showPop({ @@ -1155,6 +1432,7 @@ console.log("收到设备的数据",data) visibleClose: true }); these.setBleFormData(); + hideLoading(these); return; } @@ -1163,7 +1441,7 @@ console.log("收到设备的数据",data) let arr = gbk.encode(text) let gbkData = gbk.arr2hex(arr); - + // 构建数据包 const bufferSize = 5 + gbkData.length / 2; // 头部4字节 + 数据部分 const buffer = new ArrayBuffer(bufferSize); @@ -1174,7 +1452,7 @@ console.log("收到设备的数据",data) dataView.setUint8(1, 0x03); // 帧类型:文字 dataView.setUint8(2, currentPacket.toString(16)); // 包序号 dataView.setUint16(3, (text.length * 2).toString(16)); // 数据长度 - + // 填充数据 let index = 0; for (var i = 0; i < gbkData.length; i += 2) { @@ -1182,8 +1460,8 @@ console.log("收到设备的数据",data) dataView.setUint8(5 + index, value); index++; } - - + + // 发送数据包 @@ -1197,21 +1475,14 @@ console.log("收到设备的数据",data) currentPacket++; setTimeout(sendNextPacket, 0); }).catch(err => { - - these.showPop({ - message: "文字发送失败," + err.msg, - iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", - borderColor: "#e034344d", - buttonBgColor: "#E03434", - }); + if(err.code=='10007'){ + setTimeout(sendNextPacket, 0); + }else{ + requestSend(); + } }).finally(() => { - hideLoading(these); + }); - - - - - }; // 开始发送第一个包 @@ -1219,7 +1490,7 @@ console.log("收到设备的数据",data) } - if(ReSendNo){ + if (ReSendNo) { sendText(ReSendNo); return; } @@ -1227,17 +1498,17 @@ console.log("收到设备的数据",data) these.HoldYouHand("word transmit start", 120, f.deviceId, f.writeServiceId, f .wirteCharactId).then( () => { - setTimeout(sendText, 200); }).catch((ex) => { - console.log("握手没有成功", ex); - hideLoading(these); - these.showPop({ - message: ex.msg, - iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", - borderColor: "#e034344d", - buttonBgColor: "#E03434", - }); + requestSend(); + // console.log("握手没有成功", ex); + // hideLoading(these); + // these.showPop({ + // message: ex.msg, + // iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", + // borderColor: "#e034344d", + // buttonBgColor: "#E03434", + // }); }); }, 0); @@ -1268,6 +1539,7 @@ console.log("收到设备的数据",data) resolve(true); }, pauseTime); }).catch(err => { + console.log("握手没有成功", ) reject(err); }); @@ -1684,17 +1956,20 @@ console.log("收到设备的数据",data) align-content: center; justify-content: space-around; align-items: center; - + border-radius: 8px; + background: rgba(26, 26, 26, 1); + box-sizing: border-box; + padding: 30rpx 0rpx; } .modeSetting .item { - width: 150rpx; - height: 150rpx; - background: rgba(26, 26, 26, 1); + width: 120rpx; + height: 120rpx; + background: rgba(42, 42, 42, 1); border-radius: 50%; color: rgba(255, 255, 255, 0.87); - margin-top: 20rpx; + font-family: PingFang SC; font-size: 28rpx; font-weight: 400; @@ -1800,42 +2075,118 @@ console.log("收到设备的数据",data) align-items: center; } - .netContent { + .optTitle{ + color: rgba(255, 255, 255, 0.87); + +font-family: 'PingFang SC'; +font-size: 28rpx; +font-weight: 400; + +letter-spacing: 0.14rpx; +text-align: left; +width: 100%; +box-sizing: border-box; +padding:30rpx 0rpx 10rpx 30rpx; + } + + .sosContent{ + width: 100%; + height: 130rpx; + display: flex; flex-direction: row; flex-wrap: nowrap; - align-content: flex-end; - justify-content: space-around; - align-items: flex-end; - width: 50rpx; + align-content: center; + justify-content: space-between; + align-items: center; + } + .sosContent .item{ + width:calc(calc(100% - 80rpx) / 2); + height: 100%; + box-sizing: border-box; + border-radius: 16rpx; + background: rgba(26, 26, 26, 1); + color: rgba(255, 255, 255, 0.87); + font-family: 'PingFang SC'; + font-size: 28rpx; + font-weight: 400; + letter-spacing: 0.14rpx; + display: flex; + flex-direction: row; + flex-wrap: nowrap; + align-content: center; + justify-content: center; + align-items: center; } - .net { - width: 7rpx; - background: rgba(255, 255, 255, 0.3); + .sosContent .item.active{ + border: 1px solid rgba(224, 52, 52, 1); + color: rgba(224, 52, 52, 1); } - .net.netone { - height: 11rpx; + .sosContent .imgContent{ + width: 55rpx; + height: 55rpx; + background-color: #232323; + border-radius: 4rpx; + margin-right: 30rpx; + } + .sosContent .imgContent .img{ + width: 70%; + height: 70%; + } - .net.nettwo { - height: 17rpx; + .sosContent .item.active .imgContent{ + background-color: #E034340F; } - .net.netsiri { - height: 23rpx; + .lightMode{ + width: 100%; + height: 180rpx; + border-radius: 16rpx; +background: rgba(26, 26, 26, 1); +margin-bottom: 30rpx; +display: flex; + flex-direction: row; + flex-wrap: nowrap; + align-content: center; + justify-content: space-between; + align-items: center; } - .net.netfour { - height: 29rpx; + + .lightMode .item{ + width:calc(calc(100% - 90rpx) / 3); + height: 100%; + box-sizing: border-box; + border-radius: 16rpx; + + color: rgba(255, 255, 255, 0.87); + font-family: 'PingFang SC'; + font-size: 28rpx; + font-weight: 400; + letter-spacing: 0.14rpx; + display: flex; + flex-direction: column; + flex-wrap: nowrap; + align-content: center; + justify-content: space-evenly; + align-items: center; } - .net.netfive { - height: 35rpx; + .lightMode .item.active{ + + color:#AED600; } - .net.active { - background: #FFFFFF !important; + .lightMode .imgContent{ + width: 80rpx; + height: 100rpx; + } + .lightMode .imgContent .img{ + width: 100%; + height: 100%; + } \ No newline at end of file diff --git a/pages/BlueTooth/ModeSetting/HBY670.vue b/pages/BlueTooth/ModeSetting/HBY670V1.vue similarity index 100% rename from pages/BlueTooth/ModeSetting/HBY670.vue rename to pages/BlueTooth/ModeSetting/HBY670V1.vue diff --git a/pages/BlueTooth/ModeSetting/VideoSend_670.vue b/pages/BlueTooth/ModeSetting/VideoSend_670.vue index 1e26ab4..1e8bc89 100644 --- a/pages/BlueTooth/ModeSetting/VideoSend_670.vue +++ b/pages/BlueTooth/ModeSetting/VideoSend_670.vue @@ -59,7 +59,7 @@ var mqttClient=null; videoDuration: 2, hexArray: [], -reSendNumber:"" + reSendNumber:"" } }, onLoad() { @@ -401,7 +401,7 @@ reSendNumber:"" }).catch(err => { console.log("完成指令发送失败"); }); - },500) + },1500) }, sendData(buffer) { diff --git a/pages/BlueTooth/ModeSetting/index.vue b/pages/BlueTooth/ModeSetting/index.vue index 88dc2cb..d0edfba 100644 --- a/pages/BlueTooth/ModeSetting/index.vue +++ b/pages/BlueTooth/ModeSetting/index.vue @@ -33,7 +33,7 @@ url: '6155_V1' }, { - name: "/pages/BlueTooth/ModeSetting/HBY670", + name: "/pages/BlueTooth/ModeSetting/HBY670V1", url: 'HBY670' }, diff --git a/pages/common/login/index.vue b/pages/common/login/index.vue index f4dd3a8..ec2e5ec 100644 --- a/pages/common/login/index.vue +++ b/pages/common/login/index.vue @@ -69,6 +69,29 @@ showAgreement: false, // 控制弹窗显示 } }, + onLoad(){ + if(uni.getStorageSync("token") && uni.getStorageSync("clientID")){//免登陆 + + let time=uni.getStorageSync("tokenTime"); + if(!time){ + time=0; + } + let currTime=new Date().getTime(); + if(currTimeKS<4e#@T;v%Xn3BLgejx>)Ac|pF-p=|0tjEC14Op{FmKua{t+d zOQt`7IP5x8{<-~U&wKy!fI3d>M`6Ob{pYwUsy+K3gVdY=dY+#xj{U}yR%@0z?jLDD zaeKB$|HY2{*X{TpE%1N4!oPgSKlhs|7;ek6)`MrkiT}Lu%D3$~_89#)uj$RP@BME*;qCH|_3WGen*4k3uxZ1|zo$0JKl$HQF52)moXt+CBK2SSuVl~nTncgr zzPU5XAN{WvulzE52h+!xoO+QDfq&kAFrBooE#28hep|fc566G$zok6m4;MS_5!hBQ z0MwoS6R7*t=k_1sH~winSo~xD!)%pWUVVv2t_i;vH}pTc|E_=Mqp3f)gSBzDR|wv$ zOMRf+82&8&IY=SM6?GHp_pYD##q`fKp60WCfLBl&?pFmnH! b{ZZZ#QXjBLiv1+8P-O6Q^>bP0l+XkK@ITnn literal 0 HcmV?d00001 diff --git a/static/images/670/jieNActive.png b/static/images/670/jieNActive.png new file mode 100644 index 0000000000000000000000000000000000000000..c43abfe6d3c14f2d247eadacf77e13e384619cbd GIT binary patch literal 1873 zcmd^AZA@EL7`_#;le)Ene8edil(85w9WiOx0xh`8Y;5RarX><@QMU49G@aR?Evvnw zC|qQ6&6p^5THK#y`(ZI;s|hT(NV|@(t}Zd5+fCZ;)^$rrO-l#dj>|pXe(jHc{NoSx zB=;jH@B2RIJkRrtgVwpxX&CU4TC2=eM{kIhlt?V5 zIZaTq9h5AfY8rzjb0vWHq-<4!-}^3w57NT*61+<@?Lnc1d9rCj$408y!L8pTd%!?& z{U;1GV4zc$YPf+;IX|h(m67g9!Vh%tD4oe4#}^oWKk0qxUz+NU1j>67uy(zO#|rk$`1%!Uyf~_coqt#d!P|N1%^Ts^f{;L8NyeJ zbw3(G!!x_2qrhg_)WJ(D(6;by*sJF`d_YHRUBU15J}d#Q?zhclKo~HOSyn%0%Hnqz zaEkl;2FQL@amoPxqebtBEND)v2H*#~;o%f0$S8_V+08FRf$(8kGBEJBlW4xQgPNhi zU1wo@9FI6pEl0r~o8L5B9+~mHzU7w1Zx`D=phaR&_KB}`7hrrkzmfet()%&wv_D$p zKAyVhP2Q2%3+E(YNilbmY#a(jZ;Qk(m2@oh1Y!f98xl5YKD9Ba`QK9QOK;#654%+)09lB%(^J;#3xH&6MudzyX?3PG*8Z0<%c&T5YB&~%N-D$|G2>*y>Ry@ibtXLfQ%rC$qQPN}C;=bR_&r8Yjj=uLFEjwT&RQoq@b45LkM;#STx=+$)lD3P7b zoIjU0|B8mG8cXuMxO!Wq% z^^64cW9V?cm&AvYd-WS1nI%Aip%)&{cIIdMFp#tD%+J*2lu(=83uWV_%*%Le>ixsy S2SM(tgcNVK$$xyK)A}cJ(nFa5 literal 0 HcmV?d00001 diff --git a/static/images/670/qiang.png b/static/images/670/qiang.png new file mode 100644 index 0000000000000000000000000000000000000000..6f4df40aae554f1ac98d97a9aceb5614cf78266d GIT binary patch literal 2064 zcmdT_ZA=q)7;mXiUe^i|CW;5M1vWD4%ZP~1=SlP$3bu`{D^2co>_Mr0ofsn}BD3&BE5YdPrkZr8F!{J3TNuqU~@-2eaF z^E|(oyF0yaZ(5LlxIcrz2!hg6_tV!5`pEJ1q0c3~n_p)z*g7aR=>W_$8<~wfNWp`G z>wawQN=r>GC@6UET{>j$Sh)9J#Aoi(xw-Bx1qHizr+(S>ZL9xCRza?;L?+7~aktF6 zj01h2v&)2*XzT_iW`U8@g^P1F^rC~qQV-gegplDjBIu_W8pB#VxeYBh=JVr8XC%pP zcg14|EtTDMDsU3zm=K2E5TuP3jIp7mzY->}qWQ}5MwNK#pCq)^nM1I8tXwfWh04uy zKBA_uXH`5`IOQz`1E2B|P8OyJo6H{>Gf!?ejaT^NYakYNT8eD9T+m7Y-n0(SKH_Ya zXR}3T;=aLjnM=_OYnBFKz@crrxs1|cGGv@QZjAq;H!*!wZB_O=GQGf84z%f7prvT$ zSj9Hu4BVTTJt}i=$yn;407sIdqMqVu&@i~94dq)DUhS^4SemUef}xI^UQhYG)LY_= zkP9YHonXMDV#Q3IwXgdeL#p&5SNV!=%9`y11iRDqf;;fM zIh&a%51Y;9m$$>wdcdp9OYlIMS(-*xt%Lv!I_g;9UG&)=enOH^ZWgcF@N2+AtD;9q z?b4v@;60*tj>29vGyh$ZsaXAuaki2;El-^sEHp(Zf##WF5^g9l+#6tlx zw&fQEO<$fAdDHS(`>`Qrx)bMo=v*h?KIwfz1|fsA`rh~+V}a;qLzDfTyp!-I4G>5~ zQysEKdl*4`MT8YviFzzE^MiQ+a}2P6;eZ9b;$aJ|A)o<+@uQ-fpu&EfU|)9yV25Fm zm_I#()3fDZ0;}Le9E1#XMu`}D)JJ$GY_^H-ilvxRB{Oj~yiM|oFbGeC47U)j-r%oI z6g>Djb1Atk#N^%X`T^6~`dpV(vL`f&O^Qtxnxh*SVC|a-(0;879r3d!kCD;FdboGC z+5QG0kT^r-z~m_>4+8JllC@k7z$E+yV@jwrh74;j53zJ{sk;2>2Y-Z)(Z-;X4lrC>d^vuF3H<)5;>PF_>_v2{f!`fRZS6-Z z%?)0OUr{N%gmcJRlepKB#sqFtQHl-2XrNUsabA%(m?$p9c_gmJbK6}xSeg~7Rn^RU zYLT(VD>#@snzGmuMTSa|HS{FFYtxsAyIjg&1N!5!B1*mSOGD<){8XTjg$Qn6%%*CUogb;p9{l*)(1ePVEr02tP{(7ROZItDAMJLRq=g zklUC$+&0A<6kJOk(J1dA7u9F& z@x(w15!2~&v%@sq#N(qjqF;2v|2EDR_fHdE_sDX(QIZNznz>=DQ@ sp|$2*pTuA|pPVALSYq76JWV2jNCjVYZBc_HB$8N>^}RekUf|`u-e5A*8TQ}) z(azqPBr|vJIp=qO=XcJzsegZC!JOnDB?AEF6t2tr5dNy*M>A_C{66nJwGaRySD3fv z*Sff2Pu$_m!lRjmsSV$pY%9piD=RDex&e9ojp2$#x3wf90AAAx%&-6v;ja-L{>uLE zI+*QTIml&2K_73+sbx~sHTVAd-39gj>d*^84I_OblR8(#NxOw5{ZxhKbE(fNg+2~r zdln!ix&k$jNk^*WcPv4-2vEo^)#^jiEIdPA({~ z7ufNHNW_oKzJl2=ZV5e44nQEGPq@jrbWRXD@1!znwNGa346Z@Py@sWH7>J3%0_<@?cfcI?iFoN^K_b1$wZfvzSVrf3PWg9{mH=b?%rNB3o$NqZ>2Bxso0gI9i2?O zLu)+KZ5e3$lT6JQx_n@NgZv7mH!0_VT*bHWMw;dLTf~sr?a#u$`7ERwn+Cfv{1hSY z<+C@oGzJz^`6!*Hd^Hy!+{*q{o^!gm+1PlMdGOuuw{-ZJ8TO`N{Fj}((b3etr8O`+ z*i3^`zQNauPNpi(@OjASN~423goBOBr^D)IbP&0#3MahSLG8ttd#||1ve-kwIFW>_ z-gI{fGmLD7v^|H!rt>2UeelsUpFWw~qONP!b-S#YDzVMXCG>v0YXzT5RY7iyNBPX@ z;ks08g67B6TljK6(LdG!DWW#OQ_6Po8otw9?Q#Z7SlRTnB^f6uJnxisP$MSG(C{W> zO0L4DQXX=~nFszLHgvia$A|!8pQafV2^l^&8|@K}htbJR{RuD+HV6TgQ>C~#{#&Zf zqEA!}A`hlnipJ)deWw$VZs8jz#AaQSbLUb}qx&f`sx$WahjjzSrxnuMZ9(btY55mS zb~&j$&kky7>Azby*@`PN46d6ra_I8z%H^ZYY<+0-f$lq1UGa{Q|sXX^)hMQ|u zoaECHI&slIj><@R78<@P?vT_C$T8WJxdYzebXuPmtoQuNI7hu4I2t@KOm)1wT{tF*kbZ`rVe}_$w`?;@7Ozr2zaX{ybaqI} zSs2(l3r`{rdcJo1TMcvg_3V8gqi(Mz4YQOyBoC%2E?u36Ol-Sz{|J_-J{=gD13fC6 z`TQH>=!3pz%xj)e9cb6$k4yC??zf=M^e2oJ^!IuPGpoL0{VqJsYUe*hMn(A72a1jz z=|CZUj9&dSQ1@qU84wqRi$VIu2@A;GJc`EEFe@g`JLyN@B%aN$&nH~~b_-*ZX(4b} z??H`Y%c$S5ZrYWK(b?t!OXxW4h_4#GQf7NS;pLY%5&AZX@3MYi>S~NYS?s;cm^>BI z23=%pKek8FQb8B9$X5Cn=y-`CTb>5I`LLb>S1ODRd_n(MYn@~^pcXUrCeP(1${)5C z!=bU2!!CuIE!A1drYUl!GL((YfGIlo&~V3fJq_y-!eLkh&r-#%D3qU+&tMXlSPpAgG*wzY%*T{cEn$veyG7PzftA_92nUKn$4T?D*H zq{&SQKwc6}AD<2CV4sNkx7Ij@@Sakpf*Xcm_Zgp2_|+biLcWZliOf$}wmyAD6A`a& zGRc~VBf4dtDB5s{5%pQWbP|NU&Dv@6@1kPe%Miyec5rgs2|DCw?h^_kwQp=I3U z|KILIm2xia{!eXn8H2k{@NdS7Y)U21W7>Ir9saT;Bg9zY`(rMx>5jd8D?vIZgaaX3 zFnoN>2PObi?3u>l11iu-u8O1H&i%Z?LI{1eG6y|TtyZGLg{r?7z C_1XUb literal 0 HcmV?d00001 diff --git a/static/images/670/rb.png b/static/images/670/rb.png new file mode 100644 index 0000000000000000000000000000000000000000..b865fe437a960d24619fca1df3f2acdae45b9a5c GIT binary patch literal 754 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 TtHKQbKLXi~z4bS?H=X(yw~()a literal 0 HcmV?d00001 diff --git a/static/images/670/sg.png b/static/images/670/sg.png new file mode 100644 index 0000000000000000000000000000000000000000..28d9bf77910760779f6f1c40ffc88b4f255ec12f GIT binary patch literal 968 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=hEVF!y`9IEGX(zJ0(rLB(^DilaP0T~@04zeXJ&CSiFW%ulvT<3k#!plp`%l*%Ttn^v* zqkO~P!UOCK_cdN-|Ge(}NBU-6@&oD0ZQmzTPtaZa)<{I4(vmBW1!Wg#AKUVz9&vX8HppxfI@A+z`FFF6X zb;I9`2df+0Kjz$5XSf~DzDM%>%ju2%6Sn~M)_Ps4jN`byp1a0$!_nej4j+BC*^5@x z&%6BH`r%k@L!UuwMa%j^oZ+wZyd zh!lu_$eq-;gXyEvhQFr{xHGLk)BP@6rIuG;=8(3NB z?P1s!FZsi99>mCox63~s+Piv*{WD9Lmh-PcEX+j- zli!B3)lGQ*K34Uw;d#!FOgHLMAFx*{s@P6R-}E=|fcwWLRD<1b{h$sGsQqtH%{%x{q9Qe}Y~w zjeV`@)shch|LFfLcp(0x&!jwNfrhtoKcXJ+R&J9l;Qe3tj`^C+ZGDel9E>;qDLt55 z;b;6n>fhr#>}x9h?rSsL-p^q(>$&M;`*X9Ne+_5a@VD)N`RDlewf_V+m+{T9Gbwxl P%%KdPu6{1-oD!M<*~t0B literal 0 HcmV?d00001 diff --git a/static/images/670/sgActive.png b/static/images/670/sgActive.png new file mode 100644 index 0000000000000000000000000000000000000000..5dd61b90f385caa5a79a7e07057dbd13fdf4af25 GIT binary patch literal 1303 zcmcIke@q&86hE+ZM5>@p=(bKJb!pnpT(>4RI)qHA)~u6dTSprb>3#&3v>olNvXzh0N6B9Eq(QEh%p~vbQV@$ zEUeBpe|M?3N-9;URPP+3j+Q?E{QQ5M(=@bPPP3>~m6g(#UhAcF^q@+vt=DR0C{20r z>zEcAA3|^eTbviW-G;~Qa3-m1hr1L?V#c2tJGG!j;>~0bY&r`+??!&R4w4ajx}Jf4 z5F1Tp=aQxC*^=BC({>;Gfg6uX$X!G|4_)SVG#)44>-faiZ~ps%1&+&Dw+!l+^$#lu z97WCv2JDD$s2(H*@Jmc~fKE^X6Hgz0Mm!^giI8#_2|SQPCasHTvdz!u;~|*Haq?tv z*dngkDS0t`-oVEem^U8HC?`bM96HQS#_vTy>b-X1xlZvPD<07_NCdkYgtnD#aP{H~ z!PN|KVDC4{^GxXOP@k{ku&&BBBGVn4`ztTvMf!rK8=*tWN0;XajJr5xg6{6V6||~n zx$HBL!O)Y9o}Sz7ylr_O-o`x|w&q3D@XA;CD?VbEqx-`t2-t+48Th@oY#JpVTJEHY zrYI5HiyAY~!q|nUl5sn-my0b^4SF{7^nAIq81uIJ8PFglSsevr4S&k}u4cOWL|)~$ zpKIY??fCsEz+HEfZe@7elIlW9L2|U28X9R(>k^b*YL3_ppPj7Bi%>%u6OD{eZb=Sc z=Zs#J3!CvI=lyvfvx58ADEWFmHtuZSVvlx8$S68%s&KMDYK&XFkS9_UU{DzGE?YI3ES#8G8i$OH*f zxFFLN0@z}6Xt5{dTB!(hb56|-AVPT{j(*)TEjI2A3}Z#^gu+@>Hvl1aHaVY5l~ahcFl>VQ4;TIsA(4j z!qlodieg1J^TwPkbSYeH2>fX9%-(!VGF^I!15e!6)& z?BsEYs6>D+Z**grtWTNZ742|y*5{A&!BLGQMk%WYHl}RaH^iq57g08m6%M%Qu zYjly1?GTL=!Ak-ei`V~IK7k!6Yr@-DnqfF=Op>^Q#LU|4{_74b-QSuda6yj#%QeCK vjFxHS^71_ { console.log("蓝牙初始化成功:" + JSON.stringify(args)); this.data.isOpenBlue = true; + this.data.available=true; resolve(true); if (this.data.isSubscribe) { //整个App生命周期,只订阅一次 @@ -939,6 +940,10 @@ class BleHelper { resolve(false); return; } + if(!this.data.available){ + reject(this.getError({code:10001})); + return; + } console.log("正在连接" + deviceId); uni.createBLEConnection({ deviceId: deviceId, diff --git a/utils/BleReceive.js b/utils/BleReceive.js index ad07427..13a0b99 100644 --- a/utils/BleReceive.js +++ b/utils/BleReceive.js @@ -257,25 +257,25 @@ class BleReceive { try { // 跳过帧头(第一个字节),从第二个字节开始解析 let staticLevelByte = bytes[1]; - let staticLevelText = '未知'; + let staticLevelText = ''; switch (staticLevelByte) { case 0x65: - staticLevelText = '高档'; + staticLevelText = 'hight'; break case 0x66: - staticLevelText = '中档'; + staticLevelText = 'center'; break case 0x67: - staticLevelText = '低档'; + staticLevelText = 'low'; break case 0x68: - staticLevelText = '关闭'; + staticLevelText = 'close'; break } // 解析照明档位 let lightingLevelByte = bytes[2]; - let lightingLevelText = lightingLevelByte === 0x6d ? '强光': lightingLevelByte === 0x6e ? '弱光': '关闭'; + let lightingLevelText = lightingLevelByte === 0x6d ? 'hight': lightingLevelByte === 0x6e ? 'low': 'close'; // 解析剩余照明时间(第三和第四字节,小端序) let lightingTime = (bytes[3] << 8) | bytes[4]; @@ -286,26 +286,26 @@ class BleReceive { let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte)); let warn = bytes[6]; - if (warn == 0x00) { - warn = '无预警'; - } else if (warn == 0x01) { - warn = '弱预警'; - } else if (warn == 0x02) { - warn = '中预警'; - } else if (warn == 0x03) { - warn = '强预警'; - } else if (warn == 0x04) { - warn = '非常强预警'; - } + // if (warn == 0x00) { + // warn = '无预警'; + // } else if (warn == 0x01) { + // warn = '弱预警'; + // } else if (warn == 0x02) { + // warn = '中预警'; + // } else if (warn == 0x03) { + // warn = '强预警'; + // } else if (warn == 0x04) { + // warn = '非常强预警'; + // } - let staticWarn = bytes[7] == 0x01 ? '静止报警': '无静止报警'; + let staticWarn = bytes[7] == 0x01;//静止报警 let fourGStrenth = bytes[8]; //4g信号强度 - let sosTxt = bytes[9] == 0x00 ? '关闭' : bytes[9] == 0x01 ? '爆闪模式' : '红蓝模式'; + let sosTxt = bytes[9] == 0x00 ? '关闭' : bytes[9] == 0x01 ? 'sg' : 'rb'; - receiveData.staticLevel = staticLevelText; - receiveData.lightingLevel = lightingLevelText; - receiveData.lightingTime = lightingTime ; - receiveData.batteryLevel = batteryLevel; + receiveData.modeCurr = staticLevelText; + receiveData.lightCurr = lightingLevelText; + receiveData.xuhang = lightingTime ; + receiveData.battary = batteryLevel; receiveData.warnLevel = warn; receiveData.staticWarn = staticWarn; receiveData.fourGStrenth = fourGStrenth;