1
0
forked from dyf/APP

Merge branch 'new-20250827' of http://47.107.152.87:3000/liubiao/APP into new-20250827

This commit is contained in:
liub
2026-03-05 10:08:08 +08:00
5 changed files with 222 additions and 87 deletions

View File

@ -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,24 +45,24 @@
<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 class="info-value status-running locationGPS">
<uni-icons type="location" size="17" color="rgba(255, 255, 255, 0.8)"
style="vertical-align: bottom;" />
{{ deviceInfo.address }}
</view>
</view> </view>
<view class="info-value status-running locationGPS"> </view>
<uni-icons type="location" size="17"
color="rgba(255, 255, 255, 0.8)" style="vertical-align: bottom;" />
{{ deviceInfo.address }}
</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: deviceInfo.voiceStrobeAlarm === 1 }"
@click="sosSetting(1)"> @click="sosSetting(1)">
{{ deviceInfo.voiceStrobeAlarm === 1 ? '报警中' : '强制报警' }} {{ deviceInfo.voiceStrobeAlarm === 1 ? '报警中' : '强制报警' }}
</view> </view>
@ -161,7 +163,7 @@
<text class="sliderVal">{{ formData.strobeFrequency }}HZ</text> <text class="sliderVal">{{ formData.strobeFrequency }}HZ</text>
</view> </view>
<view class="slider-container"> <view class="slider-container">
<slider min="0.5" max="10" step="0.5" :disabled="false" :value="formData.strobeFrequency" <slider min="1" max="10" step="1" :disabled="false" :value="formData.strobeFrequency"
activeColor="#bbe600" backgroundColor="#686767" block-size="20" block-color="#ffffffde" activeColor="#bbe600" backgroundColor="#686767" block-size="20" block-color="#ffffffde"
@change="onFreqChanging" @changing="onFreqChanging" class="custom-slider" /> @change="onFreqChanging" @changing="onFreqChanging" class="custom-slider" />
</view> </view>
@ -236,6 +238,7 @@
data() { data() {
return { return {
mqttClient: null, mqttClient: null,
activePermissions: [], // 存储当前设备的权限数组
Status: { Status: {
isRightIconVisible: false, isRightIconVisible: false,
navTitle: '', navTitle: '',
@ -244,6 +247,7 @@
curr: 0, curr: 0,
total: 0, total: 0,
pageHide: false, pageHide: false,
Pop: { Pop: {
showPop: false, //是否显示弹窗 showPop: false, //是否显示弹窗
popType: 'custom', popType: 'custom',
@ -312,7 +316,6 @@
lightBrightness: 10, lightBrightness: 10,
sta_system: '', sta_system: '',
warnTime: 0, warnTime: 0,
sta_SOSType: 0
}, },
dic: { dic: {
sta_VoiceType: { sta_VoiceType: {
@ -453,32 +456,138 @@
these.Status.apiType = data.apiType; these.Status.apiType = data.apiType;
these.Status.isRightIconVisible = these.Status.apiType === 'listA'; these.Status.isRightIconVisible = these.Status.apiType === 'listA';
if (data.apiType !== 'listA') {
Common.getdeviceShareId(data.data.id).then(res => {
if (res.code == 200) {
if (res.data.permission) {
these.permissions = res.data.permission.split(',');
}
}
});
}
this.mqttClient = new MqttClient(); this.mqttClient = new MqttClient();
// this.mqttClient.connect(() => {
// // 订阅来自设备的状态更新 this.mqttClient.connect(() => {
// const statusTopic = `status/894078/HBY100/${data.data.deviceImei}`; // 订阅来自设备的状态更新
// this.mqttClient.subscribe(statusTopic, (payload) => { const statusTopic = `status/894078/HBY100/${data.data.deviceImei}`;
// try { this.mqttClient.subscribe(statusTopic, (payload) => {
// // 解析MQTT返回的payload try {
// const payloadObj = typeof payload === 'string' ? JSON.parse( // 解析MQTT返回的payload
// payload) : payload; const payloadObj = typeof payload === 'string' ? JSON.parse(
// } catch (e) { 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 //续航时间
// 设备按键, app同步
} else if (funcType == '14') {
// 调节亮度,音量,频率相关字段
these.formData.strobeFrequency = led_strobe.frequency ||
0.5; //频率
these.formData.volume = volume || 10; //音量
these.formData.lightBrightness = brightness.red ||
10; //亮度值
// 警示灯
const enable1 = led_strobe.enable ?? 0; // 开关1=开0=关
const mode1 = led_strobe.mode ?? 0; // 模式0/1/2/3/4/5/6
if (enable1 === 1) {
// 开启状
these.formData.sta_LightType = mode1 + '';
} else {
// 关闭状态:赋值-1表示关闭
these.formData.sta_LightType = '-1';
}
// 报警模式,选中,首次上报值,或者切换设备按键上报值
const enable = siren_alarm.enable ?? 0; // 报警开关1=开0=关
const mode = siren_alarm.mode ?? 0; // 模式0/1/2/3/4/5/6
if (these.formData.sta_VoiceType != 7) {
if (enable === 1) {
// 开启状态
these.formData.sta_VoiceType = mode + '';
} else {
// 关闭状态:赋值-1表示关闭
these.formData.sta_VoiceType = mode + '';
}
} else {
// 播放语音,上报消息
const voiceStrobeAlarm = data.voice_broadcast ?? 0;
if (voiceStrobeAlarm === 1) {
these.formData.sta_VoiceType = '7'
} else {
these.formData.sta_VoiceType = '-1'
}
}
}
// 报警模式相关字段赋值,是语音播放根据这个字段
if (funcType === '6') {
console.log('我是谁', data.voice_broadcast);
// 语音频闪报警0=关闭1=开启 ui7是播放的状态
const voiceStrobeAlarm = data.voice_broadcast ?? 0;
if (voiceStrobeAlarm === 1) {
these.formData.sta_VoiceType = '7'
} else {
these.formData.sta_VoiceType = '-1'
}
// 强制报警按键解除报警状态,app同步
} else if (funcType === '12') {
const enable_alarm = data.voice_strobe_alarm ??
0; // 报警开关1=开0=关
const mode_alarm = data.mode ?? 0; // 模式0/1/2/3/4/5/6
if (enable_alarm === 1) {
// 开启状
these.deviceInfo.voiceStrobeAlarm = 1;
these.formData.sta_VoiceType = mode_alarm + ''
} else {
// 关闭状态:赋值-1表示关闭
these.deviceInfo.voiceStrobeAlarm = -1;
// 模式还是选中的,模式,解除也是
these.formData.sta_VoiceType = mode_alarm + ''
}
}
// 警示灯模式选中切换
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) // 分享接口
if (these.Status.apiType === 'listA') {
these.fetchDeviceDetail(data.data.id)
} else {
this.activePermissions = data.data.permission ? data.data.permission.split(',') : [];
console.log(this.activePermissions,'this.activePermissions');
these.fetchDeviceDetail(data.data.deviceId)
}
}); });
this.createThrottledFunctions(); this.createThrottledFunctions();
@ -502,6 +611,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 +621,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 + ''
@ -525,6 +639,14 @@
} }
}) })
}, },
// 检查权限的方法
hasPermission(permissionCode) {
// 如果还在加载中直接返回false
if (this.pageLoading) return false
// 如果不是分享设备,默认有全部权限
if (!this.isSharedDevice) return true
return this.activePermissions.includes(permissionCode)
},
handleRightClick(item, s) { handleRightClick(item, s) {
if (item && item.callback) { if (item && item.callback) {
item.callback(item, s); item.callback(item, s);
@ -553,7 +675,6 @@
}, },
// 语音管理 // 语音管理
audioManager(item) { audioManager(item) {
this.formData.sta_VoiceType = -1
if (this.Status.apiType !== 'listA') {} if (this.Status.apiType !== 'listA') {}
uni.navigateTo({ uni.navigateTo({
url: '/pages/100J/audioManager/AudioList', url: '/pages/100J/audioManager/AudioList',
@ -687,6 +808,7 @@
}, },
// 警示灯开关闭 // 警示灯开关闭
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) {
@ -731,9 +853,32 @@
val = '-1'; val = '-1';
} }
this.formData.sta_VoiceType = val; this.formData.sta_VoiceType = val;
console.log(this.formData.sta_VoiceType, 'this.formData.sta_VoiceType')
// 模式类型为7时才去判断 // 模式类型为7时才去判断
if (val === '7' || val === '-1') { console.log(val, 'valllll');
const isVoiceOperate = val === '7' || val === '-1'; // 标记是否是语音开启/关闭操作
if (this.deviceInfo.voiceStrobeAlarm == 1) {
// 如果强制报警已经开启了,那么切换下面的模式需要时,需要触发报警指令
const data = {
deviceIds: [this.deviceInfo.deviceId],
// 声光报警开关开启传1
voiceStrobeAlarm: 1,
mode: this.formData.sta_VoiceType
};
deviceForceAlarmActivation(data).then((res) => {
if (res.code === 200) {
uni.showToast({
title: '强制报警已开启',
icon: 'none'
});
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
}
})
} else if (isVoiceOperate) {
console.log('我是谁');
let data = { let data = {
deviceId: this.deviceInfo.deviceId, deviceId: this.deviceInfo.deviceId,
voiceBroadcast: Number(this.formData.sta_VoiceType) === -1 ? 0 : 1 voiceBroadcast: Number(this.formData.sta_VoiceType) === -1 ? 0 : 1
@ -752,7 +897,6 @@
} }
}) })
} }
}, },
// 报警模式 // 报警模式
sosSetting(item) { sosSetting(item) {
@ -775,8 +919,7 @@
showCancel: true, showCancel: true,
buttonCancelText: '取消', buttonCancelText: '取消',
okCallback: () => { okCallback: () => {
console.log(this.formData.sta_SOSType, 'this.formData.sta_SOSType'); this.deviceInfo.voiceStrobeAlarm = isClose ? 0 : 1; //强制报警,报警中 0是强制报警,1是报警中
this.formData.sta_SOSType = isClose ? 0 : 1;
const data = { const data = {
deviceIds: [this.deviceInfo.deviceId], deviceIds: [this.deviceInfo.deviceId],
// 声光报警开关关闭传0开启传1 // 声光报警开关关闭传0开启传1
@ -789,18 +932,16 @@
title: isClose ? '声光报警已解除' : '强制报警已开启', title: isClose ? '声光报警已解除' : '强制报警已开启',
icon: 'none' icon: 'none'
}); });
if (isClose && this.formData.sta_VoiceType === '7') {
this.formData.sta_VoiceType = '-1';
}
} else { } else {
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,
icon: 'none' icon: 'none'
}); });
} }
}).catch((err) => { }).catch((err) => {});
uni.showToast({
title: '请求失败,请重试',
icon: 'none'
});
});
} }
}; };
}, },
@ -814,7 +955,7 @@
if (receive.deviceId !== this.formData.deviceId) { if (receive.deviceId !== this.formData.deviceId) {
return; return;
} }
if (this.formData.sta_battery <= 20) { if (this.deviceInfo.batteryPercentage <= 20) {
this.showMsg("设备电量低"); this.showMsg("设备电量低");
} }
}, },
@ -1307,8 +1448,6 @@
.proinfo .item .img { .proinfo .item .img {
width: 50rpx; width: 50rpx;
height: 50rpx; height: 50rpx;
} }
.proinfo .item .txt { .proinfo .item .txt {
@ -1321,14 +1460,10 @@
text-align: left; text-align: left;
} }
.slider-container { .slider-container {
padding: 0px; padding: 0px;
} }
.addIco { .addIco {
width: 100%; width: 100%;
height: 360rpx; height: 360rpx;
@ -1749,27 +1884,28 @@
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;
} }
.info-label { .info-label {
font-size: 28rpx; font-size: 28rpx;
color: rgba(255, 255, 255, 0.87); color: rgba(255, 255, 255, 0.87);
white-space: nowrap; white-space: nowrap;
} }
.info-value { .info-value {
font-size: 28rpx; font-size: 28rpx;
color: rgba(255, 255, 255, 0.6); color: rgba(255, 255, 255, 0.6);
} }
.status-running { .status-running {
/* color: rgba(255, 255, 255, 0.6); */ /* color: rgba(255, 255, 255, 0.6); */
text-align: end; text-align: end;
} }
.locationGPS { .locationGPS {
width: 88%; width: 88%;
text-align: end; text-align: end;

View File

@ -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;

View File

@ -40,15 +40,15 @@
<view class="device-name"> <view class="device-name">
<view>设备:{{item.deviceName}}</view> <view>设备:{{item.deviceName}}</view>
<view class="ID"> <view class="ID">
<view class="ID" v-if="item.communicationMode==0">ID:{{item.deviceImei}} <view class="ID" v-if="item.communicationMode==0 || item.communicationMode==2">ID:{{item.deviceImei}}
</view> </view>
<view class="ID" v-else>ID:{{item.deviceMac}}</view> <view class="ID" v-else>ID:{{item.deviceMac}}</view>
<!-- 在线状态 --> <!-- 在线状态 -->
<view class="onlines" <view class="onlines"
v-if="item.communicationMode==0 && item.onlineStatus==1">在线</view> v-if="item.onlineStatus==1">在线</view>
<!-- 离线状态 --> <!-- 离线状态 -->
<view class="offlines" <view class="offlines"
v-if="item.communicationMode==0 && item.onlineStatus==0">离线</view> v-if="item.onlineStatus==0">离线</view>
<view>电量{{item.battery || '0'}}%</view> <view>电量{{item.battery || '0'}}%</view>
</view> </view>
</view> </view>
@ -386,7 +386,7 @@ import BleReceive from '@/utils/BleReceive';
if (res.code == 200) { if (res.code == 200) {
//console.log("deviceTypeList=" + JSON.stringify(res.data)); //console.log("deviceTypeList=" + JSON.stringify(res.data));
this.tabs = [{ this.tabs = [{
id: '', id: '',
name: '全部设备', name: '全部设备',
typeName: '全部设备' typeName: '全部设备'
}, },
@ -405,9 +405,6 @@ import BleReceive from '@/utils/BleReceive';
this.deviceList = []; this.deviceList = [];
this.activeTab = index; this.activeTab = index;
this.activeTabInfo = tab this.activeTabInfo = tab
this.downCallback(); this.downCallback();
}, },
// 获取设备列表 // 获取设备列表

View File

@ -216,7 +216,7 @@
const res = await deviceShareAdd({ const res = await deviceShareAdd({
phonenumber: this.phone, phonenumber: this.phone,
smsCode: this.code, smsCode: this.code,
deviceId: this.itemInfo.id, deviceId: this.itemInfo.id || this.itemInfo.deviceId,
permission: selectedPermissions.join(',') permission: selectedPermissions.join(',')
}) })
@ -250,8 +250,8 @@
const eventChannel = this.getOpenerEventChannel(); const eventChannel = this.getOpenerEventChannel();
// 监听 'shareDevice' 事件,获取传过来的数据 // 监听 'shareDevice' 事件,获取传过来的数据
eventChannel.on('shareDevice', (data) => { eventChannel.on('shareDevice', (data) => {
console.log(data, 'data1t111');
this.itemInfo = data.data; this.itemInfo = data.data;
console.log(this.itemInfo,'this.itemInfo');
this.permissions=Common.getPermissions(this.itemInfo.persissonType); this.permissions=Common.getPermissions(this.itemInfo.persissonType);
console.log(this.itemInfo.persissonType,'this.itemInfo.persissonType'); console.log(this.itemInfo.persissonType,'this.itemInfo.persissonType');
}) })

View File

@ -86,7 +86,9 @@
}, },
getData(val) { getData(val) {
let data = { let data = {
deviceId: val deviceId: val,
pageNum: 1,
pageSize: 500
} }
deviceShareList(data).then((res) => { deviceShareList(data).then((res) => {
if (res.code == 200) { if (res.code == 200) {
@ -117,7 +119,7 @@
eventChannel.on('shareManagement', (data) => { eventChannel.on('shareManagement', (data) => {
console.log(data, 'data1t111'); console.log(data, 'data1t111');
this.itemInfo = data.data; this.itemInfo = data.data;
this.getData(this.itemInfo.id) this.getData(this.itemInfo.id ||this.itemInfo.deviceId)
}) })
} }
} }
@ -179,12 +181,13 @@
border-radius: 32px; border-radius: 32px;
background: rgba(255, 200, 78, 0.06); background: rgba(255, 200, 78, 0.06);
display: inline-block; display: inline-block;
width: 152rpx; width: 100rpx;
height: 60rpx; height: 50rpx;
text-align: center; text-align: center;
line-height: 60rpx; line-height: 50rpx;
color: rgba(224, 52, 52, 1); color: rgba(224, 52, 52, 1);
cursor: pointer; cursor: pointer;
margin-top: 30rpx;
} }
.IMG { .IMG {