修改App图标、名称、蓝牙加入断线重连
This commit is contained in:
@ -249,6 +249,14 @@
|
||||
hideLoading,
|
||||
updateLoading
|
||||
} from '@/utils/loading.js'
|
||||
import {
|
||||
request,
|
||||
baseURL
|
||||
} from '../../utils/request';
|
||||
import {
|
||||
registerPersonInfo
|
||||
} from '@/api/6170/deviceControl.js';
|
||||
|
||||
const pagePath = "pages/650/HBY650";
|
||||
var ble = null;
|
||||
var these = null;
|
||||
@ -629,7 +637,7 @@
|
||||
receiveData.modeCurr = staticLevelText;
|
||||
receiveData.lightCurr = lightingLevelText;
|
||||
receiveData.xuhang = json.sta_PowerTime + "分钟";
|
||||
receiveData.battary = json.sta_PowerPercent ;
|
||||
receiveData.battary = json.sta_PowerPercent;
|
||||
|
||||
receiveData.warnLevel = warn;
|
||||
receiveData.staticWarn = staticWarn;
|
||||
@ -699,10 +707,10 @@
|
||||
},
|
||||
getDevice: function() {
|
||||
|
||||
// console.log("LinkedList=", ble.data.LinkedList);
|
||||
// console.log("formData=", these.formData);
|
||||
console.log("LinkedList=", ble.data.LinkedList);
|
||||
console.log("this.device=", this.device);
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
return v.deviceId == these.formData.deviceId;
|
||||
return v.macAddress == these.device.deviceMac;
|
||||
});
|
||||
|
||||
return f;
|
||||
@ -800,60 +808,60 @@
|
||||
setTimeout(task, 0);
|
||||
},
|
||||
CloseWarn: function(ispop) {
|
||||
let closeEvt=()=>{
|
||||
let closeEvt = () => {
|
||||
{
|
||||
these.Status.Pop.showPop = false;
|
||||
|
||||
|
||||
these.formData.qzwarn = false;
|
||||
clearInterval(these.Status.staticWarn.inteval);
|
||||
|
||||
let closeSOS=()=>{
|
||||
|
||||
let closeSOS = () => {
|
||||
let json = {
|
||||
ins_SOSGrade: [0]
|
||||
};
|
||||
|
||||
|
||||
this.sendMQ(json).then((res) => {
|
||||
console.log("4g发送成功");
|
||||
}).catch((ex) => {
|
||||
console.log("ex=",ex);
|
||||
these.showPop({
|
||||
message: "通信异常,请检查手机或设备网络",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
|
||||
}).finally(() => {
|
||||
hideLoading(these);
|
||||
these.setBleFormData();
|
||||
|
||||
|
||||
this.sendMQ(json).then((res) => {
|
||||
console.log("4g发送成功");
|
||||
}).catch((ex) => {
|
||||
console.log("ex=", ex);
|
||||
these.showPop({
|
||||
message: "通信异常,请检查手机或设备网络",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
|
||||
}).finally(() => {
|
||||
hideLoading(these);
|
||||
these.setBleFormData();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
let closeWarn=()=>{
|
||||
|
||||
|
||||
let closeWarn = () => {
|
||||
let json = {
|
||||
ins_ShakeBit: [0]
|
||||
};
|
||||
|
||||
|
||||
this.sendMQ(json).then((res) => {
|
||||
console.log("4g发送成功");
|
||||
}).catch((ex) => {
|
||||
console.log("ex=",ex);
|
||||
these.showPop({
|
||||
message: "通信异常,请检查手机或设备网络",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
|
||||
}).finally(() => {
|
||||
hideLoading(these);
|
||||
these.setBleFormData();
|
||||
|
||||
|
||||
this.sendMQ(json).then((res) => {
|
||||
console.log("4g发送成功");
|
||||
}).catch((ex) => {
|
||||
console.log("ex=", 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) {
|
||||
@ -866,31 +874,32 @@
|
||||
dataView.setUint8(3, 0x00); // 数据长度
|
||||
dataView.setUint8(4, 0x01); // 数据长度
|
||||
dataView.setUint8(5, 0x71); // 数据
|
||||
|
||||
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(
|
||||
() => {
|
||||
console.log("关闭强制报警成功")
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x05); // 帧类型
|
||||
dataView.setUint8(2, 0x01); // 包序号
|
||||
dataView.setUint8(3, 0x00); // 数据长度
|
||||
dataView.setUint8(4, 0x01); // 数据长度
|
||||
dataView.setUint8(5, 0x68);
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(()=>{
|
||||
console.log("成功");
|
||||
});
|
||||
}).catch(ex => {
|
||||
() => {
|
||||
console.log("关闭强制报警成功")
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x05); // 帧类型
|
||||
dataView.setUint8(2, 0x01); // 包序号
|
||||
dataView.setUint8(3, 0x00); // 数据长度
|
||||
dataView.setUint8(4, 0x01); // 数据长度
|
||||
dataView.setUint8(5, 0x68);
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10)
|
||||
.then(() => {
|
||||
console.log("成功");
|
||||
});
|
||||
}).catch(ex => {
|
||||
closeSOS();
|
||||
closeWarn();
|
||||
// closeWarn();
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
closeSOS();
|
||||
closeWarn();
|
||||
// closeWarn();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!ispop){
|
||||
if (!ispop) {
|
||||
closeEvt();
|
||||
return;
|
||||
}
|
||||
@ -901,8 +910,8 @@
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText:"解除报警",
|
||||
okCallback: closeEvt
|
||||
buttonText: "解除报警",
|
||||
okCallback: closeEvt
|
||||
});
|
||||
|
||||
},
|
||||
@ -972,21 +981,21 @@
|
||||
() => {
|
||||
console.log("蓝牙发送成功了");
|
||||
|
||||
dic = {
|
||||
close: 0x71
|
||||
}
|
||||
if (type in dic) {
|
||||
dataView.setUint8(1, 0x06); // 帧类型
|
||||
dataView.setUint8(5, 0x71); // 数据
|
||||
// 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);
|
||||
})
|
||||
// } 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();
|
||||
@ -1012,16 +1021,28 @@
|
||||
okCallback: function() {
|
||||
these.formData.qzwarn = true;
|
||||
|
||||
these.Status.staticWarn.time = 5;
|
||||
these.Status.staticWarn.inteval = setInterval(() => {
|
||||
these.Status.staticWarn.time = 180;
|
||||
|
||||
|
||||
let loopFunc = () => {
|
||||
if (these.Status.staticWarn.inteval === null) {
|
||||
return;
|
||||
}
|
||||
if (these.Status.staticWarn.time === 0) {
|
||||
console.log("111111");
|
||||
|
||||
clearInterval(these.Status.staticWarn.inteval);
|
||||
these.Status.staticWarn.inteval = null;
|
||||
these.formData.qzwarn = false;
|
||||
these.formData.SOS = 'close';
|
||||
these.CloseWarn(false);
|
||||
return;
|
||||
}
|
||||
these.Status.staticWarn.time = these.Status.staticWarn
|
||||
.time - 1;
|
||||
}
|
||||
these.Status.staticWarn.inteval = setInterval(() => {
|
||||
loopFunc();
|
||||
}, 1000)
|
||||
|
||||
SendCmd();
|
||||
@ -1101,8 +1122,14 @@
|
||||
these.setBleFormData();
|
||||
}).catch((ex) => {
|
||||
//使用4G发送
|
||||
console.log("蓝牙发送失败,转4g发送", ex);
|
||||
requestSend();
|
||||
if (ex.code == 10007) {
|
||||
console.log("蓝牙发送失败,正在重试");
|
||||
task();
|
||||
} else {
|
||||
console.log("蓝牙发送失败,转4g发送", ex);
|
||||
requestSend();
|
||||
}
|
||||
|
||||
});
|
||||
} else {
|
||||
console.log("找不到蓝牙设备,使用4G发送")
|
||||
@ -1437,6 +1464,8 @@
|
||||
dataView.setUint8(6 + i, '0x' + packetData[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
let inteval = 30;
|
||||
console.log("开始发送一段视频"); //
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
|
||||
@ -1487,6 +1516,17 @@
|
||||
}
|
||||
|
||||
var sendVideo = (videoPath) => {
|
||||
|
||||
let f = these.getDevice();
|
||||
if (!f) {
|
||||
these.showPop({
|
||||
message: "蓝牙未连接,请连接后再试",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
return;
|
||||
}
|
||||
let uploadVideo = () => {
|
||||
|
||||
if (these.videoHexArray.length > 0) {
|
||||
@ -1495,7 +1535,9 @@
|
||||
return;
|
||||
|
||||
}
|
||||
console.log("开始处理,正在上传");
|
||||
console.log("开始处理,正在上传", f);
|
||||
const token = uni.getStorageSync('token');
|
||||
const clientid = uni.getStorageSync('clientID');
|
||||
|
||||
showLoading(these, {
|
||||
text: "上传中"
|
||||
@ -1503,13 +1545,25 @@
|
||||
let p1 = these.HoldYouHand("video transmit start", 2200, f.deviceId, f.writeServiceId,
|
||||
f.wirteCharactId);
|
||||
let p2 = new Promise((succ, err) => {
|
||||
if (!token) {
|
||||
err({
|
||||
code: 401,
|
||||
msg: "请先登陆后再试"
|
||||
});
|
||||
hideLoading(these);
|
||||
return;
|
||||
}
|
||||
console.log("baseURL=", baseURL);
|
||||
uni.uploadFile({
|
||||
url: 'http://114.55.111.217/video/upload',
|
||||
// url: 'http://114.55.111.217/video/upload',
|
||||
url: baseURL + "/app/video/upload",
|
||||
filePath: videoPath,
|
||||
name: 'file',
|
||||
header: {
|
||||
"Method": "POST",
|
||||
"Content-Type": "multipart/form-data"
|
||||
"Content-Type": "multipart/form-data",
|
||||
"Authorization": 'Bearer ' + token,
|
||||
"clientid": clientid
|
||||
},
|
||||
timeout: 600000,
|
||||
fail: (ex) => {
|
||||
@ -1564,7 +1618,7 @@
|
||||
});
|
||||
})
|
||||
}
|
||||
let f = these.getDevice();
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1818,6 +1872,17 @@
|
||||
});
|
||||
these.setBleFormData();
|
||||
hideLoading(these);
|
||||
|
||||
|
||||
// let formdata = {
|
||||
// code: these.formData.usrid,
|
||||
// name: these.formData.usrname,
|
||||
// position: these.formData.job,
|
||||
// unitName: these.formData.company,
|
||||
// deviceId: these.device.id,
|
||||
// deviceImei: these.device.deviceImei
|
||||
// };
|
||||
// registerPersonInfo(formdata);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user