更新100j蓝牙

This commit is contained in:
微微一笑
2026-03-19 12:37:29 +08:00
parent ebe126d826
commit f943bb9b09
4 changed files with 605 additions and 37 deletions

View File

@ -104,7 +104,8 @@
deviceVoliceList,
videRenameAudioFile,
deviceDeleteAudioFile,
deviceUpdateVoice
deviceUpdateVoice,
updateBleStatus
} from '@/api/100J/HBY100-J.js'
import { baseURL } from '@/utils/request.js'
import {
@ -218,6 +219,10 @@
console.log(rec, 'ressss');
this.blue = rec.ble;
this.device = rec.data;
// 同步蓝牙状态,确保语音上传走蓝牙优先
if (rec.ble && (rec.ble.isConnected || rec.ble.bleDeviceId)) {
updateBleStatus(!!rec.ble.isConnected, rec.ble.bleDeviceId || '', rec.data?.deviceId || '');
}
this.getinitData(rec.data.deviceId, true)
});
@ -496,16 +501,20 @@
this.isUpdating = true;
// 本地项优先用 localPath云端项用 fileUrl兼容多种字段名相对路径补全 baseURL
let fileUrl = '';
let localPath = (item.localPath && typeof item.localPath === 'string') ? item.localPath : '';
if (!item._isLocal) {
const raw = item.fileUrl || item.url || item.filePath || item.audioUrl || item.ossUrl || '';
fileUrl = (typeof raw === 'string' && raw) ? (raw.startsWith('/') ? (baseURL + raw) : raw) : '';
} else {
// 本地项localPath 优先,无则用 fileUrlmergeLocal 中可能只有 fileUrl 存路径)
if (!localPath && item.fileUrl) localPath = item.fileUrl;
}
const localPath = (item.localPath && typeof item.localPath === 'string') ? item.localPath : '';
const data = {
id: item.id,
fileUrl,
localPath,
onProgress: (p) => { this.updateProgress = p; }
onProgress: (p) => { this.updateProgress = p; },
onWaiting: () => { uni.showToast({ title: '等待蓝牙连接中...', icon: 'none', duration: 2000 }); }
};
// 整体超时 60 秒仅影响蓝牙上传4G HTTP 很快返回)
const overallTimer = setTimeout(() => {
@ -518,11 +527,6 @@
deviceUpdateVoice(data).then((RES) => {
clearTimeout(overallTimer);
if (RES.code == 200) {
// 更新列表选中状态:当前项设为使用中,其他项取消
const targetId = item.id || item.Id;
this.dataListA.forEach(it => {
it.useStatus = ((it.id || it.Id) === targetId) ? 1 : 0;
});
// 蓝牙上传:进度已由 onProgress 更新,直接完成
if (RES._channel === 'ble') {
uni.showToast({ title: '音频上传成功', icon: 'success', duration: 2000 });
@ -549,11 +553,6 @@
this.updateProgress = progress;
if (progress === 100) {
clearTimeout(this.upgradeTimer);
// 更新列表选中状态4G 成功时)
const targetId = item.id || item.Id;
this.dataListA.forEach(it => {
it.useStatus = ((it.id || it.Id) === targetId) ? 1 : 0;
});
uni.showToast({ title: '音频上传成功', icon: 'success', duration: 2000 });
this.isUpdating = false;
setTimeout(() => { uni.navigateBack(); }, 1500);