提交
This commit is contained in:
@ -199,11 +199,47 @@
|
|||||||
<image src="/static/images/210/delete.png" mode="aspectFit" class="uploadIMG"></image>
|
<image src="/static/images/210/delete.png" mode="aspectFit" class="uploadIMG"></image>
|
||||||
<text>删除文件</text>
|
<text>删除文件</text>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- 展示已上传的报警声音文件 -->
|
||||||
|
<view class="file-list-tip" v-if="soundFileList.length > 0">
|
||||||
|
<text>已上传文件:{{ soundFileList.map(item => item.name).join('、') }}</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 按钮组 -->
|
<!-- 按钮组 -->
|
||||||
<view class="popup-buttons">
|
<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>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -292,9 +328,23 @@
|
|||||||
console.log('自动报警确认');
|
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 MqttClient from '@/utils/mqtt.js';
|
||||||
import {
|
import {
|
||||||
@ -400,7 +450,11 @@
|
|||||||
radioSelected: 0, // -1表示未选中任何项
|
radioSelected: 0, // -1表示未选中任何项
|
||||||
deviceType: '',
|
deviceType: '',
|
||||||
popupType: '', //弹框类型
|
popupType: '', //弹框类型
|
||||||
lightModeC: false
|
lightModeC: false,
|
||||||
|
// 新增:报警声音文件相关
|
||||||
|
soundFileList: [],
|
||||||
|
deleteSoundMode: false,
|
||||||
|
selectedSoundFiles: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -408,11 +462,112 @@
|
|||||||
closePopup() {
|
closePopup() {
|
||||||
this.lightModeA = false;
|
this.lightModeA = false;
|
||||||
this.lightModeB = 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) {
|
showPopup(type) {
|
||||||
this.currentPopup = {
|
this.currentPopup = {
|
||||||
@ -497,7 +652,7 @@
|
|||||||
uploadStartup() {
|
uploadStartup() {
|
||||||
this.lightModeB = true
|
this.lightModeB = true
|
||||||
},
|
},
|
||||||
// 上传开机画面
|
// 上传开机画面-选择图片
|
||||||
checkImgUpload() {
|
checkImgUpload() {
|
||||||
uni.chooseImage({
|
uni.chooseImage({
|
||||||
count: 1,
|
count: 1,
|
||||||
@ -766,7 +921,6 @@
|
|||||||
title: '加载中...'
|
title: '加载中...'
|
||||||
})
|
})
|
||||||
eventChannel.on('detailData', (data) => {
|
eventChannel.on('detailData', (data) => {
|
||||||
console.log(data, '这是传过来的惨呼啊');
|
|
||||||
this.itemInfo = data.data;
|
this.itemInfo = data.data;
|
||||||
this.deviceID = data.data.id;
|
this.deviceID = data.data.id;
|
||||||
this.navTitle = data.data.deviceName;
|
this.navTitle = data.data.deviceName;
|
||||||
@ -777,7 +931,7 @@
|
|||||||
this.isRightIconVisible = this.apiType === 'listA';
|
this.isRightIconVisible = this.apiType === 'listA';
|
||||||
// 初始化并连接MQTT
|
// 初始化并连接MQTT
|
||||||
this.mqttClient = new MqttClient();
|
this.mqttClient = new MqttClient();
|
||||||
this.mqttClient.connect(() => {
|
this.mqttClient.connect(() => {
|
||||||
console.log('MQTT 连接成功,开始订阅主题');
|
console.log('MQTT 连接成功,开始订阅主题');
|
||||||
// 订阅来自设备的状态更新
|
// 订阅来自设备的状态更新
|
||||||
const statusTopic = `A/${this.itemInfo.deviceImei}`;
|
const statusTopic = `A/${this.itemInfo.deviceImei}`;
|
||||||
@ -1380,4 +1534,30 @@
|
|||||||
margin-top: 60rpx;
|
margin-top: 60rpx;
|
||||||
position: relative;
|
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>
|
</style>
|
||||||
@ -19,7 +19,7 @@
|
|||||||
}
|
}
|
||||||
.deviceTitle{
|
.deviceTitle{
|
||||||
color: rgba(255, 255, 255, 0.87);
|
color: rgba(255, 255, 255, 0.87);
|
||||||
line-height: 45mnrpx;
|
line-height: 45rpx;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
Reference in New Issue
Block a user