670完成
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
import request from '@/utils/request'
|
import {request,baseURL} from '@/utils/request'
|
||||||
|
|
||||||
function getdata(url,method,data){
|
function getdata(data,url,method){
|
||||||
return new Promise((resolve,reject)=>{
|
return new Promise((resolve,reject)=>{
|
||||||
if(!url){
|
if(!url){
|
||||||
reject('url为空');
|
reject('url为空');
|
||||||
@ -21,21 +21,70 @@ function getdata(url,method,data){
|
|||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
//档位设置
|
|
||||||
function gearSetting(data){
|
|
||||||
let url="";
|
|
||||||
return getdata(url,"POST",data);
|
|
||||||
}
|
|
||||||
|
|
||||||
//人员信息设置
|
//人员信息设置
|
||||||
function sendUsr(data){
|
function sendUsr(data){
|
||||||
let url="/app/xinghan/device/registerPersonInfo";
|
let url="/app/xinghan/device/registerPersonInfo";
|
||||||
return getdata(url,"POST",data);
|
return getdata(data,url,"POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
//报警信息
|
||||||
|
function warnMsg(data){
|
||||||
|
let url="/app/xinghan/device/sendAlarmMessage"
|
||||||
|
return getdata(data,url,"POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
//开机图片
|
||||||
|
function sendPic(data){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
|
const token = uni.getStorageSync('token');
|
||||||
|
const clientid = uni.getStorageSync('clientID');
|
||||||
|
let config = {
|
||||||
|
header: {}
|
||||||
|
};
|
||||||
|
if (token) {
|
||||||
|
config.header['Authorization'] = 'Bearer ' + token;
|
||||||
|
config.header['clientid'] = clientid;
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.uploadFile({
|
||||||
|
|
||||||
|
url: baseURL + '/app/xinghan/device/uploadLogo',
|
||||||
|
filePath: data.picPath,
|
||||||
|
name: 'file',
|
||||||
|
formData: {
|
||||||
|
deviceId: data.deviceId,
|
||||||
|
deviceImei: data.deviceImei
|
||||||
|
},
|
||||||
|
header: config.header,
|
||||||
|
timeout: 600000,
|
||||||
|
fail: (ex) => {
|
||||||
|
console.log("上传视频失败" ,ex);
|
||||||
|
reject(ex);
|
||||||
|
},
|
||||||
|
success: (res) => {
|
||||||
|
console.log("上传完成", res);
|
||||||
|
if(res.statusCode==200){
|
||||||
|
resolve(JSON.parse(res.data));
|
||||||
|
}else{
|
||||||
|
reject(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default{
|
export default{
|
||||||
gearSetting:gearSetting,
|
sendUsr:sendUsr,
|
||||||
sendUsr:sendUsr
|
warnMsg:warnMsg,
|
||||||
|
sendPic:sendPic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,8 +60,8 @@
|
|||||||
console.log("res.data.length="+res.data.length);
|
console.log("res.data.length="+res.data.length);
|
||||||
|
|
||||||
|
|
||||||
eventChannel.emit('ImgCutOver',res.data);
|
eventChannel.emit('ImgCutOver',{piexls:res.data,picPath:e.tempFilePath});
|
||||||
eventChannel.emit('ImgCutOver_Path',e.tempFilePath);
|
|
||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
|
@ -567,7 +567,7 @@
|
|||||||
|
|
||||||
these.Status.BottomMenu.show = false;
|
these.Status.BottomMenu.show = false;
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
processAndSendImageData(data).catch((ex) => {
|
processAndSendImageData(data.piexls).catch((ex) => {
|
||||||
console.log("出现异常", ex);
|
console.log("出现异常", ex);
|
||||||
});
|
});
|
||||||
}, 0)
|
}, 0)
|
||||||
|
@ -736,7 +736,7 @@ console.log("收到设备的数据",data)
|
|||||||
});
|
});
|
||||||
|
|
||||||
these.Status.BottomMenu.show = false;
|
these.Status.BottomMenu.show = false;
|
||||||
these.rgb565Data = ble.convertToRGB565(data);
|
these.rgb565Data = ble.convertToRGB565(data.piexls);
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
sendImagePackets().catch(() => {
|
sendImagePackets().catch(() => {
|
||||||
|
|
||||||
|
@ -104,29 +104,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- <view class="lampMode">
|
|
||||||
<view class="mode fleft" :class="formData.lightCurr?'active':''" v-on:click.stop="LampToggle()">
|
|
||||||
<view class="leftImg">
|
|
||||||
<image class="img" src="/static/images/6155/DeviceDetail/mainLamp.png" mode="aspectFit"></image>
|
|
||||||
</view>
|
|
||||||
<view class="rightTxt">
|
|
||||||
<text class="bigTxt">照明模式</text>
|
|
||||||
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mode marginLeft fleft" :class="formData.cMode=='mode'?'':'active'"
|
|
||||||
v-on:click.stop="ShowUpload()">
|
|
||||||
<view class="leftImg">
|
|
||||||
<image class="img" src="/static/images/6155/DeviceDetail/open.png" mode="aspectFit"></image>
|
|
||||||
</view>
|
|
||||||
<view class="rightTxt">
|
|
||||||
<text class="bigTxt">开机画面</text>
|
|
||||||
<text class="smallTxt">上传</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="clear"></view>
|
|
||||||
</view> -->
|
|
||||||
<view class="usrinfo">
|
<view class="usrinfo">
|
||||||
<view @click="Status.usrToggle=!Status.usrToggle">
|
<view @click="Status.usrToggle=!Status.usrToggle">
|
||||||
<text class="usrtitle fleft">人员信息登记</text>
|
<text class="usrtitle fleft">人员信息登记</text>
|
||||||
@ -161,6 +139,35 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view class="usrinfo">
|
||||||
|
<view >
|
||||||
|
<text class="usrtitle fleft">发送信息</text>
|
||||||
|
<view class="btnSend fright" v-on:click.stop="sendUrgent(null)">发送</view>
|
||||||
|
<view class="clear"></view>
|
||||||
|
</view>
|
||||||
|
<view >
|
||||||
|
|
||||||
|
<view class="item">
|
||||||
|
<input class="value" style="text-indent: 20rpx;" v-model="formData.msgTxt" placeholder="请输入文字" placeholder-class="usrplace" />
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="usrinfo picVideo">
|
||||||
|
<view >
|
||||||
|
<text class="usrtitle fleft">开机画面</text>
|
||||||
|
|
||||||
|
<view class="clear"></view>
|
||||||
|
</view>
|
||||||
|
<view v-on:click.stop="ShowUpload()" class="btnImg center">
|
||||||
|
|
||||||
|
<image class="img" src="/static/images/6155/DeviceDetail/add.png" mode="aspectFit"></image>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="proinfo lamp">
|
<view class="proinfo lamp">
|
||||||
<text class="title">产品信息</text>
|
<text class="title">产品信息</text>
|
||||||
<view class="itemcontent">
|
<view class="itemcontent">
|
||||||
@ -297,7 +304,7 @@
|
|||||||
job: "", //职位
|
job: "", //职位
|
||||||
id: "", //id
|
id: "", //id
|
||||||
msgTxt: "", //消息1
|
msgTxt: "", //消息1
|
||||||
qzwarn: false, //是否报警
|
qzwarn: false, //是否强制报警
|
||||||
warnLevel: "", //报警级别
|
warnLevel: "", //报警级别
|
||||||
staticWarn:false,//静止报警
|
staticWarn:false,//静止报警
|
||||||
fourGStrenth:0,//4G信号强度
|
fourGStrenth:0,//4G信号强度
|
||||||
@ -323,7 +330,8 @@
|
|||||||
showConfirm: false
|
showConfirm: false
|
||||||
},
|
},
|
||||||
rgb565Data: [],
|
rgb565Data: [],
|
||||||
videoHexArray: []
|
videoHexArray: [],
|
||||||
|
picPath:""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -421,22 +429,26 @@
|
|||||||
|
|
||||||
let json = JSON.parse(payload);
|
let json = JSON.parse(payload);
|
||||||
let keys = Object.keys(json);
|
let keys = Object.keys(json);
|
||||||
console.log("keys=", keys);
|
// console.log("keys=", keys);
|
||||||
if (keys.indexOf('sta_DetectGrade') > -1) { //上报的报文
|
if (keys.indexOf('sta_DetectGrade') > -1) { //上报的报文
|
||||||
console.log("收到设备上报的数据", payload);
|
console.log("收到设备上报的数据", payload);
|
||||||
// this.parseDataMQ(json);
|
this.parseDataMQ(json);
|
||||||
} else if (keys.indexOf('sta_PicTrans') > -1) { //发送开机画面
|
}
|
||||||
console.log("收到开机画面答复", payload);
|
// else if (keys.indexOf('sta_PicTrans') > -1) { //发送开机画面
|
||||||
// this.SendImgMQ(json);
|
// console.log("收到开机画面答复", payload);
|
||||||
} else if (keys.indexOf('sta_TexTrans') > -1) { //发送文本信息
|
// // this.SendImgMQ(json);
|
||||||
console.log("收到文本回复", payload);
|
// }
|
||||||
// this.SendTxtMQ(json);
|
// else if (keys.indexOf('sta_TexTrans') > -1) { //发送文本信息
|
||||||
} else if (keys.indexOf('sta_BreakNews') > -1) { //紧急通知
|
// console.log("收到文本回复", payload);
|
||||||
console.log("收到紧急消息回复", payload);
|
// // this.SendTxtMQ(json);
|
||||||
// this.sendUrgentMQ(json);
|
// }
|
||||||
} else {
|
// else if (keys.indexOf('sta_BreakNews') > -1) { //紧急通知
|
||||||
console.log("收到不能处理的数据", payload);
|
// console.log("收到紧急消息回复", payload);
|
||||||
}
|
// // this.sendUrgentMQ(json);
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// console.log("收到不能处理的数据", payload);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -476,7 +488,54 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
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;
|
||||||
|
},
|
||||||
bleValueNotify: function(receive, device, path) { //订阅消息
|
bleValueNotify: function(receive, device, path) { //订阅消息
|
||||||
|
|
||||||
let data = recei.ReceiveData(receive, device, pagePath);
|
let data = recei.ReceiveData(receive, device, pagePath);
|
||||||
@ -503,41 +562,44 @@
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.refreshFormData(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(this.formData.imei){
|
|
||||||
this.initMQ();
|
|
||||||
}
|
|
||||||
if (these.formData.staticWarn) {//有静止报警
|
|
||||||
these.showPop({
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
refreshFormData(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(this.formData.imei){
|
||||||
|
this.initMQ();
|
||||||
|
}
|
||||||
|
if (these.formData.staticWarn) {//有静止报警
|
||||||
|
these.showPop({
|
||||||
|
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();
|
||||||
|
},
|
||||||
getDevice: function() {
|
getDevice: function() {
|
||||||
|
|
||||||
// console.log("LinkedList=", ble.data.LinkedList);
|
// console.log("LinkedList=", ble.data.LinkedList);
|
||||||
@ -796,7 +858,7 @@
|
|||||||
proParam: function() {
|
proParam: function() {
|
||||||
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/common/productDes/index?id=' + this.formData.id,
|
url: '/pages/common/productDes/index?id=' + this.device.id,
|
||||||
success(ev) {
|
success(ev) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -804,7 +866,7 @@
|
|||||||
},
|
},
|
||||||
handRemark: function() {
|
handRemark: function() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/common/operatingInstruct/index?id=' + this.formData.id,
|
url: '/pages/common/operatingInstruct/index?id=' + this.device.id,
|
||||||
success(ev) {
|
success(ev) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -812,7 +874,7 @@
|
|||||||
},
|
},
|
||||||
handVideo: function() {
|
handVideo: function() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/common/operationVideo/index?id=' + this.formData.id,
|
url: '/pages/common/operationVideo/index?id=' + this.device.id,
|
||||||
success(ev) {
|
success(ev) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -821,6 +883,41 @@
|
|||||||
checkImgUpload: function(type, index) {
|
checkImgUpload: function(type, index) {
|
||||||
console.log("123213213213");
|
console.log("123213213213");
|
||||||
let f = these.getDevice();
|
let f = these.getDevice();
|
||||||
|
|
||||||
|
var sendImgByRequest=()=>{
|
||||||
|
return new Promise((resolve,reject)=>{
|
||||||
|
api.sendPic({
|
||||||
|
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",
|
||||||
|
});
|
||||||
|
resolve();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
these.showPop({
|
||||||
|
message: res.errMsg?res.errMsg:"未知的原因上传失败了",
|
||||||
|
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||||
|
borderColor: "#e034344d",
|
||||||
|
buttonBgColor: "#E03434",
|
||||||
|
});
|
||||||
|
reject(res);
|
||||||
|
}
|
||||||
|
}).catch((ex)=>{
|
||||||
|
console.log("图片上传失败了",ex);
|
||||||
|
reject(ex)
|
||||||
|
}).finally(()=>{
|
||||||
|
hideLoading(these);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
// 分包发送图片数据
|
// 分包发送图片数据
|
||||||
var sendImagePackets = function(ReSendNo) {
|
var sendImagePackets = function(ReSendNo) {
|
||||||
|
|
||||||
@ -918,7 +1015,7 @@
|
|||||||
updateLoading(these, {
|
updateLoading(these, {
|
||||||
text: "正在发送:" + currentPacket + "/" +
|
text: "正在发送:" + currentPacket + "/" +
|
||||||
totalPackets
|
totalPackets
|
||||||
})
|
});
|
||||||
currentPacket++;
|
currentPacket++;
|
||||||
|
|
||||||
setTimeout(sendNextPacket, 0);
|
setTimeout(sendNextPacket, 0);
|
||||||
@ -927,19 +1024,21 @@
|
|||||||
if (err.code == '10007') {
|
if (err.code == '10007') {
|
||||||
setTimeout(sendNextPacket, 0);
|
setTimeout(sendNextPacket, 0);
|
||||||
return;
|
return;
|
||||||
|
}else{
|
||||||
|
updateLoading(these, {
|
||||||
|
text: "蓝牙发送失败,正在使用4G发送"
|
||||||
|
});
|
||||||
|
sendImgByRequest().then(resolve).catch(reject);
|
||||||
}
|
}
|
||||||
these.Status.BottomMenu.show = false;
|
// these.Status.BottomMenu.show = false;
|
||||||
|
// these.showPop({
|
||||||
|
// message: err.msg,
|
||||||
|
// iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||||
these.showPop({
|
// borderColor: "#e034344d",
|
||||||
message: err.msg,
|
// buttonBgColor: "#E03434",
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
// });
|
||||||
borderColor: "#e034344d",
|
// hideLoading(these);
|
||||||
buttonBgColor: "#E03434",
|
// reject(err);
|
||||||
});
|
|
||||||
hideLoading(these);
|
|
||||||
reject(err);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -952,15 +1051,11 @@
|
|||||||
f.wirteCharactId).then(() => {
|
f.wirteCharactId).then(() => {
|
||||||
sendNextPacket();
|
sendNextPacket();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log("握手没有成功");
|
updateLoading(these, {
|
||||||
these.showPop({
|
text: "蓝牙发送失败,正在使用4G发送"
|
||||||
message: err.msg,
|
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
|
||||||
borderColor: "#e034344d",
|
|
||||||
buttonBgColor: "#E03434",
|
|
||||||
});
|
});
|
||||||
hideLoading(these);
|
sendImgByRequest().then(resolve).catch(reject);
|
||||||
reject(err);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -978,8 +1073,10 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
these.Status.BottomMenu.show = false;
|
these.Status.BottomMenu.show = false;
|
||||||
these.rgb565Data = ble.convertToRGB565(data);
|
these.picPath=data.picPath;
|
||||||
|
these.rgb565Data = ble.convertToRGB565(data.piexls);
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
|
||||||
sendImagePackets().catch(() => {
|
sendImagePackets().catch(() => {
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -1080,7 +1177,7 @@
|
|||||||
dataView.setUint8(6 + i, '0x' + packetData[i]);
|
dataView.setUint8(6 + i, '0x' + packetData[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let inteval = 50;
|
let inteval = 30;
|
||||||
console.log("开始发送一段视频"); //
|
console.log("开始发送一段视频"); //
|
||||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
|
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
|
||||||
.wirteCharactId, 10).then(() => {
|
.wirteCharactId, 10).then(() => {
|
||||||
@ -1272,8 +1369,8 @@
|
|||||||
this.Status.BottomMenu.menuItems = [];
|
this.Status.BottomMenu.menuItems = [];
|
||||||
this.Status.BottomMenu.title = "上传开机画面";
|
this.Status.BottomMenu.title = "上传开机画面";
|
||||||
this.Status.BottomMenu.type = "checkImg";
|
this.Status.BottomMenu.type = "checkImg";
|
||||||
this.Status.BottomMenu.show = true;
|
this.Status.BottomMenu.show = true;
|
||||||
this.formData.cMode = "img";
|
this.Status.BottomMenu.showBtn=false;
|
||||||
},
|
},
|
||||||
|
|
||||||
showMenu(flag) {
|
showMenu(flag) {
|
||||||
@ -1335,8 +1432,8 @@
|
|||||||
|
|
||||||
let requestSend=()=>{
|
let requestSend=()=>{
|
||||||
let json = {
|
let json = {
|
||||||
deviceId: '1942386314582163705',
|
deviceId: this.device.id,
|
||||||
deviceImei: '862419074249128',
|
deviceImei: this.device.deviceImei?this.device.deviceImei:this.formData.imei,
|
||||||
name: this.formData.company,
|
name: this.formData.company,
|
||||||
position: this.formData.name,
|
position: this.formData.name,
|
||||||
unitName: this.formData.job,
|
unitName: this.formData.job,
|
||||||
@ -1514,6 +1611,67 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
sendUrgent(type) {
|
||||||
|
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));
|
||||||
|
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));
|
||||||
|
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
|
||||||
|
]
|
||||||
|
}
|
||||||
|
console.log("data=",data);
|
||||||
|
api.warnMsg(data).then((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
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
these.showPop({
|
||||||
|
message: res.msg,
|
||||||
|
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||||
|
borderColor: "#e034344d",
|
||||||
|
buttonBgColor: "#E03434",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).finally(()=>{
|
||||||
|
hideLoading(this);
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
HoldYouHand(str, pauseTime, deviceid, serviceid, characid) {
|
HoldYouHand(str, pauseTime, deviceid, serviceid, characid) {
|
||||||
@ -2189,4 +2347,14 @@ display: flex;
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
.picVideo .btnImg{
|
||||||
|
width: 100%;
|
||||||
|
height:100rpx;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
background: rgba(42, 42, 42, 1);
|
||||||
|
}
|
||||||
|
.picVideo .btnImg .img{
|
||||||
|
width: 40rpx;
|
||||||
|
height:40rpx;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
@ -335,6 +335,8 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
uni.getBluetoothAdapterState({
|
uni.getBluetoothAdapterState({
|
||||||
success: (info) => {
|
success: (info) => {
|
||||||
|
this.data.available=info.available;
|
||||||
|
this.data.discovering=info.discovering;
|
||||||
resolve(info);
|
resolve(info);
|
||||||
},
|
},
|
||||||
fail: (ex1) => {
|
fail: (ex1) => {
|
||||||
@ -358,6 +360,7 @@ class BleHelper {
|
|||||||
resolve(false);
|
resolve(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uni.openBluetoothAdapter({
|
uni.openBluetoothAdapter({
|
||||||
success: (args) => {
|
success: (args) => {
|
||||||
console.log("蓝牙初始化成功:" + JSON.stringify(args));
|
console.log("蓝牙初始化成功:" + JSON.stringify(args));
|
||||||
|
@ -45,21 +45,23 @@ class BleReceive {
|
|||||||
|
|
||||||
|
|
||||||
ReceiveData(receive,f,path) {
|
ReceiveData(receive,f,path) {
|
||||||
if(f && f.macAddress && f.id){
|
if(f && f.macAddress && f.id){
|
||||||
|
let data={};
|
||||||
if(f.detailPageUrl=='/pages/6155/deviceDetail'){
|
if(f.detailPageUrl=='/pages/6155/deviceDetail'){
|
||||||
console.log("该设备是6155");
|
console.log("该设备是6155");
|
||||||
return this.Receive_6155(receive,f,path);
|
data= this.Receive_6155(receive,f,path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(f.detailPageUrl=='/pages/650/HBY650'){
|
if(f.detailPageUrl=='/pages/650/HBY650'){
|
||||||
console.log("该设备是650");
|
console.log("该设备是650");
|
||||||
return this.Receive_650(receive,f,path);
|
data= this.Receive_650(receive,f,path);
|
||||||
}
|
}
|
||||||
if(f.detailPageUrl=='/pages/670/HBY670'){
|
if(f.detailPageUrl=='/pages/670/HBY670'){
|
||||||
console.log("该设备是670");
|
console.log("该设备是670");
|
||||||
return this.Receive_670(receive,f,path);
|
data= this.Receive_670(receive,f,path);
|
||||||
}
|
}
|
||||||
|
console.log("收到数据并处理完毕,",data);
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
console.log("已收到该消息,但无法处理",f);
|
console.log("已收到该消息,但无法处理",f);
|
||||||
|
|
||||||
@ -242,7 +244,7 @@ class BleReceive {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let data=parseData();
|
let data=parseData(receive.bytes);
|
||||||
console.log("data=",data);
|
console.log("data=",data);
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
@ -251,10 +253,11 @@ class BleReceive {
|
|||||||
Receive_670(receive,f,path){
|
Receive_670(receive,f,path){
|
||||||
|
|
||||||
var todo = (bytes) =>{
|
var todo = (bytes) =>{
|
||||||
|
console.log("todo");
|
||||||
let receiveData = {};
|
let receiveData = {};
|
||||||
if (bytes[0] == 0x55) {
|
if (bytes[0] == 0x55) {
|
||||||
try {
|
try {
|
||||||
|
console.log("todo");
|
||||||
// 跳过帧头(第一个字节),从第二个字节开始解析
|
// 跳过帧头(第一个字节),从第二个字节开始解析
|
||||||
let staticLevelByte = bytes[1];
|
let staticLevelByte = bytes[1];
|
||||||
let staticLevelText = '';
|
let staticLevelText = '';
|
||||||
@ -272,7 +275,7 @@ class BleReceive {
|
|||||||
staticLevelText = 'close';
|
staticLevelText = 'close';
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
console.log("todo");
|
||||||
// 解析照明档位
|
// 解析照明档位
|
||||||
let lightingLevelByte = bytes[2];
|
let lightingLevelByte = bytes[2];
|
||||||
let lightingLevelText = lightingLevelByte === 0x6d ? 'hight': lightingLevelByte === 0x6e ? 'low': 'close';
|
let lightingLevelText = lightingLevelByte === 0x6d ? 'hight': lightingLevelByte === 0x6e ? 'low': 'close';
|
||||||
@ -284,24 +287,24 @@ class BleReceive {
|
|||||||
let batteryLevelByte = bytes[5];
|
let batteryLevelByte = bytes[5];
|
||||||
|
|
||||||
let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
|
let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
|
||||||
|
console.log("todo");
|
||||||
let warn = bytes[6];
|
let warn = bytes[6];
|
||||||
// if (warn == 0x00) {
|
if (warn == 0x00) {
|
||||||
// warn = '无预警';
|
warn = 'none';
|
||||||
// } else if (warn == 0x01) {
|
} else if (warn == 0x01) {
|
||||||
// warn = '弱预警';
|
warn = 'ruo';
|
||||||
// } else if (warn == 0x02) {
|
} else if (warn == 0x02) {
|
||||||
// warn = '中预警';
|
warn = 'center';
|
||||||
// } else if (warn == 0x03) {
|
} else if (warn == 0x03) {
|
||||||
// warn = '强预警';
|
warn = 'hight';
|
||||||
// } else if (warn == 0x04) {
|
} else if (warn == 0x04) {
|
||||||
// warn = '非常强预警';
|
warn = 'veryhight';
|
||||||
// }
|
}
|
||||||
|
|
||||||
let staticWarn = bytes[7] == 0x01;//静止报警
|
let staticWarn = bytes[7] == 0x01;//静止报警
|
||||||
let fourGStrenth = bytes[8]; //4g信号强度
|
let fourGStrenth = bytes[8]; //4g信号强度
|
||||||
let sosTxt = bytes[9] == 0x00 ? '关闭' : bytes[9] == 0x01 ? 'sg' : 'rb';
|
let sosTxt = bytes[9] == 0x00 ? 'close' : bytes[9] == 0x01 ? 'sg' : 'rb';
|
||||||
|
console.log("todo");
|
||||||
receiveData.modeCurr = staticLevelText;
|
receiveData.modeCurr = staticLevelText;
|
||||||
receiveData.lightCurr = lightingLevelText;
|
receiveData.lightCurr = lightingLevelText;
|
||||||
receiveData.xuhang = lightingTime ;
|
receiveData.xuhang = lightingTime ;
|
||||||
@ -313,6 +316,7 @@ class BleReceive {
|
|||||||
} catch(error) {
|
} catch(error) {
|
||||||
console.log('数据解析错误:', error);
|
console.log('数据解析错误:', error);
|
||||||
}
|
}
|
||||||
|
console.log("todo");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
let uint8Array = new Uint8Array(receive.value);
|
let uint8Array = new Uint8Array(receive.value);
|
||||||
@ -325,7 +329,7 @@ class BleReceive {
|
|||||||
receiveData.macAddress = str.split(':').slice(1).join(":");
|
receiveData.macAddress = str.split(':').slice(1).join(":");
|
||||||
console.log('收到mac地址:', +this.receiveData.macAddress);
|
console.log('收到mac地址:', +this.receiveData.macAddress);
|
||||||
} else if (str.indexOf('imei:') == 0) {
|
} else if (str.indexOf('imei:') == 0) {
|
||||||
receiveData.IMEI = str.split(':')[1];
|
receiveData.imei = str.split(':')[1];
|
||||||
console.log('收到IEMI:', +this.receiveData.macAddress);
|
console.log('收到IEMI:', +this.receiveData.macAddress);
|
||||||
|
|
||||||
} else if (str.indexOf('longitude:') == 0) {
|
} else if (str.indexOf('longitude:') == 0) {
|
||||||
@ -376,13 +380,13 @@ class BleReceive {
|
|||||||
console.log('将数据转文本失败', ex);
|
console.log('将数据转文本失败', ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log("todo",receiveData);
|
||||||
this.setBleFormData(receiveData,f);
|
this.setBleFormData(receiveData,f);
|
||||||
return receiveData;
|
return receiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let data=todo();
|
let data=todo(receive.bytes);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ class MqttClient {
|
|||||||
this.client.onMessageArrived = (message) => {
|
this.client.onMessageArrived = (message) => {
|
||||||
const topic = message.destinationName;
|
const topic = message.destinationName;
|
||||||
const payload = message.payloadString;
|
const payload = message.payloadString;
|
||||||
console.log(`收到消息, 主题: ${topic}, 内容: ${payload}`);
|
// console.log(`收到消息, 主题: ${topic}, 内容: ${payload}`);
|
||||||
const potentialJsons = payload.replace(/}\s*{/g, '}|{').split('|');
|
const potentialJsons = payload.replace(/}\s*{/g, '}|{').split('|');
|
||||||
potentialJsons.forEach(jsonString => {
|
potentialJsons.forEach(jsonString => {
|
||||||
if (jsonString.trim() === '') return;
|
if (jsonString.trim() === '') return;
|
||||||
|
@ -28,9 +28,11 @@ const request = (options) => {
|
|||||||
header: options.header || {},
|
header: options.header || {},
|
||||||
timeout: 30000,
|
timeout: 30000,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
|
console.log("请求成功",res);
|
||||||
resolve(res.data);
|
resolve(res.data);
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
|
console.log("请求失败",err);
|
||||||
reject(err);
|
reject(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user