100J相关bug修改
This commit is contained in:
@ -22,7 +22,9 @@
|
|||||||
<view class="row">
|
<view class="row">
|
||||||
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
||||||
<view class="txt">
|
<view class="txt">
|
||||||
<view class="bigTxt"> {{ Math.floor((Number(deviceInfo.batteryRemainingTime)||0)/60) }}小时 {{ (Number(deviceInfo.batteryRemainingTime)||0)%60 }}分钟
|
<view class="bigTxt">
|
||||||
|
{{ Math.floor((Number(deviceInfo.batteryRemainingTime) || 0) / 60) }}小时
|
||||||
|
{{ (Number(deviceInfo.batteryRemainingTime) || 0) % 60 }}分钟
|
||||||
</view>
|
</view>
|
||||||
<view class="smallTxt">续航时间</view>
|
<view class="smallTxt">续航时间</view>
|
||||||
</view>
|
</view>
|
||||||
@ -43,21 +45,21 @@
|
|||||||
<text class="value">{{ deviceInfo.onlineStatus === 0 ? '离线' : deviceInfo.onlineStatus
|
<text class="value">{{ deviceInfo.onlineStatus === 0 ? '离线' : deviceInfo.onlineStatus
|
||||||
=== 2 ? '故障' : '在线' }}</text>
|
=== 2 ? '故障' : '在线' }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="info-row">
|
<view class="info-row">
|
||||||
<text class="info-label" style="display: flex; align-items: center;">定位信息</text>
|
<text class="info-label" style="display: flex; align-items: center;">定位信息</text>
|
||||||
<view class="info-value status-running" @click="gpsPosition(deviceInfo)">
|
<view class="info-value status-running" @click="gpsPosition(deviceInfo)">
|
||||||
<view class="info-value status-running">
|
<view class="info-value status-running">
|
||||||
{{ deviceInfo && deviceInfo.longitude ? Number(deviceInfo.longitude).toFixed(4) : '' }}
|
{{ deviceInfo && deviceInfo.longitude ? Number(deviceInfo.longitude).toFixed(4) : '' }}
|
||||||
{{ deviceInfo && deviceInfo.latitude ? Number(deviceInfo.latitude).toFixed(4) : '' }}
|
{{ deviceInfo && deviceInfo.latitude ? Number(deviceInfo.latitude).toFixed(4) : '' }}
|
||||||
</view>
|
</view>
|
||||||
<view class="info-value status-running locationGPS">
|
<view class="info-value status-running locationGPS">
|
||||||
<uni-icons type="location" size="17"
|
<uni-icons type="location" size="17" color="rgba(255, 255, 255, 0.8)"
|
||||||
color="rgba(255, 255, 255, 0.8)" style="vertical-align: bottom;" />
|
style="vertical-align: bottom;" />
|
||||||
{{ deviceInfo.address }}
|
{{ deviceInfo.address }}
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
|
||||||
<view class="lampMode">
|
<view class="lampMode">
|
||||||
<view class="sosContent">
|
<view class="sosContent">
|
||||||
<view class="btnSos openSos center" :class="{ active: formData.sta_SOSType === 1 }"
|
<view class="btnSos openSos center" :class="{ active: formData.sta_SOSType === 1 }"
|
||||||
@ -464,19 +466,83 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
this.mqttClient = new MqttClient();
|
this.mqttClient = new MqttClient();
|
||||||
// this.mqttClient.connect(() => {
|
|
||||||
// // 订阅来自设备的状态更新
|
|
||||||
// const statusTopic = `status/894078/HBY100/${data.data.deviceImei}`;
|
|
||||||
// this.mqttClient.subscribe(statusTopic, (payload) => {
|
|
||||||
// try {
|
|
||||||
// // 解析MQTT返回的payload
|
|
||||||
// const payloadObj = typeof payload === 'string' ? JSON.parse(
|
|
||||||
// payload) : payload;
|
|
||||||
// } catch (e) {
|
|
||||||
|
|
||||||
// }
|
this.mqttClient.connect(() => {
|
||||||
// })
|
// 订阅来自设备的状态更新
|
||||||
// })
|
const statusTopic = `status/894078/HBY100/${data.data.deviceImei}`;
|
||||||
|
this.mqttClient.subscribe(statusTopic, (payload) => {
|
||||||
|
try {
|
||||||
|
// 解析MQTT返回的payload
|
||||||
|
const payloadObj = typeof payload === 'string' ? JSON.parse(
|
||||||
|
payload) : payload;
|
||||||
|
console.log(payloadObj, '这是我的数据类型么');
|
||||||
|
const data = payloadObj.data ?? {};
|
||||||
|
const funcType = payloadObj.funcType ?? ''; // 从顶层获取funcType
|
||||||
|
const {
|
||||||
|
siren_alarm = {
|
||||||
|
enable: 0,
|
||||||
|
mode: 0
|
||||||
|
},
|
||||||
|
led_strobe = {
|
||||||
|
enable: 0,
|
||||||
|
mode: 0,
|
||||||
|
frequency: 0
|
||||||
|
},
|
||||||
|
volume = 0,
|
||||||
|
brightness = {
|
||||||
|
red: 0,
|
||||||
|
green: 0,
|
||||||
|
blue: 0
|
||||||
|
},
|
||||||
|
|
||||||
|
} = data;
|
||||||
|
// 3. 赋值对应的字段
|
||||||
|
|
||||||
|
// 续航时间相关
|
||||||
|
if (funcType == '4') {
|
||||||
|
these.deviceInfo.batteryPercentage = data.level //电量
|
||||||
|
these.deviceInfo.batteryRemainingTime = data
|
||||||
|
.battery_remaining_time //续航时间
|
||||||
|
} else if (funcType == '14') {
|
||||||
|
// 调节相关字段
|
||||||
|
these.formData.strobeFrequency = led_strobe.frequency ||
|
||||||
|
0.5; //频率
|
||||||
|
these.formData.volume = volume || 10; //音量
|
||||||
|
these.formData.lightBrightness = brightness.red ||
|
||||||
|
10; //亮度值,不管红色,蓝色,黄色
|
||||||
|
}
|
||||||
|
// 报警模式相关字段赋值
|
||||||
|
// 是语音根据这个字段做判断
|
||||||
|
if (funcType === '6') {
|
||||||
|
// 语音频闪报警:0=关闭,1=开启
|
||||||
|
const voiceStrobeAlarm = data.voice_strobe_alarm ?? 0;
|
||||||
|
these.formData.sta_VoiceType = voiceStrobeAlarm === 1 ? '1' :
|
||||||
|
'-1';
|
||||||
|
} else if (funcType === '12') {
|
||||||
|
// 报警模式:直接用alarmMode作为sta_VoiceType
|
||||||
|
const alarmMode = data.mode ?? 0;
|
||||||
|
these.formData.sta_VoiceType = alarmMode + ''; // 转字符串匹配key
|
||||||
|
}
|
||||||
|
// 警示灯模式选中切换
|
||||||
|
if (funcType === '10') {
|
||||||
|
const enable = data.enable ?? 0; // 开关:1=开,0=关
|
||||||
|
const mode = data.mode ?? 0; // 模式:0/1/2/3/4/5/6
|
||||||
|
if (enable === 1) {
|
||||||
|
// 开启状
|
||||||
|
these.formData.sta_LightType = mode + '';
|
||||||
|
} else {
|
||||||
|
// 关闭状态:赋值-1,表示关闭
|
||||||
|
these.formData.sta_LightType = '-1';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 报警模式相关字段
|
||||||
|
console.log('formData赋值完成:', these.formData);
|
||||||
|
} catch (e) {
|
||||||
|
// 捕获异常并打印,方便排查问题(不要空catch)
|
||||||
|
console.log('解析MQTT payload失败:', e);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
console.log(data, 'datatatatat');
|
console.log(data, 'datatatatat');
|
||||||
these.fetchDeviceDetail(data.data.id)
|
these.fetchDeviceDetail(data.data.id)
|
||||||
});
|
});
|
||||||
@ -502,6 +568,7 @@
|
|||||||
},
|
},
|
||||||
// 获取设备详情(普通详情)
|
// 获取设备详情(普通详情)
|
||||||
fetchDeviceDetail(id) {
|
fetchDeviceDetail(id) {
|
||||||
|
let that = this
|
||||||
deviceDetail(id).then((res) => {
|
deviceDetail(id).then((res) => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
const validData = Object.fromEntries(
|
const validData = Object.fromEntries(
|
||||||
@ -511,13 +578,17 @@
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
Object.assign(this.formData, validData);
|
Object.assign(this.formData, validData);
|
||||||
this.deviceInfo = res.data;
|
that.deviceInfo = res.data;
|
||||||
// 0 红色爆闪,1 蓝色爆闪,2 黄色爆闪,3,红色顺时针旋转爆闪,4黄色顺时针旋转爆闪,5,红蓝顺时针旋转爆闪,6 红蓝交替爆闪
|
const strobeEnable = res.data.strobeEnable ?? 0; // 0=关闭,1=开启
|
||||||
this.formData.sta_LightType = (res.data.strobeMode ?? 0) + ''
|
const strobeMode = res.data.strobeMode ?? 0; // 0=红闪、1=蓝闪、3=红色顺时针...
|
||||||
// 0爆闪关闭, 1爆闪开启
|
if (strobeEnable === 1) {
|
||||||
const strobeEnable = res.data.strobeEnable ?? 0;
|
// 开启状态
|
||||||
this.formData.sta_LightType = strobeEnable === 1 ? 1 : -1;
|
that.formData.sta_LightType = strobeMode + '';
|
||||||
if (res.data.alarmMode == 7) {
|
} else {
|
||||||
|
// 关闭状态
|
||||||
|
that.formData.sta_LightType = '-1';
|
||||||
|
}
|
||||||
|
if (this.formData_VoiceType == 7) {
|
||||||
this.formData.sta_VoiceType = res.data.voiceStrobeAlarm ?? 0;
|
this.formData.sta_VoiceType = res.data.voiceStrobeAlarm ?? 0;
|
||||||
} else {
|
} else {
|
||||||
this.formData.sta_VoiceType = res.data.alarmMode + ''
|
this.formData.sta_VoiceType = res.data.alarmMode + ''
|
||||||
@ -687,6 +758,8 @@
|
|||||||
},
|
},
|
||||||
// 警示灯开关闭
|
// 警示灯开关闭
|
||||||
lightTypeSet(item, index) {
|
lightTypeSet(item, index) {
|
||||||
|
console.log('走了么');
|
||||||
|
|
||||||
let val = item.key;
|
let val = item.key;
|
||||||
// 切换选中/取消选中逻辑
|
// 切换选中/取消选中逻辑
|
||||||
if (this.formData.sta_LightType === val) {
|
if (this.formData.sta_LightType === val) {
|
||||||
@ -1749,6 +1822,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.info-row {
|
.info-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|||||||
@ -469,12 +469,11 @@
|
|||||||
},
|
},
|
||||||
Apply(item, index) {
|
Apply(item, index) {
|
||||||
this.mqttClient = new MqttClient();
|
this.mqttClient = new MqttClient();
|
||||||
this.updateProgress = 0;
|
|
||||||
this.isUpdating = true;
|
|
||||||
let data = {
|
let data = {
|
||||||
id: item.id
|
id: item.id
|
||||||
}
|
}
|
||||||
deviceUpdateVoice(data).then((RES) => {
|
deviceUpdateVoice(data).then((RES) => {
|
||||||
|
console.log(RES,'RES');
|
||||||
if (RES.code == 200) {
|
if (RES.code == 200) {
|
||||||
this.updateProgress = 0;
|
this.updateProgress = 0;
|
||||||
this.isUpdating = true;
|
this.isUpdating = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user