merge upstream
This commit is contained in:
@ -199,11 +199,47 @@
|
||||
<image src="/static/images/210/delete.png" mode="aspectFit" class="uploadIMG"></image>
|
||||
<text>删除文件</text>
|
||||
</view>
|
||||
<!-- 展示已上传的报警声音文件 -->
|
||||
<view class="file-list-tip" v-if="soundFileList.length > 0">
|
||||
<text>已上传文件:{{ soundFileList.map(item => item.name).join('、') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 按钮组 -->
|
||||
<view class="popup-buttons">
|
||||
<button class="agree" @click="handleupload">确定</button>
|
||||
<button class="agree" @click="handleSoundUpload">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- =====删除报警声音文件列表弹窗======= -->
|
||||
<view class="agreement-mask" v-if="deleteSoundMode" @click.stop="closeDeleteSoundPopup">
|
||||
<view class="agreement-popupB" @click.stop style="height: 45%;">
|
||||
<!-- 标题 -->
|
||||
<view class="popup-title">选择要删除的报警声音</view>
|
||||
<view class="popup-content">
|
||||
<!-- 无文件提示 -->
|
||||
<view v-if="soundFileList.length === 0" class="empty-tip">
|
||||
<text>暂无已上传的报警声音文件</text>
|
||||
</view>
|
||||
<view v-else class="file-list">
|
||||
<view
|
||||
class="file-item"
|
||||
v-for="(file, index) in soundFileList"
|
||||
:key="index"
|
||||
>
|
||||
<checkbox
|
||||
v-model="selectedSoundFiles"
|
||||
:value="file"
|
||||
@change="handleSoundFileSelect"
|
||||
/>
|
||||
<text class="file-name">{{ file.name }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 按钮组 -->
|
||||
<view class="popup-buttons" style="position: relative; bottom: 0;">
|
||||
<button class="disagree" @click="closeDeleteSoundPopup" style="width: 48%;">取消</button>
|
||||
<button class="agreeBtn" @click="confirmDeleteSound" :disabled="selectedSoundFiles.length === 0" style="width: 48%;">确定删除</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -292,9 +328,23 @@
|
||||
console.log('自动报警确认');
|
||||
// 这里可以添加自动报警的逻辑
|
||||
}
|
||||
},
|
||||
// 报警声音上传成功
|
||||
soundUpload: {
|
||||
config: {
|
||||
icon: '/static/images/common/upload.png',
|
||||
message: '报警声音上传成功',
|
||||
showCancel: false
|
||||
}
|
||||
},
|
||||
// 报警声音删除成功
|
||||
soundDelete: {
|
||||
config: {
|
||||
icon: '/static/images/common/sendSucc.png',
|
||||
message: '报警声音删除成功',
|
||||
showCancel: false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
import MqttClient from '@/utils/mqtt.js';
|
||||
import {
|
||||
@ -400,7 +450,11 @@
|
||||
radioSelected: 0, // -1表示未选中任何项
|
||||
deviceType: '',
|
||||
popupType: '', //弹框类型
|
||||
lightModeC: false
|
||||
lightModeC: false,
|
||||
// 新增:报警声音文件相关
|
||||
soundFileList: [],
|
||||
deleteSoundMode: false,
|
||||
selectedSoundFiles: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -408,11 +462,112 @@
|
||||
closePopup() {
|
||||
this.lightModeA = false;
|
||||
this.lightModeB = false;
|
||||
this.lightModeC = false;
|
||||
},
|
||||
// 关闭删除报警声音弹窗
|
||||
closeDeleteSoundPopup() {
|
||||
this.deleteSoundMode = false;
|
||||
this.selectedSoundFiles = []; // 清空选中状态
|
||||
this.lightModeC = true; // 回到报警声音上传弹窗
|
||||
},
|
||||
|
||||
handleSoundFileSelect() {
|
||||
console.log("选中的报警声音文件:", this.selectedSoundFiles);
|
||||
},
|
||||
// 确认删除选中的报警声音文件
|
||||
confirmDeleteSound() {
|
||||
this.soundFileList = this.soundFileList.filter(file => !this.selectedSoundFiles.includes(file));
|
||||
this.showPopup('soundDelete');
|
||||
this.selectedSoundFiles = [];
|
||||
this.closeDeleteSoundPopup();
|
||||
},
|
||||
// 上传报警声音文件
|
||||
uploadFile() {
|
||||
uni.chooseFile({
|
||||
count: 1,
|
||||
success: (res) => {
|
||||
const file = res.tempFiles[0];
|
||||
const fileSize = file.size || 0;
|
||||
// 限制文件大小(示例:5MB)
|
||||
if (fileSize > 5 * 1024 * 1024) {
|
||||
uni.showToast({
|
||||
title: '文件大小不能超过5MB',
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 显示上传中加载提示
|
||||
uni.showLoading({
|
||||
title: '上传中...',
|
||||
mask: true
|
||||
});
|
||||
// 调用上传接口
|
||||
uni.uploadFile({
|
||||
url: baseURL + '/app/device/uploadSound', // 替换为真实的报警声音上传接口
|
||||
filePath: file.path,
|
||||
name: 'file',
|
||||
formData: {
|
||||
deviceId: this.deviceID,
|
||||
},
|
||||
header: {
|
||||
'Authorization': 'Bearer ' + getToken(),
|
||||
'clientid': clientid(),
|
||||
},
|
||||
complete: (res) => {
|
||||
uni.hideLoading();
|
||||
try {
|
||||
const responseData = JSON.parse(res.data);
|
||||
if (responseData.code === 200) {
|
||||
// 上传成功,添加到文件列表
|
||||
this.soundFileList.push({
|
||||
name: file.name,
|
||||
url: responseData.data.url // 接口返回的文件地址
|
||||
});
|
||||
this.showPopup('soundUpload');
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: responseData.msg,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('选择文件失败:', err);
|
||||
uni.showToast({
|
||||
title: '选择文件失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
deleteQ() {
|
||||
if (this.soundFileList.length === 0) {
|
||||
uni.showToast({
|
||||
title: "暂无可删除的报警声音文件",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.lightModeC = false;
|
||||
this.deleteSoundMode = true;
|
||||
},
|
||||
// 报警声音上传弹窗确定按钮
|
||||
handleSoundUpload() {
|
||||
uni.showToast({
|
||||
title: "报警声音配置确认成功",
|
||||
icon: "success"
|
||||
});
|
||||
this.closePopup();
|
||||
},
|
||||
// 上传文件
|
||||
uploadFile() {},
|
||||
// 删除文件
|
||||
deleteQ() {},
|
||||
// 打开弹框
|
||||
showPopup(type) {
|
||||
this.currentPopup = {
|
||||
@ -497,7 +652,7 @@
|
||||
uploadStartup() {
|
||||
this.lightModeB = true
|
||||
},
|
||||
// 上传开机画面
|
||||
// 上传开机画面-选择图片
|
||||
checkImgUpload() {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
@ -766,7 +921,6 @@
|
||||
title: '加载中...'
|
||||
})
|
||||
eventChannel.on('detailData', (data) => {
|
||||
console.log(data, '这是传过来的惨呼啊');
|
||||
this.itemInfo = data.data;
|
||||
this.deviceID = data.data.id;
|
||||
this.navTitle = data.data.deviceName;
|
||||
@ -777,7 +931,7 @@
|
||||
this.isRightIconVisible = this.apiType === 'listA';
|
||||
// 初始化并连接MQTT
|
||||
this.mqttClient = new MqttClient();
|
||||
this.mqttClient.connect(() => {
|
||||
this.mqttClient.connect(() => {
|
||||
console.log('MQTT 连接成功,开始订阅主题');
|
||||
// 订阅来自设备的状态更新
|
||||
const statusTopic = `A/${this.itemInfo.deviceImei}`;
|
||||
@ -1380,4 +1534,30 @@
|
||||
margin-top: 60rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* 新增:删除文件列表样式 */
|
||||
.file-list-tip {
|
||||
margin-top: 20rpx;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
.empty-tip {
|
||||
text-align: center;
|
||||
color: #999;
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
.file-list {
|
||||
padding: 10rpx 0;
|
||||
}
|
||||
.file-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 10rpx 0;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
.file-name {
|
||||
margin-left: 10rpx;
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
}
|
||||
</style>
|
||||
@ -27,19 +27,19 @@
|
||||
<text class="value">{{device.deviceName}}</text>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">Mac地址</text>
|
||||
<text class="value">{{device.deviceMac}}</text>
|
||||
</view>
|
||||
<text class="lbl">Mac地址</text>
|
||||
<text class="value">{{device.deviceMac}}</text>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">设备状态</text>
|
||||
<text class="value">{{formData.statu}}</text>
|
||||
<text class="value" :class="formData.statu === '充电中' ? 'red' : 'white'">{{formData.statu}}</text>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">蓝牙名称</text>
|
||||
<text class="value">{{device.bluetoothName}}</text>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
|
||||
<view class="item">
|
||||
<text class="lbl">蓝牙状态</text>
|
||||
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text>
|
||||
@ -314,7 +314,7 @@
|
||||
}
|
||||
these.formData.blename = f.name ? f.name : "Unname";
|
||||
these.formData.deviceName = device.deviceName;
|
||||
|
||||
|
||||
these.formData.id = device.id;
|
||||
these.formData.deviceId = f.deviceId;
|
||||
these.formData.bleStatu = false;
|
||||
@ -390,6 +390,7 @@
|
||||
}
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
// 重新连接后状态以设备上报为准
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
@ -406,6 +407,9 @@
|
||||
}
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = false;
|
||||
// 断开连接时先将充电状态复位,避免保持旧值
|
||||
this.formData.statu = '未充电';
|
||||
this.setBleFormData();
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
@ -491,7 +495,10 @@
|
||||
}
|
||||
});
|
||||
if ('statu' in json) {
|
||||
these.formData.statu = json.statu == '1' ? '充电中' : '未充电';
|
||||
const chargingVal = json.statu;
|
||||
const isCharging = chargingVal === 1 || chargingVal === '1' || chargingVal === true ||
|
||||
chargingVal === '充电中';
|
||||
these.formData.statu = isCharging ? '充电中' : '未充电';
|
||||
}
|
||||
if ('xuhang' in json) {
|
||||
these.formData.xuhang = json.xuhang;
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
}
|
||||
.deviceTitle{
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
line-height: 45mnrpx;
|
||||
line-height: 45rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user