670加入机器状态、设备详情加接口请求

This commit is contained in:
liub
2025-09-18 17:31:40 +08:00
parent 404e42a7d8
commit cb44810c6b
10 changed files with 454 additions and 221 deletions

View File

@ -83,10 +83,18 @@ function sendPic(data){
}); });
} }
//设备详情
function getDetail(id){
return request({
url: '/api/xinghan/device/'+id,
method: 'get',
})
}
export default{ export default{
sendUsr:sendUsr, sendUsr:sendUsr,
warnMsg:warnMsg, warnMsg:warnMsg,
sendPic:sendPic sendPic:sendPic,
getDetail:getDetail
} }

View File

@ -328,7 +328,7 @@
}); });
if (!f) { if (!f) {
these.getDetail();
these.showBleUnConnect(); these.showBleUnConnect();
return; return;
} }
@ -347,7 +347,7 @@
these.formData.deviceId = f.deviceId; these.formData.deviceId = f.deviceId;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId); ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId);
these.setBleFormData(); these.setBleFormData();
these.getDetail();
}); });
@ -875,7 +875,7 @@
setMode(mode, type) { setMode(mode, type) {
let dataValue = 0; let dataValue = 0;
switch (mode) { switch (mode) {
case 0: case 0:
@ -1203,7 +1203,22 @@
setTimeout(task, 0); setTimeout(task, 0);
}, },
getDetail() {
var that = this;
usrApi.getDetail(this.device.id).then(res => {
if (res && res.code == 200) {
res = res.data;
let personnelInfo = res.personnelInfo;
if (personnelInfo) {
these.formData.textLines[2] = personnelInfo.unitName;
these.formData.textLines[1] = personnelInfo.name;
these.formData.textLines[0] = personnelInfo.position;
}
}
});
},
ack: function() { ack: function() {

View File

@ -255,10 +255,10 @@
cMode: false, cMode: false,
modeCurr: 'low', modeCurr: 'low',
company: '黄石消防支队', company: '',
name: '菜英俊', name: '',
job: '小队长', job: '',
id: 'HSXF01061', id: '',
iswarn: false iswarn: false
}, },
rgb565Data: [], rgb565Data: [],
@ -314,6 +314,7 @@
these.showBleUnConnect(); these.showBleUnConnect();
these.getDetail();
return; return;
} }
let form = f.formData; let form = f.formData;
@ -331,7 +332,7 @@
these.formData.deviceId = f.deviceId; these.formData.deviceId = f.deviceId;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId); ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId);
these.setBleFormData(); these.setBleFormData();
these.getDetail();
}); });
@ -457,6 +458,23 @@
return f; return f;
}, },
getDetail() {
var that = this;
usrApi.getDetail(this.device.id).then(res => {
if (res && res.code == 200) {
res = res.data;
let personnelInfo = res.personnelInfo;
if (personnelInfo) {
that.formData.company = personnelInfo.unitName;
that.formData.name = personnelInfo.name;
that.formData.job = personnelInfo.position;
that.formData.id = personnelInfo.code
}
}
});
},
setBleFormData() { setBleFormData() {
ble.data.LinkedList.find((v) => { ble.data.LinkedList.find((v) => {
if (v.deviceId == these.formData.deviceId) { if (v.deviceId == these.formData.deviceId) {
@ -959,8 +977,8 @@
} }
uni.uploadFile({ uni.uploadFile({
// url: 'http://114.55.111.217/video/upload', url: 'http://114.55.111.217/video/upload',
url: baseURL+"app/video/upload", // url: baseURL+"app/video/upload",
filePath: videoPath, filePath: videoPath,
name: 'file', name: 'file',
header: { header: {

View File

@ -33,13 +33,30 @@
<text class="lbl">设备名称</text> <text class="lbl">设备名称</text>
<text class="value">{{device.deviceName}}</text> <text class="value">{{device.deviceName}}</text>
</view> </view>
<view class="item">
<text class="lbl">设备状态</text>
<text class="value">{{formData.sta_system}}</text>
</view>
<view class="item"> <view class="item">
<text class="lbl">定位信息</text> <text class="lbl">定位信息</text>
<view> <view class="multiValue">
<view>{{formData.lon}}&nbsp;&nbsp;{{formData.lat}}</view> <view class="valueItem">
<text class="value">{{formData.address}}</text> {{formData.Lon}}
</view>
<view class="valueItem">
{{formData.Lat}}
</view>
<view class="valueItem">
<view style="width:80%;float: right;text-align: right;">{{formData.address}}</view>
<view class="clear"></view>
</view>
</view> </view>
</view> </view>
</view> </view>
@ -358,7 +375,8 @@
warnLevel: "", //报警级别 warnLevel: "", //报警级别
staticWarn: false, //静止报警 staticWarn: false, //静止报警
fourGStrenth: 0, //4G信号强度 fourGStrenth: 0, //4G信号强度
deviceId: "" deviceId: "",
sta_system: "" //设备状态0关机1仅充电2开机未充电,3开机且充电
}, },
device: { device: {
id: "", id: "",
@ -413,6 +431,7 @@
var device = data.data; var device = data.data;
these.Status.apiType = data.apiType; these.Status.apiType = data.apiType;
these.device = device; these.device = device;
if (these.device.deviceImei) { if (these.device.deviceImei) {
these.initMQ(); these.initMQ();
} }
@ -425,6 +444,7 @@
return false; return false;
}); });
if (!f) { if (!f) {
these.getDetail();
return; return;
} }
let form = f.formData; let form = f.formData;
@ -440,6 +460,7 @@
} else if (these.device.deviceImei) { } else if (these.device.deviceImei) {
these.formData['imei'] = these.device.deviceImei; these.formData['imei'] = these.device.deviceImei;
} }
these.getDetail();
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId); ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId);
}); });
@ -454,6 +475,74 @@
}, },
methods: { methods: {
getDetail() {
var that = this;
api.getDetail(this.device.id).then(res => {
if (res && res.code == 200) {
res = res.data;
let json=res;
console.log("res=",res);
that.formData.Lon = res.longitude;
that.formData.Lat = res.latitude;
that.formData.address = res.address;
let personnelInfo = res.personnelInfo;
if (personnelInfo) {
that.formData.company = personnelInfo.unitName;
that.formData.usrname = personnelInfo.name;
that.formData.job = personnelInfo.position;
that.formData.usrid = personnelInfo.code
}
let dic = {
"3": "hight",
"2": "center",
"1": "low",
"0": "close",
};
let staticLevelText = dic[json.staDetectGrade];
that.formData.modeCurr = staticLevelText;
dic = {
"0": "none",
"1": "ruo",
"2": "center",
"3": "hight",
"4": "veryhight",
};
let warn = dic[json.staDetectResult];
that.formData.warnLevel = warn;
let lightingLevelText = json.staLightGrade === 1 ? 'hight' : json.staLightGrade === 2 ? 'low' :
'close';
that.formData.lightCurr = lightingLevelText;
that.formData.battary = json.staPowerPercent
let hours = Math.floor(json.staPowerTime / 60);
let remainingMinutes = json.staPowerTime % 60;
let xuhang = '0分';
// 处理不同情况的显示
if (hours === 0) {
xuhang = `${remainingMinutes}`;
} else if (remainingMinutes === 0) {
xuhang = `${hours}小时`;
} else {
xuhang = `${hours}小时${remainingMinutes}`;
}
that.formData.xuhang = xuhang;
let sosText = json.staSOSGrade === 2 ? 'rb' : json.staSOSGrade === 1 ? "sg" : "close";
that.formData.SOS = sosText;
}
});
},
getWarnStyle(index) { getWarnStyle(index) {
let className = ""; let className = "";
@ -540,6 +629,7 @@
console.log("收到设备上报的数据", payload); console.log("收到设备上报的数据", payload);
this.parseDataMQ(json); this.parseDataMQ(json);
} }
//以下操作已改到后端
// else if (keys.indexOf('sta_PicTrans') > -1) { //发送开机画面 // else if (keys.indexOf('sta_PicTrans') > -1) { //发送开机画面
// console.log("收到开机画面答复", payload); // console.log("收到开机画面答复", payload);
// // this.SendImgMQ(json); // // this.SendImgMQ(json);
@ -598,56 +688,80 @@
}, },
parseDataMQ(json) { parseDataMQ(json) {
let receiveData = {}; let receiveData = {};
let staticLevelText = "";
let dic = {
"3": "hight",
"2": "center",
"1": "low",
"0": "close",
}; let dic = {};
staticLevelText = dic[json.sta_DetectGrade]; if ("sta_DetectGrade" in json) {
dic = {
"3": "hight",
"2": "center",
"1": "low",
"0": "close",
let lightingLevelText = json.sta_LightGrade === };
1 ? 'hight' : let staticLevelText = dic[json.sta_DetectGrade];
json.sta_LightGrade === receiveData.modeCurr = staticLevelText;
2 ? }
'low' :
'close';
let warn = "";
dic = {
"0": "none",
"1": "ruo",
"2": "center",
"3": "hight",
"4": "veryhight",
};
warn = dic[json.sta_DetectResult];
if ("sta_LightGrade" in json) {
let sosText = null; let lightingLevelText = json.sta_LightGrade === 1 ? 'hight' : json.sta_LightGrade === 2 ? 'low' :
if (json.sta_SOSGrade !== undefined) { 'close';
receiveData.lightCurr = lightingLevelText;
}
if ("sta_DetectResult" in json) {
sosText = json.sta_SOSGrade === 2 ? 'rb' : dic = {
json.sta_SOSGrade === 1 ? "sg" : "close" "0": "none",
"1": "ruo",
"2": "center",
"3": "hight",
"4": "veryhight",
};
let warn = dic[json.sta_DetectResult];
receiveData.warnLevel = warn;
}
if ("sta_SOSGrade" in json) {
let sosText = json.sta_SOSGrade === 2 ? 'rb' : json.sta_SOSGrade === 1 ? "sg" : "close";
receiveData.SOS = sosText; receiveData.SOS = sosText;
} }
let staticWarn = json.sta_ShakeBit === 1;
receiveData.modeCurr = staticLevelText; if ("sta_ShakeBit" in json) {
receiveData.lightCurr = lightingLevelText; let staticWarn = json.sta_ShakeBit === 1;
receiveData.xuhang = json.sta_PowerTime + "分钟"; receiveData.staticWarn = staticWarn;
receiveData.battary = json.sta_PowerPercent; }
receiveData.warnLevel = warn; if ("sta_PowerTime" in json) {
receiveData.staticWarn = staticWarn; let hours = Math.floor(json.sta_PowerTime / 60);
receiveData.fourGStrenth = json.sta_4gSinal; let remainingMinutes = json.sta_PowerTime % 60;
receiveData.imei = json.sta_imei; let xuhang = '0分';
receiveData.Lon = json.sta_longitude; // 处理不同情况的显示
receiveData.Lat = json.sta_latitude; if (hours === 0) {
xuhang = `${remainingMinutes}`;
} else if (remainingMinutes === 0) {
xuhang = `${hours}小时`;
} else {
xuhang = `${hours}小时${remainingMinutes}`;
}
receiveData.xuhang = xuhang;
}
("sta_PowerPercent" in json) && (receiveData.battary = json.sta_PowerPercent);
("sta_4gSinal" in json) && (receiveData.fourGStrenth = json.sta_4gSinal);
("sta_imei" in json) && (receiveData.imei = json.sta_imei);
("sta_longitude" in json) && (receiveData.Lon = json.sta_longitude);
("sta_latitude" in json) && (receiveData.Lat = json.sta_latitude);
if ("sta_system" in json) {
dic = {
"0": "关机",
"1": "仅充电",
"2": "开机未充电",
"3": "开机且充电"
}
receiveData.sta_system = dic[json.sta_system];
}
this.refreshFormData(receiveData, 'auto'); this.refreshFormData(receiveData, 'auto');
return receiveData; return receiveData;
}, },
@ -686,14 +800,14 @@
for (var i = 0; i < keys.length; i++) { for (var i = 0; i < keys.length; i++) {
let key = keys[i]; let key = keys[i];
if (key in these.formData) { if (key in these.formData) {
these.formData[key] = data[key]; this.formData[key] = data[key];
} }
} }
if (this.formData.imei) { if (this.formData.imei) {
this.initMQ(); this.initMQ();
} }
if (this.formData.staticWarn) { //有静止报警 if (this.formData.staticWarn) { //有静止报警
these.showPop({ this.showPop({
message: "设备静止报警中", message: "设备静止报警中",
iconUrl: "/static/images/6155/DeviceDetail/warnning.png", iconUrl: "/static/images/6155/DeviceDetail/warnning.png",
borderColor: "#e034344d", borderColor: "#e034344d",
@ -701,8 +815,6 @@
buttonText: "确定", buttonText: "确定",
clickEvt: "staticWarn" clickEvt: "staticWarn"
}); });
} }
this.setBleFormData(); this.setBleFormData();
@ -1576,8 +1688,8 @@
} }
console.log("baseURL=", baseURL); console.log("baseURL=", baseURL);
uni.uploadFile({ uni.uploadFile({
// url: 'http://114.55.111.217/video/upload', url: 'http://114.55.111.217/video/upload',
url: baseURL + "/app/video/upload", // url: baseURL + "/app/video/upload",
filePath: videoPath, filePath: videoPath,
name: 'file', name: 'file',
header: { header: {
@ -1617,7 +1729,7 @@
} else { } else {
console.log("服务器未返回正确的数据"); console.log("服务器未返回正确的数据", arr);
these.showPop({ these.showPop({
@ -1996,7 +2108,7 @@
text: "请稍候..." text: "请稍候..."
}); });
this.setBleFormData(); this.setBleFormData();
let data = { let data = {
"sendMsg": this.formData.msgTxt, "sendMsg": this.formData.msgTxt,
@ -2187,7 +2299,8 @@
.eqinfo .item { .eqinfo .item {
width: 100%; width: 100%;
height: 60rpx; min-height: 60rpx;
height: auto;
line-height: 60rpx; line-height: 60rpx;
padding: 0rpx 28rpx; padding: 0rpx 28rpx;
box-sizing: border-box; box-sizing: border-box;
@ -2204,7 +2317,7 @@
font-family: PingFang SC; font-family: PingFang SC;
font-size: 28rpx; font-size: 28rpx;
font-weight: 400; font-weight: 400;
width: 140rpx;
letter-spacing: 0.07px; letter-spacing: 0.07px;
text-align: left; text-align: left;
} }
@ -2219,6 +2332,26 @@
text-align: left; text-align: left;
} }
.eqinfo .multiValue {
display: flex;
flex-direction: column;
flex-wrap: wrap;
align-content: flex-end;
align-items: flex-end;
justify-content: flex-start;
width: calc(100% - 140rpx)
}
.eqinfo .valueItem {
height: auto;
line-height: 40rpx;
color: rgba(255, 255, 255, 0.6);
font-family: PingFang SC;
font-size: 14px;
font-weight: 400;
letter-spacing: 0.07px;
}
.lamp { .lamp {
margin-top: 24rpx; margin-top: 24rpx;
} }

View File

@ -158,7 +158,7 @@
var these = null; var these = null;
var BrighInteval = null; var BrighInteval = null;
var recei = null; var recei = null;
export default { export default {
components: { components: {
TextToHexV1 TextToHexV1
@ -317,7 +317,7 @@
let device = data.data; let device = data.data;
these.device = device; these.device = device;
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) { if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v); console.log("找到设备了", v);
@ -328,7 +328,7 @@
}); });
if (!f) { if (!f) {
these.getDetail();
these.showBleUnConnect(); these.showBleUnConnect();
return; return;
} }
@ -347,7 +347,7 @@
these.formData.deviceId = f.deviceId; these.formData.deviceId = f.deviceId;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId); ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId);
these.setBleFormData(); these.setBleFormData();
these.getDetail();
}); });
@ -385,15 +385,15 @@
} }
switch (this.formData.mode) { switch (this.formData.mode) {
case 0: case 0:
txt = "强光模式"; txt = "强光模式";
break; break;
case 1: case 1:
txt = "弱光模式"; txt = "弱光模式";
break; break;
case 2: case 2:
txt = "爆闪模式"; txt = "爆闪模式";
break; break;
@ -403,7 +403,7 @@
default: default:
txt = "关闭"; txt = "关闭";
break; break;
} }
return txt; return txt;
} }
@ -419,9 +419,9 @@
return f; return f;
}, },
bleValueNotify: function(receive, device, path) { bleValueNotify: function(receive, device, path) {
let str = recei.ReceiveData(receive, device, path); let str = recei.ReceiveData(receive, device, path);
console.log("处理接收到的数据:" + str); console.log("处理接收到的数据:" + str);
return; return;
let data = recei.ReceiveData(receive, device, path); let data = recei.ReceiveData(receive, device, path);
@ -529,29 +529,31 @@
} }
}); });
}, },
showBleUnConnect(){ showBleUnConnect() {
this.showPop({ this.showPop({
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备", message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
buttonText:'去连接', buttonText: '去连接',
okCallback:function(){ okCallback: function() {
console.log("1111"); console.log("1111");
uni.navigateTo({ uni.navigateTo({
url:"/pages/common/addBLE/addEquip", url: "/pages/common/addBLE/addEquip",
events: { events: {
BindOver: function(data) { BindOver: function(data) {
console.log(data) console.log(data)
} }
}, },
success: function(res) { success: function(res) {
// 通过eventChannel向被打开页面传送数据 // 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('detailData', { data: these.device }) res.eventChannel.emit('detailData', {
}, data: these.device
fail(ex){ })
console.log("跳转失败",ex); },
} fail(ex) {
console.log("跳转失败", ex);
}
}) })
} }
}); });
@ -642,8 +644,8 @@
these.showPop({ these.showPop({
message: "上传成功", message: "上传成功",
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png", iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
borderColor : '#BBE600', borderColor: '#BBE600',
buttonBgColor : '#BBE600' buttonBgColor: '#BBE600'
}); });
resolve(); resolve();
@ -889,9 +891,9 @@
case 1: case 1:
dataValue = 0x02; dataValue = 0x02;
break; break;
// case 2: // case 2:
// dataValue = 0x02; // dataValue = 0x02;
// break; // break;
case 2: case 2:
dataValue = 0x03; dataValue = 0x03;
break; break;
@ -974,7 +976,7 @@
if (this.Status.Pop.clickEvt == 'SendUsr') { if (this.Status.Pop.clickEvt == 'SendUsr') {
} }
if(this.Status.Pop.okCallback){ if (this.Status.Pop.okCallback) {
this.Status.Pop.okCallback(); this.Status.Pop.okCallback();
} }
this.Status.Pop.showPop = false; this.Status.Pop.showPop = false;
@ -992,11 +994,11 @@
okCallback: null, okCallback: null,
cancelCallback: null, cancelCallback: null,
popType: 'custom', popType: 'custom',
buttonText:'确定', buttonText: '确定',
clickEvt: '' clickEvt: ''
}; };
if (!option) { if (!option) {
} }
let keys = Object.keys(option); let keys = Object.keys(option);
for (var i = 0; i < keys.length; i++) { for (var i = 0; i < keys.length; i++) {
@ -1011,7 +1013,7 @@
} }
this.Status.Pop[key] = defaultCfg[key]; this.Status.Pop[key] = defaultCfg[key];
} }
this.Status.Pop.showPop = true; this.Status.Pop.showPop = true;
}, },
sendUsr() { sendUsr() {
@ -1171,18 +1173,18 @@
console.log("发送成功"); console.log("发送成功");
this.showPop({ this.showPop({
message: "发送成功", message: "发送成功",
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png", iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
borderColor : '#BBE600', borderColor: '#BBE600',
buttonBgColor : '#BBE600' buttonBgColor: '#BBE600'
}); });
let json = { let json = {
deviceId: these.device.id, deviceId: these.device.id,
name: these.formData.textLines[1], name: these.formData.textLines[1],
position: these.formData.textLines[0], position: these.formData.textLines[0],
unitName: these.formData.textLines[2], unitName: these.formData.textLines[2],
code: "" code: ""
}; };
@ -1199,7 +1201,22 @@
setTimeout(task, 0); setTimeout(task, 0);
}, },
getDetail() {
var that = this;
usrApi.getDetail(this.device.id).then(res => {
if (res && res.code == 200) {
res = res.data;
let personnelInfo = res.personnelInfo;
if (personnelInfo) {
these.formData.textLines[2] = personnelInfo.unitName;
these.formData.textLines[1] = personnelInfo.name;
these.formData.textLines[0] = personnelInfo.position;
}
}
});
},
ack: function() { ack: function() {

View File

@ -56,6 +56,7 @@
<view class="w50 fleft">静止报警状态:{{receiveData.staticWarn}}</view> <view class="w50 fleft">静止报警状态:{{receiveData.staticWarn}}</view>
<view class="w50 fleft">4G信号强度:{{receiveData.fourGStrenth}}</view> <view class="w50 fleft">4G信号强度:{{receiveData.fourGStrenth}}</view>
<view class="w50 fleft">SOS模式:{{receiveData.SOS}}</view> <view class="w50 fleft">SOS模式:{{receiveData.SOS}}</view>
<view class="w50 fleft">设备状态:{{receiveData.sta_system}}</view>
<view class="clear"></view> <view class="clear"></view>
</view> </view>
<view>重发包序号{{reSendNumber}}</view> <view>重发包序号{{reSendNumber}}</view>
@ -226,7 +227,7 @@
<script> <script>
import gbk from '@/utils/gbk.js'; import gbk from '@/utils/gbk.js';
import MqttClient from '@/utils/mqtt.js'; import MqttClient from '@/utils/mqtt.js';
import request,{ import request, {
baseURL baseURL
} from '@/utils/request.js'; } from '@/utils/request.js';
var videoChannel = null; var videoChannel = null;
@ -294,7 +295,8 @@
IMEI: "", IMEI: "",
Lon: "", Lon: "",
Lat: "", Lat: "",
SOS: "" SOS: "",
sta_system: ""
}, },
subscits: [], subscits: [],
videoPath: "", videoPath: "",
@ -354,7 +356,7 @@
parseDataMQ(json) { parseDataMQ(json) {
let staticLevelText = ""; let staticLevelText = "";
let dic = { let dic = {
"3": "高档", "3": "高档",
@ -363,14 +365,16 @@
"0": "关闭", "0": "关闭",
}; };
staticLevelText = dic[json.sta_DetectGrade]; if ("sta_DetectGrade" in json) {
staticLevelText = dic[json.sta_DetectGrade.toString()];
}
let lightingLevelText = "";
if ("sta_LightGrade" in json) {
lightingLevelText = json.sta_LightGrade === 1 ? '强光' : json.sta_LightGrade === 2 ? '弱光' : '关闭';
}
let lightingLevelText = json.sta_LightGrade ===
1 ? '强光' :
json.sta_LightGrade ===
2 ?
'弱光' :
'关闭';
let warn = ""; let warn = "";
dic = { dic = {
"0": "无预警", "0": "无预警",
@ -379,25 +383,47 @@
"3": "强预警", "3": "强预警",
"4": "非常强预警", "4": "非常强预警",
}; };
warn = dic[json.sta_DetectResult]; if ("sta_DetectResult" in json) {
warn = dic[json.sta_DetectResult.toString()];
}
let sosText = json.sta_SOSGrade === 2 ? '红蓝模式' :
json.sta_SOSGrade === 1 ? "爆闪模式" : "关闭"
let staticWarn = json.sta_ShakeBit === 1 ? '正在报警' : '未报警'; let sosText = "";
if ("sta_SOSGrade" in json) {
sosText=json.sta_SOSGrade === 2 ? '红蓝模式' : json.sta_SOSGrade === 1 ? "爆闪模式" : "关闭"
}
let staticWarn = "";
if ("sta_ShakeBit" in json) {
json.sta_ShakeBit === 1 ? '正在报警' : '未报警';
}
if ("sta_system" in json) {
dic = {
"0": "关机",
"1": "仅充电",
"2": "开机未充电",
"3": "开机且充电"
}
this.receiveData.sta_system = dic[json.sta_system.toString()];
}
this.receiveData.staticLevel = staticLevelText; this.receiveData.staticLevel = staticLevelText;
this.receiveData.lightingLevel = lightingLevelText; this.receiveData.lightingLevel = lightingLevelText;
this.receiveData.lightingTime = json.sta_PowerTime + "分钟"; ("sta_PowerTime" in json) && (this.receiveData.lightingTime = json.sta_PowerTime + "分钟");
this.receiveData.batteryLevel = json.sta_PowerPercent + "%"; ("sta_PowerPercent" in json) && (this.receiveData.batteryLevel = json.sta_PowerPercent + "%");
this.receiveData.SOS = sosText; this.receiveData.SOS = sosText;
this.receiveData.warnLevel = warn; this.receiveData.warnLevel = warn;
this.receiveData.staticWarn = staticWarn; this.receiveData.staticWarn = staticWarn;
this.receiveData.fourGStrenth = json.sta_4gSinal; ("sta_4gSinal" in json) && (this.receiveData.fourGStrenth = json.sta_4gSinal);
this.receiveData.IMEI = json.sta_imei; ("sta_imei" in json ) && (this.receiveData.IMEI = json.sta_imei);
this.receiveData.Lon = json.sta_longitude; ("sta_longitude" in json) && (this.receiveData.Lon = json.sta_longitude);
this.receiveData.Lat = json.sta_latitude; ("sta_latitude" in json) && (this.receiveData.Lat = json.sta_latitude);
}, },
parseData(receive) { parseData(receive) {
@ -1285,6 +1311,7 @@
setTimeout(() => { setTimeout(() => {
uni.onBLECharacteristicValueChange(( uni.onBLECharacteristicValueChange((
receive) => { receive) => {
console.log("收到设备数据",receive);
these.parseData(receive); these.parseData(receive);
}); });
}, 100) }, 100)
@ -2101,7 +2128,7 @@
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_system') > -1) { //上报的报文
console.log("收到设备上报的数据", payload); console.log("收到设备上报的数据", payload);
this.parseDataMQ(json); this.parseDataMQ(json);
} else if (keys.indexOf('sta_PicTrans') > -1) { //发送开机画面 } else if (keys.indexOf('sta_PicTrans') > -1) { //发送开机画面

View File

@ -30,7 +30,7 @@
<script> <script>
import Common from '@/utils/Common'; import Common from '@/utils/Common';
import request,{ baseURL } from '@/utils/request.js';
export default { export default {
data() { data() {
return { return {
@ -123,15 +123,19 @@
let p2 = new Promise((resolve, reject) => { let p2 = new Promise((resolve, reject) => {
let start = new Date(); let start = new Date();
console.log("Common.baseURL=" + Common.baseURL); console.log("baseURL=" + baseURL);
const token ="";// uni.getStorageSync('token');
const clientid ="";// uni.getStorageSync('clientID');
uni.uploadFile({ uni.uploadFile({
// url: Common.baseURL + 'video/upload', url: 'http://114.55.111.217/video/upload',
url:'http://192.168.110.56:8000/app/video/upload', // url:baseURL+"/app/video/upload",
filePath: this.videoPath, filePath: this.videoPath,
name: 'file', name: 'file',
header: { header: {
"Method": "POST", "Method": "POST",
"Content-Type": "multipart/form-data" "Content-Type": "multipart/form-data",
"Authorization": 'Bearer ' + token,
"clientid": clientid
}, },
timeout: 600000, timeout: 600000,
fail: (ex) => { fail: (ex) => {

View File

@ -31,6 +31,7 @@
<script> <script>
import Common from '../../../utils/Common'; import Common from '../../../utils/Common';
import { baseURL } from '../../../utils/request';
var mqttClient=null; var mqttClient=null;
export default { export default {
data() { data() {
@ -127,14 +128,19 @@ var mqttClient=null;
let p2=new Promise((resolve,reject)=>{ let p2=new Promise((resolve,reject)=>{
let start = new Date(); let start = new Date();
console.log("Common.baseURL="+Common.baseURL); console.log("baseURL="+baseURL);
const token ="";// uni.getStorageSync('token');
const clientid ="";// uni.getStorageSync('clientID');
uni.uploadFile({ uni.uploadFile({
url:Common.baseURL+'video/upload', url: 'http://114.55.111.217/video/upload',
// url:baseURL+"/app/video/upload",
filePath: this.videoPath, filePath: this.videoPath,
name: 'file', name: 'file',
header: { header: {
"Method": "POST", "Method": "POST",
"Content-Type": "multipart/form-data" "Content-Type": "multipart/form-data",
"Authorization": 'Bearer ' + token,
"clientid": clientid
}, },
timeout: 600000, timeout: 600000,
fail: (ex) => { fail: (ex) => {

View File

@ -415,6 +415,9 @@ class BleHelper {
uni.onBluetoothAdapterStateChange((state) => { uni.onBluetoothAdapterStateChange((state) => {
console.log('蓝牙状态发生变化:' + JSON.stringify(state)); console.log('蓝牙状态发生变化:' + JSON.stringify(state));
if(this.data.available==state.available){
return;
}
this.data.available = state.available; this.data.available = state.available;
this.data.discovering = state.discovering; this.data.discovering = state.discovering;
if (this.data.available && this.data if (this.data.available && this.data
@ -1095,7 +1098,7 @@ class BleHelper {
}, },
fail: (ex) => { fail: (ex) => {
ex = this.getError(ex); ex = this.getError(ex);
console.log("蓝牙连接失败" + JSON.stringify(ex)); console.log("蓝牙"+deviceId+"连接失败" + JSON.stringify(ex));
// 连接超时后自动重试 // 连接超时后自动重试
if (ex.code === 10012 && retryCount < maxRetries) { if (ex.code === 10012 && retryCount < maxRetries) {

View File

@ -15,90 +15,92 @@ function checkAndUpdateWgt(updateUrl) {
plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => { plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
const currentVersion = widgetInfo.version; const currentVersion = widgetInfo.version;
console.log("当前版本:" + currentVersion); console.log("当前版本:" + currentVersion);
request({ // request({
url:'/app/auth/version', // url:'/app/auth/version',
method: 'get' // method: 'get'
}).then(res=>{ // }).then(res=>{
console.log("检查版本更新:",res); // console.log("检查版本更新:",res);
let os=plus.os.name.toLowerCase(); // let os=plus.os.name.toLowerCase();
if(res.code!=200){ // if(res.code!=200){
return; // return;
}
let f=res.data.find(v=>{
if(v.dictLabel.toLowerCase()==os){
return true;
}
return false;
});
if(f){
if(f.dictValue==currentVersion){
return;
}
uni.showModal({
title: '检测到更新',
content: '当前版本“'+currentVersion+'”,发现新版本“'+f.dictValue+'”,是否立即更新?',
confirmText: '立即更新',
cancelText: '稍后更新',
success: (modalRes) => {
if (modalRes.confirm) {
downloadAndInstallWgt(f.remark);
}
}
});
}
}).catch(ex=>{
console.log("检查更新失败:",ex);
});
// 2. 调用后端接口检查是否有更新
// uni.request({
// url: updateUrl,
// method: 'GET',
// data: {
// currentVersion: currentVersion,
// platform: uni.getSystemInfoSync().platform
// },
// success: (res) => {
// uni.hideLoading();
// console.log("res=", res)
// if (res.statusCode === 200) {
// const updateInfo = res.data.data;
// if (!updateInfo.hasUpdate) {
// return;
// }
// // 3. 显示更新提示
// uni.showModal({
// title: '检测到更新',
// content: updateInfo.description || '有新版本可用,是否立即更新?',
// confirmText: '立即更新',
// cancelText: '稍后更新',
// success: (modalRes) => {
// if (modalRes.confirm) {
// downloadAndInstallWgt(updateInfo.downloadUrl);
// }
// }
// });
// } else {
// uni.showToast({
// title: '当前已是最新版本',
// icon: 'none',
// duration: 2000
// });
// }
// },
// fail: (err) => {
// uni.hideLoading();
// uni.showToast({
// title: '检查更新失败',
// icon: 'none',
// duration: 2000
// });
// console.error('检查更新失败:', err);
// } // }
// let f=res.data.find(v=>{
// if(v.dictLabel.toLowerCase()==os){
// return true;
// }
// return false;
// });
// if(f){
// if(f.dictValue==currentVersion){
// return;
// }
// uni.showModal({
// title: '检测到更新',
// content: '当前版本“'+currentVersion+'”,发现新版本“'+f.dictValue+'”,是否立即更新?',
// confirmText: '立即更新',
// cancelText: '稍后更新',
// success: (modalRes) => {
// if (modalRes.confirm) {
// downloadAndInstallWgt(f.remark);
// }
// }
// });
// }
// }).catch(ex=>{
// console.log("检查更新失败:",ex);
// }); // });
// 2. 调用后端接口检查是否有更新
uni.request({
url: updateUrl,
method: 'GET',
data: {
currentVersion: currentVersion,
platform: uni.getSystemInfoSync().platform
},
success: (res) => {
uni.hideLoading();
console.log("检查更新成功=", res)
if (res.statusCode === 200) {
const updateInfo = res.data.data;
if (!updateInfo.hasUpdate) {
return;
}
// 3. 显示更新提示
uni.showModal({
title: '检测到更新',
content: updateInfo.description || '有新版本可用,是否立即更新?',
confirmText: '立即更新',
cancelText: '稍后更新',
success: (modalRes) => {
if (modalRes.confirm) {
downloadAndInstallWgt(updateInfo.downloadUrl);
}
}
});
} else {
uni.showToast({
title: '当前已是最新版本',
icon: 'none',
duration: 2000
});
}
},
fail: (err) => {
uni.hideLoading();
uni.showToast({
title: '检查更新失败',
icon: 'none',
duration: 2000
});
console.error('检查更新失败:', err);
}
});
}); });
} }