From 1deecae63fb031e175bfc673881e5ceeaf87b0a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=88=AA?= Date: Fri, 5 Dec 2025 11:04:20 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=20=E8=AF=AD=E9=9F=B3=E5=BD=95?= =?UTF-8?q?=E9=9F=B3=E6=97=B6=E9=95=BF=E8=8E=B7=E5=8F=96=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development.yh | 4 ++-- src/pages/course/components/talkingItem.vue | 2 +- src/pages/course/components/touchBtn.vue | 20 +++++++++++++++++++- src/pages/course/study.vue | 5 +++-- src/pages/index/components/question.vue | 2 +- src/pages/index/dialog.vue | 5 +++-- src/pages/sparring/components/question.vue | 12 ++++++++---- src/pages/sparring/components/touchBtn.vue | 16 +++++++++++++++- src/pages/sparring/tip.vue | 5 +++-- 9 files changed, 55 insertions(+), 16 deletions(-) diff --git a/.env.development.yh b/.env.development.yh index 193ce295..95d4857d 100644 --- a/.env.development.yh +++ b/.env.development.yh @@ -4,8 +4,8 @@ ENV = 'development.yh' # VITE_APP_BASE_H5_API_Url = 'http://25.18.122.65:7001' -VITE_APP_BASE_H5_API_Url = 'http://25.18.122.91:9786' -# VITE_APP_BASE_H5_API_Url = 'http://25.18.122.78:9786' +# VITE_APP_BASE_H5_API_Url = 'http://25.18.122.91:9786' +VITE_APP_BASE_H5_API_Url = 'http://25.18.122.78:9786' # VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' # VITE_APP_BASE_H5_API_Url_TRAEXAM = 'http://25.64.32.154:9604' # VITE_APP_BASE_H5_API_Url_TRAPRACTICE = 'http://25.64.32.156:9603' diff --git a/src/pages/course/components/talkingItem.vue b/src/pages/course/components/talkingItem.vue index 5cced8fb..b5899afa 100644 --- a/src/pages/course/components/talkingItem.vue +++ b/src/pages/course/components/talkingItem.vue @@ -694,7 +694,7 @@ voiceTime.value = (Math.ceil(talkVoiceObj.value.duration) || 0) + 's'; } else { if (sum === 100) { - voiceTime.value = 0 + 's'; + voiceTime.value = (unref(dataInfo).voiceTime || 0) + 's'; return; } setTimeout(() => { diff --git a/src/pages/course/components/touchBtn.vue b/src/pages/course/components/touchBtn.vue index 3d1a24b3..3bd0a45c 100644 --- a/src/pages/course/components/touchBtn.vue +++ b/src/pages/course/components/touchBtn.vue @@ -174,6 +174,7 @@ const initRecord = () => { recordObjCom.value = uni.getRecorderManager(); unref(recordObjCom)?.onStop((res, duration) => { + isRecording.value = false if(isGettingPermission.value){ isGettingPermission.value = false return @@ -196,13 +197,20 @@ }); } else { closeModel(); - emit('uploadVoice', audioPath.value); + emit('uploadVoice', audioPath.value, recordTime.value); } } else { closeModel(); } }); unref(recordObjCom).onStart(() => { + isRecording.value = true + recordTime.value = 0 + setRecordTime() + if(isGettingPermission.value){ + isGettingPermission.value = false + return + } startFlag.value = 1; setTimeout(() => { startFlag.value = 2; @@ -219,6 +227,16 @@ } }); }; + const setRecordTime = () => { + setTimeout(()=>{ + if(isRecording.value){ + recordTime.value += 1 + setRecordTime() + } + },1000) + } + const isRecording = ref(false) + const recordTime = ref(0) const startFlag = ref(1); // const canStart = ref(true) const startRecord = () => { diff --git a/src/pages/course/study.vue b/src/pages/course/study.vue index 9413450c..62073b71 100644 --- a/src/pages/course/study.vue +++ b/src/pages/course/study.vue @@ -839,7 +839,7 @@ const testAnswer = computed(() => { let _num = _arr.map(t => [1, 2, 6].indexOf(Number(t.type)) >= 0).filter(t => !!t) return _num.length < 5 }) -const uploadRecordNow = voicePath => { +const uploadRecordNow = (voicePath, voiceTime) => { if (!testAnswer.value) { common.msg('每个问题最多连续发送五次答案!') return @@ -911,7 +911,8 @@ const uploadRecordNow = voicePath => { userInfo: { ...choiceTeacherInfo.value }, - id: _id + id: _id, + voiceTime: voiceTime } } else { return t diff --git a/src/pages/index/components/question.vue b/src/pages/index/components/question.vue index d8623d81..1d59196a 100644 --- a/src/pages/index/components/question.vue +++ b/src/pages/index/components/question.vue @@ -131,7 +131,7 @@ import { onUnload } from '@dcloudio/uni-app'; voiceTime.value = (Math.ceil(talkVoiceObj.value.duration) || 1 ) + 's' }else{ if(sum === 20) { - voiceTime.value = 0 + 's' + voiceTime.value = (unref(dataInfo).voiceTime || 0) + 's'; return } setTimeout(()=>{ diff --git a/src/pages/index/dialog.vue b/src/pages/index/dialog.vue index c5bdba65..5c60a1ab 100644 --- a/src/pages/index/dialog.vue +++ b/src/pages/index/dialog.vue @@ -662,7 +662,7 @@ submitAnswerNow(item); }; // 发送语音 - const uploadRecordNow = (voicePath) => { + const uploadRecordNow = (voicePath, voiceTime) => { // /traask/traAskchat/voiceTrans //#ifndef APP-PLUS // h5 假数据 @@ -683,7 +683,8 @@ intrctContent: _res.body.transContent, bucketKey: _res.body.fileId, ossFileAddr: _res.body.ossFileAddr, - talkingVoice: voicePath + talkingVoice: voicePath, + voiceTime: voiceTime }; sendMessage({ commond: 'ASK', diff --git a/src/pages/sparring/components/question.vue b/src/pages/sparring/components/question.vue index d9b1e7d4..05f34268 100644 --- a/src/pages/sparring/components/question.vue +++ b/src/pages/sparring/components/question.vue @@ -130,8 +130,12 @@ talkUserVoiceObj.value.onError(() => { talkUserVoiceObj.value.src = '' }) + talkUserVoiceObj.value.onCanplay(() => { + setVoiceTime(0) + }) itemVoice.value = unref(dataInfo).talkingVoice talkUserVoiceObj.value.src = itemVoice.value + talkUserVoiceObj.value.sessionCategory = 'soloAmbient' //#ifdef APP-PLUS // 安卓端 须播放一次,不然再次播放会没有声音 if (IsAndEnv) { @@ -141,9 +145,9 @@ // talkUserVoiceObj.value.pause() } // #endif - setTimeout(() => { - setVoiceTime(0) - }, 100) + // setTimeout(() => { + // setVoiceTime(0) + // }, 100) } const isTesting = ref(false) const setVoiceTime = (sum) => { @@ -152,7 +156,7 @@ voiceTime.value = (Math.ceil(talkUserVoiceObj.value.duration) || 1) + 's' } else { if (sum === 20) { - voiceTime.value = 0 + 's' + voiceTime.value = (props.dataInfo.voiceTime|| 0) + 's' return } setTimeout(() => { diff --git a/src/pages/sparring/components/touchBtn.vue b/src/pages/sparring/components/touchBtn.vue index dd26ed33..2598f6df 100644 --- a/src/pages/sparring/components/touchBtn.vue +++ b/src/pages/sparring/components/touchBtn.vue @@ -127,6 +127,7 @@ const initRecord = () => { recordObjCom.value = uni.getRecorderManager(); unref(recordObjCom)?.onStop((res, duration) => { + isRecording.value = false if(isGettingPermission.value){ isGettingPermission.value = false return @@ -141,13 +142,16 @@ }); } else { closeModel(); - emit('uploadVoice', audioPath.value); + emit('uploadVoice', audioPath.value, recordTime.value); } } else { closeModel(); } }); unref(recordObjCom).onStart(() => { + isRecording.value = true + recordTime.value = 0 + setRecordTime() if(isGettingPermission.value){ stopRecord(); return @@ -167,6 +171,16 @@ } }); }; + const setRecordTime = () => { + setTimeout(()=>{ + if(isRecording.value){ + recordTime.value += 1 + setRecordTime() + } + },1000) + } + const isRecording = ref(false) + const recordTime = ref(0) const startFlag = ref(1); const startRecord = () => { isStartNum.value += 1; diff --git a/src/pages/sparring/tip.vue b/src/pages/sparring/tip.vue index 9bb0f7ec..ea3bc1bb 100644 --- a/src/pages/sparring/tip.vue +++ b/src/pages/sparring/tip.vue @@ -189,7 +189,7 @@ }, time); }); }; - const uploadRecordNow = (voicePath) => { + const uploadRecordNow = (voicePath, voiceTime) => { //#ifndef APP-PLUS // h5 假数据 // #endif @@ -211,7 +211,8 @@ intrctContent: _res.body.transContent, fileId: _res.body.fileId, ossFileAddr: _res.body.ossFileAddr, - talkingVoice: voicePath + talkingVoice: voicePath, + voiceTime: voiceTime }; sendMessage({ commond: 'ASK',