From b7b080a976f8b64ca676e4abf8c601344f4c2650 Mon Sep 17 00:00:00 2001 From: fengerli <528575642@qq.com> Date: Mon, 15 Dec 2025 16:03:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/210/HBY210.vue | 202 +++++++++++++++++++++++++++++++-- pages/common/aboutUs/index.vue | 2 +- 2 files changed, 192 insertions(+), 12 deletions(-) diff --git a/pages/210/HBY210.vue b/pages/210/HBY210.vue index 1df05ba..6719e92 100644 --- a/pages/210/HBY210.vue +++ b/pages/210/HBY210.vue @@ -199,11 +199,47 @@ 删除文件 + + + 已上传文件:{{ soundFileList.map(item => item.name).join('、') }} + - + + + + + + + + + 选择要删除的报警声音 + + + + 暂无已上传的报警声音文件 + + + + + {{ file.name }} + + + + + + + @@ -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); + } \ No newline at end of file diff --git a/pages/common/aboutUs/index.vue b/pages/common/aboutUs/index.vue index 693daf6..5a624a8 100644 --- a/pages/common/aboutUs/index.vue +++ b/pages/common/aboutUs/index.vue @@ -19,7 +19,7 @@ } .deviceTitle{ color: rgba(255, 255, 255, 0.87); - line-height: 45mnrpx; + line-height: 45rpx; font-size: 28rpx; } \ No newline at end of file