diff --git a/App.vue b/App.vue
index c8dacb7..754e310 100644
--- a/App.vue
+++ b/App.vue
@@ -1,14 +1,46 @@
@@ -54,4 +86,9 @@
.uni-picker-view-wrapper{
background: rgba(42, 42, 42, 1);
}
+
+ @font-face {
+ font-family: "PingFang SC";
+ src: url("~@/static/fonts/PingFangSC.ttf") format("opentype");
+ }
diff --git a/api/670/HBY670.js b/api/670/HBY670.js
index 4cc35d3..f8fca9d 100644
--- a/api/670/HBY670.js
+++ b/api/670/HBY670.js
@@ -1,4 +1,4 @@
-import {request,baseURL} from '@/utils/request'
+import request, { baseURL } from '@/utils/request'
function getdata(data,url,method){
return new Promise((resolve,reject)=>{
@@ -14,6 +14,7 @@ function getdata(data,url,method){
method: method,
data:data
}).then((res)=>{
+ console.log("res=",res);
resolve(res);
}).catch(ex=>{
reject(ex);
diff --git a/api/670/History.js b/api/670/History.js
new file mode 100644
index 0000000..be5ddfd
--- /dev/null
+++ b/api/670/History.js
@@ -0,0 +1,55 @@
+import request, { baseURL } from '@/utils/request'
+
+function getdata(data,url,method){
+ return new Promise((resolve,reject)=>{
+ if(!url){
+ reject('url为空');
+ return;
+ }
+ if(!method){
+ method='POST';
+ }
+ request({
+ url: url,
+ method: method,
+ data:data
+ }).then((res)=>{
+ console.log("res=",res);
+ resolve(res);
+ }).catch(ex=>{
+ console.log("ex=",ex);
+ reject(ex);
+ });
+ });
+
+}
+
+
+//获取开关机数据
+function getSwithData(data){
+ let url="";
+ return getdata(data,url,"POST");
+}
+
+//报警信息
+function getWarnData(data){
+ let url=""
+ return getdata(data,url,"POST");
+}
+
+//故障信息
+function getFaulData(data){
+ let url=""
+ return getdata(data,url,"POST");
+}
+
+export default{
+ getSwithData:getSwithData,
+ getWarnData:getWarnData,
+ getFaulData:getFaulData
+}
+
+
+
+
+
diff --git a/components/MessagePopup/MessagePopup.vue b/components/MessagePopup/MessagePopup.vue
index a5faf71..6b6cefc 100644
--- a/components/MessagePopup/MessagePopup.vue
+++ b/components/MessagePopup/MessagePopup.vue
@@ -177,17 +177,19 @@ export default {
return styles[this.type][styleType]
},
handleButtonClick() {
- console.log('[MessagePopup] Button clicked with value:', this.inputValue)
+
this.$emit('buttonClick', this.inputValue)
},
handleMaskClick() {
- console.log('[MessagePopup] Mask clicked')
+
this.$emit('maskClick')
},
closeClick(){
+
this.$emit('closePop')
},
handleCancelClick(){
+
this.$emit('cancelPop');
},
handleInput(e) {
diff --git a/main.js b/main.js
index 42275af..1a815db 100644
--- a/main.js
+++ b/main.js
@@ -2,14 +2,14 @@ import App from './App'
//// 引入 uView UI
import uView from 'vk-uview-ui';
-import bleTool from '@/store/BLETools.js';
+
// #ifndef VUE3
import Vue from 'vue'
import store from './store/store';
import './uni.promisify.adaptor'
Vue.config.productionTip = false
-Vue.prototype.$bleTool = bleTool;
+
App.mpType = 'app'
const app = new Vue({
store,
@@ -25,7 +25,7 @@ import {
} from 'vue'
export function createApp() {
const app = createSSRApp(App)
- app.config.globalProperties.$bleTool = bleTool;
+
// 使用 uView UI
app.use(uView)
return {
diff --git a/manifest.json b/manifest.json
index 5a09c99..fd3db9d 100644
--- a/manifest.json
+++ b/manifest.json
@@ -2,7 +2,7 @@
"name" : "JingQuan",
"appid" : "__UNI__A21EF43",
"description" : "设备管控",
- "versionName" : "1.0.0",
+ "versionName" : "1.0.9",
"versionCode" : "100",
"transformPx" : false,
/* 5+App特有相关 */
@@ -85,7 +85,7 @@
"appkey_ios" : "065c43f02c7b627a74ad7dd23b16bb4f",
"appkey_android" : "d7d852dbda2b95f6f796fb9a711a9fee"
},
- "customStyle": true
+ "customStyle" : true
},
"oauth" : {},
"push" : {}
diff --git a/pages.json b/pages.json
index 297bc18..cd0037d 100644
--- a/pages.json
+++ b/pages.json
@@ -265,7 +265,8 @@
{
"path": "pages/670/HBY670",
"style": {
- "navigationBarTitleText": "HBY670"
+ "navigationBarTitleText": "HBY670",
+ "navigationStyle": "custom"
}
},
{
@@ -273,6 +274,13 @@
"style": {
"navigationBarTitleText": "HBY650"
}
+ },
+ {
+ "path" : "pages/670/History",
+ "style" :
+ {
+ "navigationBarTitleText" : "历史记录"
+ }
}
diff --git a/pages/670/HBY670.vue b/pages/670/HBY670.vue
index ea422b6..39a6abc 100644
--- a/pages/670/HBY670.vue
+++ b/pages/670/HBY670.vue
@@ -1,6 +1,9 @@
-
+
+
+
@@ -41,10 +44,16 @@
- 设备自动报警中!
- {{Status.staticWarn.time}}s
+ 警告!环境存在漏电电源!
+
+
+
+
+
+
+
-
+
档位
@@ -61,21 +70,25 @@
@click="GearSetting('hight','staticBattery')">
高档
-
+
- SOS
+ 报警
-
+
声光报警
-
+
-
+
红蓝闪烁
@@ -86,25 +99,31 @@
-
+
强光
-
+
-
+
弱光
-
+
-
+
关闭
-
+
人员信息登记
@@ -139,35 +158,36 @@
-
+
-
+
发送信息
- 发送
+ 发送
-
-
-
-
+
+
+
+
-
+
-
+
-
+
开机画面
-
+
-
+
-
+
-
+
产品信息
@@ -191,8 +211,8 @@
:borderColor="Status.Pop.borderColor" :textColor="Status.Pop.textColor"
:buttonBgColor="Status.Pop.buttonBgColor" :buttonTextColor="Status.Pop.buttonTextColor"
:iconUrl="Status.Pop.iconUrl" :message="Status.Pop.message" :buttonText="Status.Pop.buttonText"
- @buttonClick="HidePop" :visiblePrompt="Status.Pop.visiblePrompt" :promptTitle="Status.Pop.promptTitle"
- v-model="Status.Pop.modelValue" />
+ @buttonClick="HidePop" @closePop="closePop" @cancelPop="closePop" :visiblePrompt="Status.Pop.visiblePrompt"
+ :promptTitle="Status.Pop.promptTitle" v-model="Status.Pop.modelValue" />
{
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
-
+ these.formData.deviceId = v.deviceId;
return true;
}
return false;
@@ -374,11 +417,10 @@
these.formData[key] = form[key];
}
}
- if(these.formData['imei'] && !these.device.deviceImei){
+ if (these.formData['imei'] && !these.device.deviceImei) {
these.initMQ();
- }
- else if(these.device.deviceImei){
- these.formData['imei'] =these.device.deviceImei;
+ } else if (these.device.deviceImei) {
+ these.formData['imei'] = these.device.deviceImei;
}
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId);
});
@@ -391,49 +433,95 @@
ble.removeReceiveCallback(pagePath);
},
computed: {
- RSSIRemark: function() {
- let remark = '极弱';
- if (this.formData.RSSI <= 0 && this.formData.RSSI >= -30) {
- remark = '强';
- }
- if (this.formData.RSSI < -30 && this.formData.RSSI >= -60) {
- remark = '一般';
- }
- if (this.formData.RSSI < -60 && this.formData.RSSI >= -85) {
- remark = '弱';
- }
- if (this.formData.RSSI < -85 && this.formData.RSSI >= -100) {
- remark = '微弱';
- }
- }
},
methods: {
- initMQ() {
+ getWarnStyle(index) {
+ let className = "";
+
+ switch (this.formData.warnLevel) {
+ case "none":
+ break;
+ case "ruo":
+ if (index <= 1) {
+ className = "active";
+ }
+ break;
+ case "center":
+ if (index <= 3) {
+ className = "active";
+ }
+ break;
+ case "hight":
+ if (index <= 4) {
+ className = "active";
+ }
+ break;
+ case "veryhight":
+ if (index <= 5) {
+ className = "active";
+ }
+ break;
+ }
+ return className;
+ },
+ handleRightClick: function(s, e) {
+
+ if (s === 0) {
+ console.log("消息");
+ uni.navigateTo({
+ url: '/pages/670/History',
+ success: (res) => {
+ res.eventChannel.emit('detailData', {
+ data: these.device,
+ });
+ }
+ })
+ return;
+ } else if (s === 1) {
+ console.log("分享");
+ uni.navigateTo({
+ url: '/pages/6170/share/index',
+ events: {
+ ack: function(data) {}
+ },
+ success: (res) => {
+ res.eventChannel.emit('share', {
+ data: this.device,
+ });
+ }
+ })
+ }
+ },
+
+ initMQ() {
+
return new Promise((resolve, reject) => {
- console.log("正在初始化MQtt")
+
if (mqttClient) {
console.log("无需再次初始化")
resolve();
return;
}
+ console.log("正在初始化MQtt")
mqttClient = new MqttClient();
mqttClient.connect(() => {
console.log("连接成功,开始订阅消息")
// 订阅来自设备的状态更新
- const statusTopic = `A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`;
+ 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);
+ // console.log("keys=", keys);sta_DetectGrade
if (keys.indexOf('sta_DetectGrade') > -1) { //上报的报文
console.log("收到设备上报的数据", payload);
- this.parseDataMQ(json);
- }
+ this.parseDataMQ(json);
+ }
// else if (keys.indexOf('sta_PicTrans') > -1) { //发送开机画面
// console.log("收到开机画面答复", payload);
// // this.SendImgMQ(json);
@@ -449,8 +537,8 @@
// else {
// console.log("收到不能处理的数据", payload);
// }
-
-
+
+
} catch (error) {
console.log("无法解析此消息", error);
}
@@ -459,9 +547,10 @@
});
});
},
-
+
sendMQ(message) {
- message=JSON.stringify(message);
+ message = JSON.stringify(message);
+ console.log("imei=", this.formData.imei ? this.formData.imei : this.device.deviceImei);
const topic = `B/${this.formData.imei?this.formData.imei:this.device.deviceImei}`;
return new Promise((resolve, reject) => {
if (!mqttClient) {
@@ -480,66 +569,74 @@
console.log("MQTT未连接,无法发布消息")
reject("MQTT未连接,无法发布消息");
} catch (error) {
- console.log("出现了异常",error);
- mqttClient.unsubscribe(`A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`);
+ console.log("出现了异常", error);
+ mqttClient.unsubscribe(
+ `A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`);
mqttClient.disconnect();
this.initMQ();
reject(error);
}
});
},
- parseDataMQ(json){
- let staticLevelText = "";
- let dic = {
- "3": "hight",
- "2": "center",
- "1": "low",
- "0": "close",
-
- };
- staticLevelText = dic[json.sta_DetectGrade];
-
- let lightingLevelText = json.sta_LightGrade ===
- 1 ? 'hight' :
- json.sta_LightGrade ===
- 2 ?
- 'low' :
- 'close';
- let warn = "";
- dic = {
- "0": "none",
- "1": "ruo",
- "2": "center",
- "3": "hight",
- "4": "veryhight",
- };
- warn = dic[json.sta_DetectResult];
-
-
- let sosText = json.sta_SOSGrade === 2 ? 'rb' :
- json.sta_SOSGrade === 1 ? "sg" : "close"
-
- let staticWarn = json.sta_ShakeBit === 1 ;
-
- receiveData.modeCurr = staticLevelText;
- receiveData.lightCurr = lightingLevelText;
- receiveData.xuhang = json.sta_PowerTime + "分钟";
- receiveData.battary = json.sta_PowerPercent + "%";
- receiveData.SOS = sosText;
- receiveData.warnLevel = warn;
- receiveData.staticWarn = staticWarn;
- receiveData.fourGStrenth = json.sta_4gSinal;
- receiveData.imei = json.sta_imei;
- receiveData.Lon = json.sta_longitude;
- receiveData.Lat = json.sta_latitude;
-
- this.refreshFormData(receiveData);
- return receiveData;
- },
+ parseDataMQ(json) {
+ let receiveData = {};
+ let staticLevelText = "";
+ let dic = {
+ "3": "hight",
+ "2": "center",
+ "1": "low",
+ "0": "close",
+
+ };
+ staticLevelText = dic[json.sta_DetectGrade];
+
+ let lightingLevelText = json.sta_LightGrade ===
+ 1 ? 'hight' :
+ json.sta_LightGrade ===
+ 2 ?
+ 'low' :
+ 'close';
+ let warn = "";
+ dic = {
+ "0": "none",
+ "1": "ruo",
+ "2": "center",
+ "3": "hight",
+ "4": "veryhight",
+ };
+ warn = dic[json.sta_DetectResult];
+
+
+ let sosText =null;
+ if(json.sta_SOSGrade!==undefined){
+
+
+ sosText=json.sta_SOSGrade === 2 ? 'rb' :
+ json.sta_SOSGrade === 1 ? "sg" : "close"
+
+ receiveData.SOS = sosText;
+ }
+ let staticWarn = json.sta_ShakeBit === 1;
+
+ receiveData.modeCurr = staticLevelText;
+ receiveData.lightCurr = lightingLevelText;
+ receiveData.xuhang = json.sta_PowerTime + "分钟";
+ receiveData.battary = json.sta_PowerPercent + "%";
+
+ receiveData.warnLevel = warn;
+ receiveData.staticWarn = staticWarn;
+ receiveData.fourGStrenth = json.sta_4gSinal;
+ receiveData.imei = json.sta_imei;
+ receiveData.Lon = json.sta_longitude;
+ receiveData.Lat = json.sta_latitude;
+
+ this.refreshFormData(receiveData,'auto');
+ return receiveData;
+ },
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) {
//重发图片
@@ -562,11 +659,11 @@
}
return;
}
- this.refreshFormData(data);
-
+ this.refreshFormData(data,'auto');
+
}
},
- refreshFormData(data){
+ refreshFormData(data,type) {
let keys = Object.keys(data);
for (var i = 0; i < keys.length; i++) {
let key = keys[i];
@@ -574,30 +671,30 @@
these.formData[key] = data[key];
}
}
- if(this.formData.imei){
+ if (this.formData.imei) {
this.initMQ();
}
- if (these.formData.staticWarn) {//有静止报警
+ if (these.formData.staticWarn) { //有静止报警
these.showPop({
- message: "自动报警",
+ message: "环境存在漏电电源",
iconUrl: "/static/images/6155/DeviceDetail/warnning.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
- buttonText:"解除报警",
- clickEvt:"staticWarn"
+ 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)
-
+ // this.Status.staticWarn.time=5;
+ // 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();
},
getDevice: function() {
@@ -611,7 +708,7 @@
return f;
},
setBleFormData() {
- let f=ble.data.LinkedList.find((v) => {
+ let f = ble.data.LinkedList.find((v) => {
if (v.deviceId == these.formData.deviceId) {
v.formData = these.formData;
@@ -619,12 +716,12 @@
}
return false;
});
- if(f){
- uni.setStorageSync(ble.StorageKey, ble.data.LinkedList);
+ if (f) {
+ uni.setStorageSync(ble.StorageKey, ble.data.LinkedList);
}
-
+
},
- lightSetting:function(type){
+ lightSetting: function(type) {
if (this.formData.lightCurr == type) {
return;
}
@@ -638,42 +735,43 @@
ble: {
qiang: 0x6D,
ruo: 0x6E,
- jieneng:0x6E,
+ jieneng: 0x6E,
close: 0x6F
},
mqtt: {
qiang: 1,
ruo: 2,
- jieneng:2,
+ jieneng: 2,
close: 0
}
};
- console.log("type=",type);
- let json= {
- ins_SOSGrade: [dic.mqtt[type]]
- };
+ console.log("type=", type);
+ let json = {
+ ins_LightGrade: [dic.mqtt[type]]
+ };
- let requestSend=()=>{
- this.sendMQ(json).then((res)=>{
+ let requestSend = () => {
+ this.sendMQ(json).then((res) => {
console.log("4g发送成功");
- }).catch((ex)=>{
+ }).catch((ex) => {
+ console.log("ex=",ex);
these.showPop({
message: "通信异常,请检查手机或设备网络",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
-
- }).finally(()=>{
+
+ }).finally(() => {
hideLoading(these);
these.setBleFormData();
});
-
-
+
+
}
let f = this.getDevice();
- let buffer=null;
+ let buffer = null;
if (f) {
// 发送数据
buffer = new ArrayBuffer(6);
@@ -684,26 +782,26 @@
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);
+ console.log("蓝牙发送失败,转4g发送", ex);
requestSend();
});
} else {
- requestSend();
+ requestSend();
}
}
setTimeout(task, 0);
},
- sosSetting:function(type){
+ sosSetting: function(type) {
if (this.formData.SOS == type) {
- type="close";
+ type = "close";
}
showLoading(this, {
@@ -712,74 +810,96 @@
let task = () => {
this.formData.SOS = type;
let dic = {
- ble: {
- sg: 0x68,
- rb: 0x69,
- close: 0x6A
- },
- mqtt: {
- sg: 2,
- rb: 1,
- close: 0
+ ble: {
+ rb: 0x68,
+ sg: 0x69,
+ close: 0x6A
+ },
+ mqtt: {
+ sg: 1,
+ rb: 2,
+ close: 0
+ }
+
}
+ console.log("type=", type);
+ let json = {
+ ins_SOSGrade: [dic.mqtt[type]]
+ };
- }
- console.log("type=",type);
- let json= {
- ins_SOSGrade: [dic.mqtt[type]]
- };
-
- let requestSend=()=>{
- this.sendMQ(json).then((res)=>{
+ let requestSend = () => {
+ this.sendMQ(json).then((res) => {
console.log("4g发送成功");
- }).catch((ex)=>{
+ }).catch((ex) => {
+ console.log("ex=",ex);
these.showPop({
message: "通信异常,请检查手机或设备网络",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
-
- }).finally(()=>{
+
+ }).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);
+ let SendCmd = () => {
+ 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("蓝牙发送成功了");
+
+ dic={
+ close: 0x71
+ }
+ if(type in dic){
+ dataView.setUint8(1, 0x06); // 帧类型
+ dataView.setUint8(5, 0x71); // 数据
+
+ }else{
+ dataView.setUint8(1, 0x06); // 帧类型
+ dataView.setUint8(5, 0x70); // 数据
+ }
+ ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(()=>{
+ console.log("蓝牙发送报警成功",type);
+ })
+
+ hideLoading(these);
+ these.setBleFormData();
+ }).catch((ex) => {
+ //使用4G发送
+ console.log("蓝牙发送失败,转4g发送", ex);
+ requestSend();
+ });
+ } else {
requestSend();
- });
- } else {
- requestSend();
+ }
}
+
+ SendCmd();
}
setTimeout(task, 0);
},
- GearSetting: function(type) {//档位设置
+ GearSetting: function(type) { //档位设置
if (this.formData.modeCurr == type) {
- type="close";
+ type = "close";
}
showLoading(this, {
text: "请稍候..."
@@ -800,61 +920,63 @@
close: 0
}
}
- console.log("type=",type);
- let json= {
+ console.log("type=", type);
+ let json = {
ins_DetectGrade: [dic.mqtt[type]]
}
- let requestSend=()=>{
- this.sendMQ(json).then((res)=>{
+ let requestSend = () => {
+ this.sendMQ(json).then((res) => {
console.log("4g发送成功");
- }).catch((ex)=>{
+ }).catch((ex) => {
+ console.log("ex=",ex)
these.showPop({
message: "通信异常,请检查手机或设备网络",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
-
- }).finally(()=>{
+
+ }).finally(() => {
hideLoading(these);
these.setBleFormData();
});
-
-
+
+
}
let f = this.getDevice();
- let buffer=null;
+ 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);
+ console.log("蓝牙发送失败,转4g发送", ex);
requestSend();
});
} else {
- requestSend();
+ console.log("找不到蓝牙设备,使用4G发送")
+ requestSend();
}
}
setTimeout(task, 0);
},
-
+
proParam: function() {
uni.navigateTo({
@@ -883,40 +1005,40 @@
checkImgUpload: function(type, index) {
console.log("123213213213");
let f = these.getDevice();
-
- var sendImgByRequest=()=>{
- return new Promise((resolve,reject)=>{
+
+ var sendImgByRequest = () => {
+ return new Promise((resolve, reject) => {
api.sendPic({
- picPath:these.picPath,
- deviceId:these.device.id,
- deviceImei:these.device.deviceImei
- }).then((res)=>{
+ picPath: these.picPath,
+ deviceId: these.device.id,
+ deviceImei: these.device.deviceImei
+ }).then((res) => {
if (res.code == 200) {
these.showPop({
showPop: true,
message: "上传成功",
- iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
+ iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
});
resolve();
return;
} else {
-
+
these.showPop({
- message: res.errMsg?res.errMsg:"未知的原因上传失败了",
+ message: res.errMsg ? res.errMsg : "未知的原因上传失败了",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
reject(res);
}
- }).catch((ex)=>{
- console.log("图片上传失败了",ex);
+ }).catch((ex) => {
+ console.log("图片上传失败了", ex);
reject(ex)
- }).finally(()=>{
+ }).finally(() => {
hideLoading(these);
});
});
-
+
}
// 分包发送图片数据
var sendImagePackets = function(ReSendNo) {
@@ -1024,7 +1146,7 @@
if (err.code == '10007') {
setTimeout(sendNextPacket, 0);
return;
- }else{
+ } else {
updateLoading(these, {
text: "蓝牙发送失败,正在使用4G发送"
});
@@ -1055,8 +1177,10 @@
text: "蓝牙发送失败,正在使用4G发送"
});
sendImgByRequest().then(resolve).catch(reject);
-
+
});
+ } else {
+ sendImgByRequest().then(resolve).catch(reject);
}
});
}
@@ -1073,10 +1197,10 @@
});
these.Status.BottomMenu.show = false;
- these.picPath=data.picPath;
+ these.picPath = data.picPath;
these.rgb565Data = ble.convertToRGB565(data.piexls);
setTimeout(function() {
-
+
sendImagePackets().catch(() => {
});
@@ -1117,7 +1241,7 @@
these.HoldYouHand("transmit complete", 0, f
.deviceId, f
.writeServiceId, f.wirteCharactId).then(
- () => {
+ () => {
console.log("全部发送完毕")
}).catch((ex) => {
console.log("出现异常", ex);
@@ -1369,8 +1493,8 @@
this.Status.BottomMenu.menuItems = [];
this.Status.BottomMenu.title = "上传开机画面";
this.Status.BottomMenu.type = "checkImg";
- this.Status.BottomMenu.show = true;
- this.Status.BottomMenu.showBtn=false;
+ this.Status.BottomMenu.show = true;
+ this.Status.BottomMenu.showBtn = false;
},
showMenu(flag) {
@@ -1406,40 +1530,65 @@
},
HidePop: function() {
if (this.Status.Pop.clickEvt == 'staticWarn') {
- this.Status.staticWarnTime=0;
+ // this.Status.staticWarnTime=0;
+ // clearInterval(this.Status.staticWarn.inteval);
+ // this.formData.staticWarn=false;
}
+ if(this.Status.Pop.okCallback){
+ console.log("执行点击按钮回调");
+ this.Status.Pop.okCallback();
+ }
+
this.Status.Pop.showPop = false;
},
+ closePop: function() {
+ this.Status.Pop.showPop = false;
+
+ if(this.Status.Pop.cancelCallback){
+ this.Status.Pop.cancelCallback();
+ }
+ },
showPop: function(option) {
-
- if (!option) {
- option = {
- a: 1
+ hideLoading(this);
+ let defaultCfg = {
+ showCancel: false,
+ borderColor: '#BBE600',
+ buttonBgColor:'#BBE600',
+ okCallback:null,
+ cancelCallback:null,
+ popType: 'custom'
};
+ if (!option) {
+
}
let keys = Object.keys(option);
for (var i = 0; i < keys.length; i++) {
let key = keys[i];
these.Status.Pop[key] = option[key];
}
- if (!option.borderColor) {
- option.borderColor = '#BBE600';
- option.buttonBgColor = '#BBE600';
+ keys = Object.keys(defaultCfg);
+ for (var i = 0; i < keys.length; i++) {
+ let key = keys[i];
+ if(key in option){
+ continue;
+ }
+ these.Status.Pop[key] = defaultCfg[key];
}
+
these.Status.Pop.showPop = true;
},
sendUsr: function(ReSendNo) {
- let requestSend=()=>{
+ let requestSend = () => {
let json = {
deviceId: this.device.id,
- deviceImei: this.device.deviceImei?this.device.deviceImei:this.formData.imei,
+ deviceImei: this.device.deviceImei ? this.device.deviceImei : this.formData.imei,
name: this.formData.company,
- position: this.formData.name,
+ position: this.formData.usrname,
unitName: this.formData.job,
- code: this.formData.id
+ code: this.formData.usrid
};
- api.sendUsr(json).then((res)=>{
+ api.sendUsr(json).then((res) => {
these.showPop({
showPop: true, //是否显示弹窗
popType: 'custom',
@@ -1458,23 +1607,23 @@
visibleClose: true
});
these.setBleFormData();
- }).catch((ex)=>{
+ }).catch((ex) => {
these.showPop({
message: "文字发送失败," + ex.msg,
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
- }).finally(()=>{
+ }).finally(() => {
hideLoading(these);
});
}
var textLines = [
this.formData.company,
- this.formData.name,
+ this.formData.usrname,
this.formData.job,
- this.formData.id
+ this.formData.usrid
];
@@ -1572,13 +1721,13 @@
currentPacket++;
setTimeout(sendNextPacket, 0);
}).catch(err => {
- if(err.code=='10007'){
+ if (err.code == '10007') {
setTimeout(sendNextPacket, 0);
- }else{
- requestSend();
- }
+ } else {
+ requestSend();
+ }
}).finally(() => {
-
+
});
};
@@ -1597,15 +1746,15 @@
() => {
setTimeout(sendText, 200);
}).catch((ex) => {
- requestSend();
- // 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);
@@ -1613,53 +1762,56 @@
},
sendUrgent(type) {
- if(!this.formData.msgTxt){
-
+ if (!this.formData.msgTxt) {
+
return;
}
showLoading(this, {
text: "请稍候..."
});
this.setBleFormData();
- let arr=[];
- if(this.formData.msgTxt.length>8){
- arr.push(this.formData.msgTxt.substring(0,8));
+ let arr = [];
+ if (this.formData.msgTxt.length > 8) {
+ arr.push(this.formData.msgTxt.substring(0, 8));
arr.push(this.formData.msgTxt.substring(8));
- }else{
- let index=Math.floor(this.formData.msgTxt.length/2)
- arr.push(this.formData.msgTxt.substring(0,index));
+ } else {
+ let index = Math.floor(this.formData.msgTxt.length / 2)
+ arr.push(this.formData.msgTxt.substring(0, index));
arr.push(this.formData.msgTxt.substring(index));
}
-
- let data={
- "sendMsg": arr.join('|'),
- "deviceIds": [
- this.device.id
- ],
- "deviceImeiList": [
- this.device.deviceImei?this.device.deviceImei:this.formData.imei
- ]
+
+ let data = {
+ "sendMsg": arr.join('|'),
+ "deviceIds": [
+ this.device.id
+ ],
+ "deviceImeiList": [
+ this.device.deviceImei ? this.device.deviceImei : this.formData.imei
+ ]
}
- console.log("data=",data);
- api.warnMsg(data).then((res)=>{
+ console.log("data=", data);
+ api.warnMsg(data).catch((ex) => {
+ console.log("ex=", ex);
+ }).then((res) => {
+ console.log("res=", res)
if (res.code == 200) {
- 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.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
+ });
} else {
these.showPop({
message: res.msg,
@@ -1668,10 +1820,10 @@
buttonBgColor: "#E03434",
});
}
- }).finally(()=>{
+ }).finally(() => {
hideLoading(this);
});
-
+
},
HoldYouHand(str, pauseTime, deviceid, serviceid, characid) {
@@ -1697,7 +1849,7 @@
resolve(true);
}, pauseTime);
}).catch(err => {
-
+
console.log("握手没有成功", )
reject(err);
});
@@ -1945,6 +2097,7 @@
box-sizing: border-box;
padding: 24rpx 28rpx;
background: rgba(26, 26, 26, 1);
+ margin-bottom: 20rpx;
}
.usrtitle {
@@ -2127,7 +2280,7 @@
border-radius: 50%;
color: rgba(255, 255, 255, 0.87);
-
+
font-family: PingFang SC;
font-size: 28rpx;
font-weight: 400;
@@ -2233,21 +2386,21 @@
align-items: center;
}
- .optTitle{
+ .optTitle {
color: rgba(255, 255, 255, 0.87);
-font-family: 'PingFang SC';
-font-size: 28rpx;
-font-weight: 400;
+ 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;
+ letter-spacing: 0.14rpx;
+ text-align: left;
+ width: 100%;
+ box-sizing: border-box;
+ padding: 30rpx 0rpx 10rpx 30rpx;
}
- .sosContent{
+ .sosContent {
width: 100%;
height: 130rpx;
@@ -2258,8 +2411,9 @@ padding:30rpx 0rpx 10rpx 30rpx;
justify-content: space-between;
align-items: center;
}
- .sosContent .item{
- width:calc(calc(100% - 80rpx) / 2);
+
+ .sosContent .item {
+ width: calc(calc(100% - 80rpx) / 2);
height: 100%;
box-sizing: border-box;
border-radius: 16rpx;
@@ -2277,35 +2431,36 @@ padding:30rpx 0rpx 10rpx 30rpx;
align-items: center;
}
- .sosContent .item.active{
+ .sosContent .item.active {
border: 1px solid rgba(224, 52, 52, 1);
color: rgba(224, 52, 52, 1);
}
- .sosContent .imgContent{
+ .sosContent .imgContent {
width: 55rpx;
height: 55rpx;
background-color: #232323;
border-radius: 4rpx;
margin-right: 30rpx;
}
- .sosContent .imgContent .img{
+
+ .sosContent .imgContent .img {
width: 70%;
height: 70%;
-
+
}
- .sosContent .item.active .imgContent{
+ .sosContent .item.active .imgContent {
background-color: #E034340F;
}
- .lightMode{
+ .lightMode {
width: 100%;
height: 180rpx;
border-radius: 16rpx;
-background: rgba(26, 26, 26, 1);
-margin-bottom: 30rpx;
-display: flex;
+ background: rgba(26, 26, 26, 1);
+ margin-bottom: 30rpx;
+ display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
@@ -2314,47 +2469,90 @@ display: flex;
}
- .lightMode .item{
- width:calc(calc(100% - 90rpx) / 3);
+ .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;
+ flex-direction: column;
+ flex-wrap: nowrap;
+ align-content: center;
+ justify-content: space-evenly;
+ align-items: center;
}
- .lightMode .item.active{
-
- color:#AED600;
+ .lightMode .item.active {
+
+ color: #AED600;
}
- .lightMode .imgContent{
+ .lightMode .imgContent {
width: 80rpx;
- height: 100rpx;
+ height: 100rpx;
}
- .lightMode .imgContent .img{
+
+ .lightMode .imgContent .img {
width: 100%;
height: 100%;
-
+
}
- .picVideo .btnImg{
+
+ .picVideo .btnImg {
width: 100%;
- height:100rpx;
+ height: 100rpx;
border-radius: 16rpx;
background: rgba(42, 42, 42, 1);
}
- .picVideo .btnImg .img{
+
+ .picVideo .btnImg .img {
width: 40rpx;
- height:40rpx;
+ height: 40rpx;
+ }
+
+
+ .netContent {
+ display: flex;
+ flex-direction: row;
+ flex-wrap: nowrap;
+ align-content: flex-end;
+ justify-content: space-around;
+ align-items: flex-end;
+ width: 50rpx;
+ }
+
+ .net {
+ width: 7rpx;
+ background: rgba(255, 255, 255, 0.3);
+ }
+
+ .net.netone {
+ height: 11rpx;
+ }
+
+ .net.nettwo {
+ height: 17rpx;
+ }
+
+ .net.netsiri {
+ height: 23rpx;
+ }
+
+ .net.netfour {
+ height: 29rpx;
+ }
+
+ .net.netfive {
+ height: 35rpx;
+ }
+
+ .net.active {
+ background: #FFFFFF !important;
}
\ No newline at end of file
diff --git a/pages/670/History.vue b/pages/670/History.vue
new file mode 100644
index 0000000..1afdb50
--- /dev/null
+++ b/pages/670/History.vue
@@ -0,0 +1,446 @@
+
+
+
+ 开机
+ 报警
+ 故障
+
+
+
+
+
+
+ 开机时间
+ {{item['open']}}
+
+
+ 关机时间
+ {{item['close']}}
+
+
+
+
+
+
+
+ 报警事项:
+ {{item['evtName']}}
+
+
+ 报警地点:
+ {{item['address']}}
+
+
+ 报警时间:
+ {{item['open']}}
+
+
+ 解除时间:
+ {{item['close']}}
+
+
+ 报警时长:
+ {{item['time']}}
+
+
+
+
+
+
+
+ 故障部位:
+ {{item['evtName']}}
+
+
+
+ 故障时间:
+ {{item['open']}}
+
+
+ 处理时间:
+ {{item['close']}}
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/common/addBLE/LinkBle.vue b/pages/common/addBLE/LinkBle.vue
index c45f4fe..b65b3eb 100644
--- a/pages/common/addBLE/LinkBle.vue
+++ b/pages/common/addBLE/LinkBle.vue
@@ -78,6 +78,7 @@
ble.removeReceiveCallback(pagePath);
},
onUnload() {
+ console.log("返回时断开蓝牙连接,取消订阅");
ble.removeReceiveCallback(pagePath);
},
onLoad(option) {
@@ -86,12 +87,12 @@
ble.addReceiveCallback((receive,f,path) => {
console.log("收到设备消息,", receive);
if (these.device.deviceId == receive.deviceId) {
- console.log("11111");
+ // console.log("11111");
if (receive.bytes[0] == 0xFC || receive.str.indexOf('mac address:') == 0) {
if (f && f.macAddress) {
these.device.macAddress = f.macAddress;
- console.log("222222");
+ // console.log("222222");
these.initDevice();
}
}
@@ -99,13 +100,23 @@
},pagePath);
eventChannel = this.getOpenerEventChannel();
eventChannel.on('LinkItem', function(data) {
+ console.log("data=",data);
let f = ble.data.LinkedList.find((v) => {
- return v.deviceId = data.deviceId;
+ return v.deviceId == data.deviceId;
});
if (f) {
- these.device = Object.assign({}, these.device, f);
- console.log("获取到设备", f);
-
+ let keys=Object.keys(f);
+ keys.forEach((v,index)=>{
+ these.device[v]=f[v];
+ })
+ console.log("LinkedList=",ble.data.LinkedList)
+ console.log("f=", f);
+ console.log("获取到设备", these.device);
+ if (f.macAddress) {
+ these.device.macAddress = f.macAddress;
+
+ these.initDevice();
+ }
} else {
console.log("未获取到设备");
}
@@ -117,6 +128,7 @@
showLoading(these, {
text: '正在获取设备信息'
});
+ console.log("these.device=",these.device);
request({
url: '/app/device/getDeviceInfoByDeviceMac',
method: 'GET',
@@ -130,12 +142,12 @@
if (data) {
let keys = Object.keys(data);
ble.data.LinkedList.find((v) => {
- if(v.deviceId = these.device.deviceId){
+ if(v.deviceId == these.device.deviceId){
for (var i = 0; i < keys.length; i++) {
let key = keys[i];
v[key] = data[key];
- console.log("key="+key);
- console.log("value="+data[key]);
+ // console.log("key="+key);
+ // console.log("value="+data[key]);
these.$set(these.device, key, data[key]);
@@ -163,7 +175,7 @@
// 调用绑定设备接口
let f = ble.data.LinkedList.find((v) => {
- return v.deviceId = these.device.deviceId;
+ return v.deviceId == these.device.deviceId;
});
if (!f) {
these.Statu.bound = false;
@@ -195,7 +207,7 @@
if (res.code == 200) {
these.Statu.bound = true;
these.Statu.boundRemark = "设备绑定成功!";
-
+ ble.removeReceiveCallback(pagePath);
uni.$emit("refreshDeviceList");
setTimeout(() => {
diff --git a/pages/common/addBLE/addEquip.vue b/pages/common/addBLE/addEquip.vue
index 5a4d3cd..b0de0f9 100644
--- a/pages/common/addBLE/addEquip.vue
+++ b/pages/common/addBLE/addEquip.vue
@@ -136,7 +136,7 @@
},
onHide: function() {
ble.StopSearch();
- ble.removeReceiveCallback(pagePath);
+
},
onBackPress: (e) => {
ble.StopSearch();
@@ -145,8 +145,7 @@
},
onUnload(){
ble.StopSearch();
- ble.removeDeviceFound(pagePath);
- ble.removeReceiveCallback(pagePath);
+
},
onLoad() {
these = this;
@@ -172,7 +171,12 @@
}
}
},pagePath);
-
+ // ble.addReceiveCallback((receivData) => {
+ // console.log("收到数据了:", receivData);//数据格式:{bytes:[109,97],str:"",hexs:"FA 01"}
+
+ // // let data=uni.getStorageSync(ble.StorageKey);
+ // console.log("LinkedList=",ble.data.LinkedList);
+ // },pagePath);
},
onShow: function() {
@@ -187,12 +191,7 @@
});
- ble.addReceiveCallback((receivData) => {
- console.log("收到数据了:", receivData);//数据格式:{bytes:[109,97],str:"",hexs:"FA 01"}
- console.log("LinkedList=",ble.data.LinkedList);
- let data=uni.getStorageSync(ble.StorageKey);
- console.log("data=",data);
- },pagePath);
+
},
@@ -241,7 +240,7 @@
these.PairEquip.push(item);
}
- ble.removeReceiveCallback(pagePath);
+ console.log("连接成功");
uni.navigateTo({
url:"/pages/common/addBLE/LinkBle",
events:{
diff --git a/pages/common/index/index.vue b/pages/common/index/index.vue
index 0d3ad04..1c3a6fa 100644
--- a/pages/common/index/index.vue
+++ b/pages/common/index/index.vue
@@ -486,6 +486,10 @@
// 列表跳转
handleFile(item) {
let url = item.detailPageUrl;
+ // console.log("url=",url);
+ // if(!url){
+ //url="/pages/670/HBY670"
+ // }
uni.navigateTo({
url: url,
events: {
@@ -498,6 +502,8 @@
deviceType: this.tabs[this.activeTab].id || '',
apiType: 'listA' //标识,根据这个参数,区分普通详情,分享跳转详情,查不一样的权限信息
});
+ },fail(ex) {
+ console.log("ex=",ex);
}
})
},
diff --git a/static/images/common/msg.png b/static/images/common/msg.png
new file mode 100644
index 0000000..e15a87e
Binary files /dev/null and b/static/images/common/msg.png differ
diff --git a/utils/BleHelper.js b/utils/BleHelper.js
index 56c9523..3d53678 100644
--- a/utils/BleHelper.js
+++ b/utils/BleHelper.js
@@ -105,17 +105,17 @@ class BleHelper {
}
linkAllDevices() {
- console.log("模块启动时,自动连接已连接过的设备", this.data.LinkedList);
+ // console.log("模块启动时,自动连接已连接过的设备", this.data.LinkedList);
if (this.data.LinkedList && this.data.LinkedList.length > 0) {
for (var i = 0; i < this.data.LinkedList.length; i++) {
let device = this.data.LinkedList[i];
- console.log("自动连接:" + device.deviceId);
+ // console.log("自动连接:" + device.deviceId);
this.LinkBlue(device.deviceId, device.writeServiceId, device.wirteCharactId, device
.notifyCharactId);
}
} else {
- console.log("无设备连接");
+ // console.log("无设备连接");
}
}
@@ -128,7 +128,7 @@ class BleHelper {
}
const currentPage = pages[pages.length - 1];
- console.log("currentPage=", currentPage.route);
+ // console.log("currentPage=", currentPage.route);
return currentPage.route;
}
@@ -181,7 +181,7 @@ class BleHelper {
key = new Date().getTime();
}
if (key) {
- console.log("订阅消息回调,key=" + key);
+ // console.log("订阅消息回调,key=" + key);
let f = this.cfg.receivDataCallback.findIndex((v) => {
return v.key == key;
});
@@ -363,7 +363,7 @@ class BleHelper {
uni.openBluetoothAdapter({
success: (args) => {
- console.log("蓝牙初始化成功:" + JSON.stringify(args));
+ // console.log("蓝牙初始化成功:" + JSON.stringify(args));
this.data.isOpenBlue = true;
this.data.available=true;
resolve(true);
@@ -371,7 +371,7 @@ class BleHelper {
if (this.data.isSubscribe) { //整个App生命周期,只订阅一次
return;
}
- console.log("开始订阅各类变化消息");
+ // console.log("开始订阅各类变化消息");
this.data.isSubscribe = true;
@@ -417,7 +417,7 @@ class BleHelper {
uni.setStorageSync(this.StorageKey, this.data
.LinkedList);
} else {
- console.log("蓝牙连接已恢复,", res);
+ // console.log("蓝牙连接已恢复,", res);
}
});
@@ -437,7 +437,7 @@ class BleHelper {
uni.onBLECharacteristicValueChange((receive) => {
//订阅消息
- console.log("收到订阅消息",receive);
+ // console.log("收到订阅消息",receive);
let f=this.data.LinkedList.find((v) => {
return v.deviceId == receive.deviceId;
})
@@ -500,7 +500,7 @@ class BleHelper {
str: str,
hexs: hexs
};
- console.log("监听到特征值:" + JSON.stringify(recData));
+ // console.log("监听到特征值:" + JSON.stringify(recData));
if (this.cfg.receivDataCallback) {
if (this.cfg.receivDataCallback.length > 0) {
@@ -678,7 +678,7 @@ class BleHelper {
state: state,
success: (res) => {
if (state) {
- console.log("订阅消息成功", res);
+ // console.log("订阅消息成功", res);
} else {
console.log("取消订阅成功", res);
}
diff --git a/utils/BleReceive.js b/utils/BleReceive.js
index c3b11ae..7015561 100644
--- a/utils/BleReceive.js
+++ b/utils/BleReceive.js
@@ -48,22 +48,23 @@ class BleReceive {
if(f && f.macAddress && f.id){
let data={};
if(f.detailPageUrl=='/pages/6155/deviceDetail'){
- console.log("该设备是6155");
+ // console.log("该设备是6155");
data= this.Receive_6155(receive,f,path);
}
if(f.detailPageUrl=='/pages/650/HBY650'){
- console.log("该设备是650");
+ // console.log("该设备是650");
data= this.Receive_650(receive,f,path);
}
if(f.detailPageUrl=='/pages/670/HBY670'){
- console.log("该设备是670");
+ // console.log("该设备是670");
data= this.Receive_670(receive,f,path);
}
- console.log("收到数据并处理完毕,",data);
+ // console.log("收到数据并处理完毕,",data);
return data;
}
- console.log("已收到该消息,但无法处理",f);
+ // console.log("已收到该消息,但无法处理",receive);
+ return receive;
}
@@ -253,11 +254,11 @@ class BleReceive {
Receive_670(receive,f,path){
var todo = (bytes) =>{
- console.log("todo");
+ // console.log("todo",receive);
let receiveData = {};
if (bytes[0] == 0x55) {
try {
- console.log("todo");
+ // console.log("todo");
// 跳过帧头(第一个字节),从第二个字节开始解析
let staticLevelByte = bytes[1];
let staticLevelText = '';
@@ -275,7 +276,7 @@ class BleReceive {
staticLevelText = 'close';
break
}
- console.log("todo");
+ // console.log("todo");
// 解析照明档位
let lightingLevelByte = bytes[2];
let lightingLevelText = lightingLevelByte === 0x6d ? 'hight': lightingLevelByte === 0x6e ? 'low': 'close';
@@ -287,7 +288,7 @@ class BleReceive {
let batteryLevelByte = bytes[5];
let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
- console.log("todo");
+ // console.log("todo");
let warn = bytes[6];
if (warn == 0x00) {
warn = 'none';
@@ -304,7 +305,7 @@ class BleReceive {
let staticWarn = bytes[7] == 0x01;//静止报警
let fourGStrenth = bytes[8]; //4g信号强度
let sosTxt = bytes[9] == 0x00 ? 'close' : bytes[9] == 0x01 ? 'sg' : 'rb';
- console.log("todo");
+ // console.log("todo");
receiveData.modeCurr = staticLevelText;
receiveData.lightCurr = lightingLevelText;
receiveData.xuhang = lightingTime ;
@@ -316,7 +317,7 @@ class BleReceive {
} catch(error) {
console.log('数据解析错误:', error);
}
- console.log("todo");
+ // console.log("todo");
} else {
try {
let uint8Array = new Uint8Array(receive.value);
@@ -340,6 +341,7 @@ class BleReceive {
console.log('收到纬度:', +this.receiveData.macAddress);
} else {
try {
+ // console.log("str=",str);
let json=JSON.parse(str);
if("staBlue_picture" in json){
//重发图片
@@ -372,7 +374,7 @@ class BleReceive {
} catch (error) {
receiveData={};
- console.log("文本解析失败")
+ // console.log("文本解析失败",error)
}
}
} catch(ex) {
@@ -380,7 +382,7 @@ class BleReceive {
console.log('将数据转文本失败', ex);
}
}
- console.log("todo",receiveData);
+ // console.log("todo",receiveData);
this.setBleFormData(receiveData,f);
return receiveData;
}
diff --git a/utils/loading.js b/utils/loading.js
index 01258bd..c5625b0 100644
--- a/utils/loading.js
+++ b/utils/loading.js
@@ -5,19 +5,17 @@ export const showLoading = (ev,options) => {
if(!ev){
return;
}
-
+ let defaultTxt="请稍候...";
if(!options){
- options={a:1};
+ options={text:defaultTxt};
}
if(!options.text && options.title){
options.text=options.title;
}
if(!options.text){
- options.text="请稍候...";
+ options.text=defaultTxt;
}
ev.$refs.loading.show(options);
-
-
}
// 隐藏loading
diff --git a/utils/mqtt.js b/utils/mqtt.js
index 0e93404..d35f036 100644
--- a/utils/mqtt.js
+++ b/utils/mqtt.js
@@ -171,7 +171,7 @@ class MqttClient {
potentialJsons.forEach(jsonString => {
if (jsonString.trim() === '') return;
if (this.messageCallbacks.has(topic)) {
- this.messageCallbacks.get(topic)(jsonString);
+ this.messageCallbacks.get(topic)(jsonString,message);
}
});
};
@@ -285,8 +285,10 @@ class MqttClient {
mqttMessage.qos = 1;
this.client.send(mqttMessage);
console.log(`成功发布消息到主题 ${topic}: ${message}`);
+ return true;
} else {
console.error('MQTT未连接,无法发布');
+ return false;
}
}
diff --git a/utils/request.js b/utils/request.js
index 23ad91f..8078084 100644
--- a/utils/request.js
+++ b/utils/request.js
@@ -22,9 +22,11 @@ const request = (options) => {
header: options.header || {},
timeout: 30000,
success: (res) => {
+ console.log("res=",res);
resolve(res.data);
},
fail: (err) => {
+ console.log("ex=",err);
reject(err);
}
};