1
0
forked from dyf/APP

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

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

View File

@ -30,7 +30,7 @@
<script>
import Common from '@/utils/Common';
import request,{ baseURL } from '@/utils/request.js';
export default {
data() {
return {
@ -123,15 +123,19 @@
let p2 = new Promise((resolve, reject) => {
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({
// url: Common.baseURL + 'video/upload',
url:'http://192.168.110.56:8000/app/video/upload',
url: 'http://114.55.111.217/video/upload',
// url:baseURL+"/app/video/upload",
filePath: this.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) => {

View File

@ -31,6 +31,7 @@
<script>
import Common from '../../../utils/Common';
import { baseURL } from '../../../utils/request';
var mqttClient=null;
export default {
data() {
@ -127,14 +128,19 @@ var mqttClient=null;
let p2=new Promise((resolve,reject)=>{
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({
url:Common.baseURL+'video/upload',
url: 'http://114.55.111.217/video/upload',
// url:baseURL+"/app/video/upload",
filePath: this.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) => {