diff --git a/App.vue b/App.vue index faaf989..a21853c 100644 --- a/App.vue +++ b/App.vue @@ -30,43 +30,41 @@ //以上代码仅在开发时使用,否则会出现不可预知的问题。 // #ifdef APP|APP-PLUS - - bleTool.getBleTool(); - - var appid = plus.runtime.appid; - console.log('应用的 appid 为:' + appid); - + if (plus.runtime.isAgreePrivacy()) { + + + bleTool.getBleTool(); - uni.getPushClientId({ - success(res) { - console.log("推送信息:", res); - uni.setStorageSync('push_cid', res.cid); - }, - fail(err) { - console.error(err) + uni.getPushClientId({ + success(res) { + console.log("推送信息:", res); + uni.setStorageSync('push_cid', res.cid); + }, + fail(err) { + console.error(err) + } + }); + if (!uni.setAppBadgeNumber) { //兼容鸿蒙的写法 + uni.setAppBadgeNumber = plus.runtime.setBadgeNumber; } - }); - if(!uni.setAppBadgeNumber){//兼容鸿蒙的写法 - uni.setAppBadgeNumber=plus.runtime.setBadgeNumber; - } - uni.onPushMessage((res) => { - console.log("收到推送消息:", res); //监听推送消息 - if(res.type=='click'){ - //将App角标设置为0,清空app在消息中心的所有消息 - uni.setAppBadgeNumber(0); - plus.push.clear(); - return; - } - uni.createPushMessage({ - title: res.data.title, - content: res.data.content, - payload:res.data.payload + uni.onPushMessage((res) => { + console.log("收到推送消息:", res); //监听推送消息 + if (res.type == 'click') { + //将App角标设置为0,清空app在消息中心的所有消息 + uni.setAppBadgeNumber(0); + plus.push.clear(); + return; + } + uni.createPushMessage({ + title: res.data.title, + content: res.data.content, + payload: res.data.payload + }); + }); - }); - - + } // #endif }, @@ -74,18 +72,15 @@ console.log('App Show'); //将检查更新换到onshow,因为苹果用户喜欢一直挂着 - uni.getSystemInfo({ - success: function(res) { - if (res.uniPlatform == 'app') { - - let appid = plus.runtime.appid; - if (appid !== 'HBuilder') { - console.log("appid=", appid); - upgrade.checkAndUpdateWgt(); - } - } - } - }); + // #ifdef APP|APP-PLUS + + let appid = plus.runtime.appid; + console.log("appid=", appid); + + if (appid !== 'HBuilder') { + upgrade.checkAndUpdateWgt(); + } + // #endif }, onHide: function() { console.log('App Hide'); @@ -212,5 +207,4 @@ font-family: "PingFangBold"; src: url("~@/static/fonts/PingFangBold.ttf") format("opentype"); } - \ No newline at end of file diff --git a/api/6170/deviceControl.js b/api/6170/deviceControl.js index c517ee5..3fcb147 100644 --- a/api/6170/deviceControl.js +++ b/api/6170/deviceControl.js @@ -63,6 +63,10 @@ export function mapReverseGeocoding(data) { }) } -export function deviceRealTimeStatus(){ - return Promise.resolve({code:500}); +export function deviceRealTimeStatus(params){ + return request({ + url: `/app/device/realTimeStatus`, + method: 'get', + data:params + }) } \ No newline at end of file diff --git a/manifest.json b/manifest.json index 985c208..864842f 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "name" : "星汉物联", "appid" : "__UNI__A21EF43", "description" : "设备管控", - "versionName" : "1.0.18", + "versionName" : "1.0.19", "versionCode" : 101, "transformPx" : false, /* 5+App特有相关 */ @@ -114,7 +114,8 @@ "xhdpi" : "unpackage/res/icons/48x48.png", "xxhdpi" : "unpackage/res/icons/72x72.png" } - } + }, + "meizu" : {} } } }, diff --git a/pages.json b/pages.json index 8bc5df7..64d3058 100644 --- a/pages.json +++ b/pages.json @@ -52,8 +52,7 @@ { "path": "pages/common/send/index", "style": { - "navigationBarTitleText": "发送信息", - "enablePullDownRefresh": true + "navigationBarTitleText": "发送信息" } }, { @@ -102,10 +101,9 @@ } }, { - "path": "pages/6170/callPolice/index", + "path": "pages/common/callPolice/index", "style": { - "navigationBarTitleText": "报警", - "enablePullDownRefresh": true + "navigationBarTitleText": "报警" } }, @@ -160,14 +158,7 @@ "navigationStyle": "custom" } }, - { - "path": "pages/6155/ImgCrop", - "style": { - "navigationBarTitleText": "图像裁剪", - "navigationStyle": "custom", - "fullscreen": true - } - }, + { "path": "pages/6075/BJQ6075", "style": { @@ -447,6 +438,14 @@ { "navigationStyle": "custom" } + }, + { + "path": "pages/common/ImgCrop/ImgCrop", + "style": { + "navigationBarTitleText": "图像裁剪", + "navigationStyle": "custom", + "fullscreen": true + } } ], diff --git a/pages/100/HBY100.vue b/pages/100/HBY100.vue index 6a9a8d5..b9cdbf4 100644 --- a/pages/100/HBY100.vue +++ b/pages/100/HBY100.vue @@ -223,11 +223,11 @@ - - + + - + 产品信息 @@ -245,18 +245,18 @@ - + - - - - + - - + + @@ -518,6 +518,11 @@ recei = BleReceive.getBleReceive(); ble = BleTool.getBleTool(); + this.$watch("formData.sta_battery", (newVal, oldVal) => { + if (newVal <= 20 && this.formData.sta_system==2) { + this.showMsg("设备电量低"); + } + }); ble.addReceiveCallback(this.bleValueNotify, pagePath); ble.addStateBreakCallback(this.bleStateBreak, pagePath); @@ -572,10 +577,10 @@ these.formData.bleStatu = false; these.formData.deviceId = f.deviceId; - these.formData.bleStatu = 'connecting'; + these.formData.bleStatu = 'connecting'; ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { these.formData.bleStatu = true; - }).catch(ex=>{ + }).catch(ex => { these.formData.bleStatu = 'err'; }); these.setBleFormData(); @@ -592,17 +597,17 @@ this.Status.pageHide = false; }, computed: { - getbleStatu(){ - if(this.formData.bleStatu===true){ + getbleStatu() { + if (this.formData.bleStatu === true) { return '已连接'; } - if(this.formData.bleStatu==='connecting'){ + if (this.formData.bleStatu === 'connecting') { return '连接中'; } - if(this.formData.bleStatu==='dicconnect'){ + if (this.formData.bleStatu === 'dicconnect') { return '正在断开'; } - if(this.formData.bleStatu==='err'){ + if (this.formData.bleStatu === 'err') { return '连接异常'; } return '未连接'; @@ -1196,9 +1201,9 @@ return; } if (res.deviceId == these.formData.deviceId) { - if(res.device){ + if (res.device) { these.formData.bleStatu = 'connecting'; - }else{ + } else { this.formData.bleStatu = false; } setTimeout(() => { @@ -1233,14 +1238,14 @@ showLoading(this, { text: "蓝牙恢复可用,正在连接设备" }); - these.formData.bleStatu='connecting'; + these.formData.bleStatu = 'connecting'; ble.LinkBlue(these.formData.deviceId).then(() => { these.formData.bleStatu = true; updateLoading(these, { text: '连接成功' }); }).catch(ex => { - these.formData.bleStatu='err'; + these.formData.bleStatu = 'err'; updateLoading(these, { text: ex.msg }) @@ -1313,9 +1318,10 @@ } }); - if (this.formData.sta_battery <= 20) { - this.showMsg("设备电量低"); - } + + + + }, getDevice: function() { @@ -1327,32 +1333,32 @@ return f; }, - - bleStatuToggle(){ - let f=this.getDevice(); - if(!f){ + + bleStatuToggle() { + let f = this.getDevice(); + if (!f) { this.showBleUnConnect(); return; } - if(this.formData.bleStatu===true){ - this.formData.bleStatu='dicconnect'; - ble.disconnectDevice(f.deviceId).finally(r=>{ - this.formData.bleStatu=false; + if (this.formData.bleStatu === true) { + this.formData.bleStatu = 'dicconnect'; + ble.disconnectDevice(f.deviceId).finally(r => { + this.formData.bleStatu = false; }); return; } - - if(this.formData.bleStatu===false || this.formData.bleStatu==='err'){ - this.formData.bleStatu='connecting'; + + if (this.formData.bleStatu === false || this.formData.bleStatu === 'err') { + this.formData.bleStatu = 'connecting'; ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { these.formData.bleStatu = true; - }).catch(ex=>{ + }).catch(ex => { these.formData.bleStatu = 'err'; }); return; } - - + + }, diff --git a/pages/6075/BJQ6075.vue b/pages/6075/BJQ6075.vue index a61429b..3e4d8dc 100644 --- a/pages/6075/BJQ6075.vue +++ b/pages/6075/BJQ6075.vue @@ -679,7 +679,7 @@ } let that = this; uni.navigateTo({ - url: "/pages/6155/ImgCrop", + url: "/pages/ImgCrop/ImgCrop", events: { ImgCutOverPath: function(data) { that.selectedImage = data.picPath; diff --git a/pages/6075J/BJQ6075J.vue b/pages/6075J/BJQ6075J.vue index f6ae01e..8115957 100644 --- a/pages/6075J/BJQ6075J.vue +++ b/pages/6075J/BJQ6075J.vue @@ -411,7 +411,8 @@ staPowerTime: null, staPowerPercent: null, staDetectResult: null - } + }, + inteval:50 } }, computed: { @@ -994,179 +995,146 @@ } let f = this.getDevice(); - // 处理像素数据并发送 - var processAndSendImageData = function(pixels) { - return new Promise((resolve, reject) => { - // 创建RGB565格式的像素数据 - const arr = Common.convertToRGB565(pixels, 'bgr'); - - var list = []; - let index = 0; // 用于追踪arr的当前位置 - let packetSize = 2048; - let cSize = 248; - // 外层循环:7个主要元素(i从1到7) - for (let i = 1; i < 8; i++) { - let secondLevel = []; - let secondCnt = 0; - // 中层循环:每个主要元素包含9个子数组(j从1到9) - for (let j = 1; j < 10; j++) { - // 确定当前子数组的长度:前8个是254,第9个是64 - - let thirdLevel = []; - - // 从arr中提取相应数量的元素 - for (let k = 0; k < cSize && index < arr.length; k++) { - - if (secondCnt == packetSize) { - break; - } - thirdLevel.push(arr[index]); - secondCnt++; - index++; - } - - secondLevel.push(thirdLevel); - } - list.push(secondLevel); - } - - console.log("list=", list); - - let length = 0; - for (let i = 0; i < list.length; i++) { - const item = list[i]; - let clength = 0; - for (let j = 0; j < item.length; j++) { - const element = item[j]; - console.log("第" + i + "包,第" + j + "小包,长度:" + element.length) - length += element.length; - clength += element.length; - - - } - } - // 分包发送 - sendImagePackets(list).then(resolve).catch(reject); - }); - } - - - - // 分包发送图片数据 - var sendImagePackets = function(imageData) { + + + var sendImagePackets = function(ReSendNo) { + return new Promise((resolve, reject) => { + // 总数据包数 - const totalPackets = 7; + let totalPackets = 52; let currentPacket = 1; - let childPacket = 1; - let totalChildPacket = 9; - - - // 发送单个数据包 - const sendNextPacket = () => { - if (currentPacket > totalPackets) { - setTimeout(() => { + + if (ReSendNo) { + totalPackets = ReSendNo; + currentPacket = ReSendNo; + } + + if (f) { + // 发送单个数据包 + const sendNextPacket = () => { + if (currentPacket > totalPackets) { hideLoading(these); - - MsgSuccess("上传成功", "确定", these); - - + these.closeAction(); + these.showPop({ + showPop: true, + message: "上传成功", + iconUrl: "/static/images/common/success.png", + }); + + setTimeout(()=>{ + ble.sendString(f.deviceId, "transmit complete", f.writeServiceId, f + .wirteCharactId); + },1000); + + these.rgb565Data = null; resolve(); - }, 3000) - + return; + } + + // 计算当前包的数据 + let packetSize = 250; + // if (currentPacket <= 51) { + // packetSize = 250; // 前51个包每个500字节 + // } else { + // packetSize = 50; // 最后一个包100字节 + // } + + // 创建数据包 + const startIndex = (currentPacket - 1) * packetSize; + const endIndex = Math.min(startIndex + packetSize, these.rgb565Data + .length); + if (startIndex > endIndex) { + return; + } + const packetData = these.rgb565Data.slice(startIndex, + endIndex); + // 构建数据包 + const bufferSize = 505; // 5 + packetData.length * 2; // 头部5字节 + 数据部分 + const buffer = new ArrayBuffer(bufferSize); + const dataView = new DataView(buffer); + + // 填充头部 + dataView.setUint8(0, 0x55); // 帧头 + dataView.setUint8(1, 0x02); // 帧类型:开机画面 + dataView.setUint8(2, '0x' + currentPacket.toString(16).padStart(2, + '0')); // 包序号 + + + if (packetData.length == 250) { + dataView.setUint8(3, 0x01); + dataView.setUint8(4, 0xF4); + } else { + dataView.setUint8(3, 0x00); + dataView.setUint8(4, 0x64); + } + + // 填充数据(每个RGB565值占2字节) + for (let i = 0; i < packetData.length; i++) { + dataView.setUint16(5 + i * 2, packetData[i], false); // 大端字节序 + } + + if (currentPacket > 51) { //第52包补FF + for (var i = 105; i < bufferSize; i++) { + dataView.setUint8(i, 0xFF); + } + } + + + + //发送数据包 + ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, + 10) + .then(() => { + + + updateLoading(these, { + text: "正在发送:" + currentPacket + "/" + + totalPackets + }) + currentPacket++; + + setTimeout(sendNextPacket, these.inteval); + }).catch(err => { + console.log("发送数据包失败了" + JSON.stringify(err)); + if (err.code == '10007') { + setTimeout(sendNextPacket, these.inteval); + return; + } + these.closeAction(); + these.showPop({ + message: err.msg, + iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", + borderColor: "#e034344d", + buttonBgColor: "#E03434", + }); + hideLoading(these); + these.rgb565Data = null; + reject(err); + }); + } + + if (ReSendNo) { + sendNextPacket(ReSendNo); return; } - - var packetData = imageData[currentPacket - 1][childPacket - 1]; - - let start = 0; - let bufferSize = packetData.length * 2; - - if (currentPacket == 7) { - if (childPacket > 2 && childPacket < 9) { - bufferSize = 496; - } else if (childPacket == 9) { - bufferSize = 128; - } - } - - if (childPacket == 1) { - bufferSize = bufferSize + 8 - start = 8; - } - if (childPacket == 9) { //|| (currentPacket==7 && childPacket==3 - bufferSize = bufferSize + 1 - } - - - //FA 09 10 04 FC 09 [00] [01] + 4096字节+FF 数据格式 - var buffer = new ArrayBuffer(bufferSize); - var dataView = new DataView(buffer); - if (childPacket == 1) { - dataView.setUint8(0, 0xFA); // 帧头 - dataView.setUint8(1, 0x09); // 帧头 - dataView.setUint8(2, 0x10); // 帧头 - dataView.setUint8(3, 0x04); // 帧头 - dataView.setUint8(4, 0xFC); // 帧头 - dataView.setUint8(5, 0x09); // 帧头 - - dataView.setUint8(6, 0x00); // 图序号,图片固定0,视频的话要写序号 - dataView.setUint8(7, currentPacket); //子包序号 - } - - for (let i = 0; i < packetData.length; i++) { - dataView.setUint16(start + i * 2, packetData[i], false); //本包数据,大端字节序 - } - console.log("packetData.length=", packetData.length); - console.log("bufferSize=", bufferSize) - if (childPacket == 9) { // || (currentPacket==7 && childPacket==3 - dataView.setUint8(bufferSize - 1, 0xFF); - } - - //发送数据包 - ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, - 30) - .then(() => { - - let curr = childPacket + (currentPacket - 1) * - totalChildPacket; - console.log("第" + currentPacket + "大包,第" + childPacket + - "小包发送完成,总计:" + curr); - updateLoading(these, { - text: "正在发送" + curr + "/63" - - }) - if (childPacket == 9) { - currentPacket++; - childPacket = 1; - } else { - childPacket++; - } - - setTimeout(sendNextPacket, 100); - }).catch(err => { - if (err.code == 10007) { - setTimeout(sendNextPacket, 100); - return; - } - - console.log("发送数据包失败了", err); - - - showPop({ - message: "发送数据包失败了" + err.msg, - iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", - borderColor: "#e034344d", - buttonBgColor: "#E03434", - }); - - hideLoading(these); - reject(err); + // 开始牵手 + ble.sendString(f.deviceId, "picture transmit start", f.writeServiceId, + f.wirteCharactId).then(() => { + setTimeout(sendNextPacket, 120); + + }).catch((err) => { + console.log("握手没有成功"); + these.showPop({ + message: err.msg, + iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", + borderColor: "#e034344d", + buttonBgColor: "#E03434", }); + hideLoading(these); + reject(err); + }); } - // 开始发送数据 - sendNextPacket(); - }); } @@ -1177,7 +1145,7 @@ sourceType: ['album'], success: function(res) { uni.navigateTo({ - url: "/pages/6155/ImgCrop", + url: "/pages/ImgCrop/ImgCrop", events: { ImgCutOver: function(data) { @@ -1186,10 +1154,11 @@ }); + these.rgb565Data = Common.convertToRGB565(data.piexls); + setTimeout(function() { - processAndSendImageData(data.piexls).catch(( - ex) => { - console.log("出现异常", ex); + sendImagePackets().catch(() => { + }); }, 0) diff --git a/pages/6155/BJQ6155.vue b/pages/6155/BJQ6155.vue index 8cc8ad8..72f80b0 100644 --- a/pages/6155/BJQ6155.vue +++ b/pages/6155/BJQ6155.vue @@ -909,7 +909,7 @@ sourceType: ['album'], success: function(res) { uni.navigateTo({ - url: "/pages/6155/ImgCrop", + url: "/pages/ImgCrop/ImgCrop", events: { ImgCutOver: function(data) { diff --git a/pages/6155/ImgCrop.vue b/pages/6155/ImgCrop.vue index c6209ea..e69de29 100644 --- a/pages/6155/ImgCrop.vue +++ b/pages/6155/ImgCrop.vue @@ -1,100 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/6155/deviceDetail.vue b/pages/6155/deviceDetail.vue index 714ed14..1170edb 100644 --- a/pages/6155/deviceDetail.vue +++ b/pages/6155/deviceDetail.vue @@ -926,7 +926,7 @@ sourceType: ['album'], success: function(res) { uni.navigateTo({ - url: "/pages/6155/ImgCrop", + url: "/pages/ImgCrop/ImgCrop", events: { ImgCutOver: function(data) { diff --git a/pages/6170/deviceControl/index.vue b/pages/6170/deviceControl/index.vue index 903511c..c18438c 100644 --- a/pages/6170/deviceControl/index.vue +++ b/pages/6170/deviceControl/index.vue @@ -979,7 +979,7 @@ } let that = this; uni.navigateTo({ - url: "/pages/6155/ImgCrop", + url: "/pages/ImgCrop/ImgCrop", events: { ImgCutOver: function(data) { that.selectedImage = data.picPath; diff --git a/pages/650/HBY650.vue b/pages/650/HBY650.vue index eadbee2..6742974 100644 --- a/pages/650/HBY650.vue +++ b/pages/650/HBY650.vue @@ -1051,7 +1051,7 @@ import request, { baseURL } from '@/utils/request.js'; var gotoCutImg = (imgPath) => { uni.navigateTo({ - url: "/pages/6155/ImgCrop", + url: "/pages/ImgCrop/ImgCrop", events: { ImgCutOver: function(data) { // console.log("我收到裁剪后的图片了,感谢老铁," + data) diff --git a/pages/670/HBY670.vue b/pages/670/HBY670.vue index c0d561c..91addfe 100644 --- a/pages/670/HBY670.vue +++ b/pages/670/HBY670.vue @@ -486,10 +486,14 @@ }, onLoad: function() { - these = this; recei = BleReceive.getBleReceive(); ble = BleTool.getBleTool(); + this.$watch("formData.battary", (newVal, oldVal) => { + if (newVal <= 20 && this.formData.sta_system==2) { + this.showMsg("设备电量低"); + } + }); ble.addReceiveCallback(these.bleValueNotify, pagePath); @@ -928,30 +932,16 @@ // console.log("收到文本回复", payload); // // this.SendTxtMQ(json); // } - if (keys.indexOf('sta_BreakNews') > - - 1) { //紧急通知 - if (json.sta_BreakNews === - 'I get it' - ) // && this.Status.msgOkTime && this.Status.msgOkIntval){ - { - these.showPop({ - showPop: true, - message: "用户已确认收到紧急通知", - iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png" - }); - - // this.Status.msgOkTime=null - // clearInterval(this.Status.msgOkIntval); - - } - - - } - // else { - // console.log("收到不能处理的数据", payload); - // } - - + if (keys.indexOf('sta_BreakNews') > -1) { //紧急通知 + if(json.sta_BreakNews=='I get it'){ + these.showPop({ + showPop: true, + message: "用户已确认收到紧急通知", + iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png" + }); + } + + } } catch (error) { console.error("无法解析此消息", payload); } @@ -1881,7 +1871,7 @@ var gotoCutImg = (imgPath) => { uni.navigateTo({ - url: "/pages/6155/ImgCrop", + url: "/pages/ImgCrop/ImgCrop", events: { ImgCutOver: function(data) { // console.log("我收到裁剪后的图片了,感谢老铁," + data) diff --git a/pages/7305/BJQ7305.vue b/pages/7305/BJQ7305.vue index d7021ca..0daf510 100644 --- a/pages/7305/BJQ7305.vue +++ b/pages/7305/BJQ7305.vue @@ -783,7 +783,7 @@ sourceType: ['album'], success: function(res) { uni.navigateTo({ - url: "/pages/6155/ImgCrop", + url: "/pages/ImgCrop/ImgCrop", events: { ImgCutOver: function(data) { //将8位的二进制数组转换成16进制数据 diff --git a/pages/common/ImgCrop/ImgCrop.vue b/pages/common/ImgCrop/ImgCrop.vue new file mode 100644 index 0000000..0f68d84 --- /dev/null +++ b/pages/common/ImgCrop/ImgCrop.vue @@ -0,0 +1,100 @@ + + + + + \ No newline at end of file diff --git a/pages/common/addScan/ScanEquip.vue b/pages/common/addScan/ScanEquip.vue index aa323f8..dc6bb27 100644 --- a/pages/common/addScan/ScanEquip.vue +++ b/pages/common/addScan/ScanEquip.vue @@ -72,7 +72,6 @@ callback: this.scan }], title: '扫码' - }, }, formData: { @@ -208,7 +207,7 @@ this.qrCodeResult(cleanedResult, true, null); }, fail: (err) => { - this.showMsg("扫码失败:" + err.errMsg, MsgType.error); + MsgError("扫码失败:" + err.errMsg,"确定",these); } }); }, diff --git a/pages/6170/callPolice/index.vue b/pages/common/callPolice/index.vue similarity index 71% rename from pages/6170/callPolice/index.vue rename to pages/common/callPolice/index.vue index 0f3dec1..7a11efb 100644 --- a/pages/6170/callPolice/index.vue +++ b/pages/common/callPolice/index.vue @@ -1,497 +1,584 @@ - - - - - \ No newline at end of file diff --git a/pages/common/index/index.vue b/pages/common/index/index.vue index d5e4473..d384bde 100644 --- a/pages/common/index/index.vue +++ b/pages/common/index/index.vue @@ -18,13 +18,16 @@ - - - + 报警 + 位置 + 发送信息 + + + @@ -40,15 +43,15 @@ 设备:{{item.deviceName}} - ID:{{item.deviceImei}} + + ID:{{item.deviceImei}} ID:{{item.deviceMac}} - 在线 + 在线 - 离线 + 离线 电量:{{item.battery || '0'}}% @@ -74,7 +77,7 @@ 暂无数据 --> - + @@ -116,7 +119,7 @@ - + {{ item.text }} @@ -146,17 +149,34 @@ } from '@/api/common/index.js' import bleTool from '@/utils/BleHelper.js'; import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue' -import BleReceive from '@/utils/BleReceive'; + import BleReceive from '@/utils/BleReceive'; var pagePath = 'pages/common/index'; var ble = null; var timeout = null; - var recei=null; + var recei = null; export default { components: { MescrollUni }, - + computed:{ + showSendFlex(){ + // return this.activeTab && this.activeTab.id !== ''&& (this.activeTabInfo.communicationMode==0 || this.activeTabInfo.communicationMode==2); + if(this.showMap || this.ShowSendmessage || this.showWarn){ + return true; + } + return false; + }, + ShowSendmessage(){ + return this.dic.showMsgTypes.indexOf(this.activeTabInfo.typeName)>-1 + }, + showMap(){ + return this.dic.showMapTypes.indexOf(this.activeTabInfo.typeName)>-1 + }, + showWarn(){ + return this.dic.showCallPolice.indexOf(this.activeTabInfo.typeName)>-1 + } + }, data() { return { mescroll: null, @@ -232,7 +252,12 @@ import BleReceive from '@/utils/BleReceive'; deviceId: '', deviceName: "", //重命名 - activeTabInfo: '' + activeTabInfo: '', + dic: { + showMsgTypes: ['BJQ6170', 'HBY210', 'HBY670', 'BJQ6075', 'BJQ6075J'],//需要发送消息的类型 + showMapTypes:['BJQ6170','HBY210','HBY670','BJQ6075','HBY018A','HBY100-J','BJQ6075J','HBY008A','HBY100-Y'],//需要显示地图的类型 + showCallPolice:['BJQ6170','HBY210','HBY670','BJQ6075','HBY018A','HBY100-J','BJQ6075J','HBY008A','HBY100-Y']//需要发送报警的类型 + } } }, methods: { @@ -253,7 +278,7 @@ import BleReceive from '@/utils/BleReceive'; // 下拉刷新 downCallback() { - + if (this.mescroll) { this.mescroll.resetUpScroll(false); this.mescroll.scrollTo(0, 0); @@ -265,7 +290,7 @@ import BleReceive from '@/utils/BleReceive'; // 上拉加载 upCallback() { - + this.getData(); }, @@ -386,7 +411,7 @@ import BleReceive from '@/utils/BleReceive'; if (res.code == 200) { //console.log("deviceTypeList=" + JSON.stringify(res.data)); this.tabs = [{ - id: '', + id: '', name: '全部设备', typeName: '全部设备' }, @@ -411,7 +436,7 @@ import BleReceive from '@/utils/BleReceive'; getData() { var task = () => { - + return new Promise((resolve, reject) => { let data = { pageNum: this.mescroll.num, @@ -495,9 +520,9 @@ import BleReceive from '@/utils/BleReceive'; case 'scan': // 扫一扫 uni.navigateTo({ - url:'/pages/common/addScan/ScanEquip' + url: '/pages/common/addScan/ScanEquip' }); - + break; case 'bluetooth': uni.navigateTo({ @@ -618,7 +643,7 @@ import BleReceive from '@/utils/BleReceive'; const deviceType = currentTab.id || ''; console.log(`跳转到发送信息页面\n当前设备类型: ${deviceType}\n设备类型名称: ${currentTab.typeName}`); uni.navigateTo({ - url: '/pages/6170/callPolice/index', + url: '/pages/common/callPolice/index', events: { ack: function(data) {} }, @@ -665,7 +690,7 @@ import BleReceive from '@/utils/BleReceive'; // 列表跳转 handleFile(item) { let url = item.detailPageUrl; - // url="/pages/6075/BJQ6075L"; + // url="/pages/6075/BJQ6075L"; // if(!url){ // url="/pages/6075/BJQ6075" // } @@ -714,7 +739,7 @@ import BleReceive from '@/utils/BleReceive'; }, }, onShow() { - + if (ble) { //因为vue视图只能后退不能隐藏后再显示 //所以回到首页后将其他所有页面的订阅都删除 @@ -722,12 +747,12 @@ import BleReceive from '@/utils/BleReceive'; } }, onLoad() { - + // console.error("首页加载"); this.getTab() this.downCallback(); - - + + // 绑定页面做了监听,新增成功,刷新页面 uni.$on('refreshDeviceList', () => { this.getTab() // 刷新数据 @@ -770,9 +795,9 @@ import BleReceive from '@/utils/BleReceive'; recei.ReceiveData(receive, device, path, recArr); this.updateBleStatu(); }, pagePath); - - let phone=uni.getStorageSync("phone"); - if(phone==='17671332251'){//先写死方便自己使用,后面按人员权限区分 + + let phone = uni.getStorageSync("phone"); + if (phone === '17671332251') { //先写死方便自己使用,后面按人员权限区分 this.menuItems.push({ text: '上报设备', icon: '/static/images/common/add.png', diff --git a/pages/common/send/index.vue b/pages/common/send/index.vue index f064c70..bd4d85c 100644 --- a/pages/common/send/index.vue +++ b/pages/common/send/index.vue @@ -1,11 +1,12 @@