From abc83f85e4b9e4fe7aaec7d9d35d65338d6e6623 Mon Sep 17 00:00:00 2001 From: yanghang Date: Fri, 18 Jul 2025 14:10:31 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/components/touchBtn.vue | 27 +++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/pages/course/components/touchBtn.vue b/src/pages/course/components/touchBtn.vue index 6477cf62..07a5b70d 100644 --- a/src/pages/course/components/touchBtn.vue +++ b/src/pages/course/components/touchBtn.vue @@ -120,18 +120,21 @@ onMounted(async ()=>{ }) } }else{ - // let _recordPerm = permission.judgeIosPermission('record') - // if(!_recordPerm){ - // common.show('提示信息', '当前页面需要使用的录音权限,是否前往开启?',true, '取消','确定').then((res) => { - // if(res) { - // // 去开启权限 - // permission.gotoAppPermissionSetting() - // }else{ - // // 取消 - // common.navigateBack() - // } - // }) - // } + let _recordPerm = uni.getAppAuthorizeSetting() + let _state = _recordPerm.microphoneAuthorized + if(_state === 'denied'){ + common.show('提示信息', '当前页面需要使用的录音权限,是否前往开启?',true, '取消','确定').then((res) => { + if(res) { + // 去开启权限 + permission.gotoAppPermissionSetting() + }else{ + // 取消 + common.navigateBack() + } + }) + }else if(_state === 'not determined'){ + startRecord() + } } // #endif }) From 266cc7451f5f4a95cd3ec7ed172e0db8682eca34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=B9=E6=9E=9C=E7=94=B5=E8=84=91?= Date: Fri, 18 Jul 2025 14:35:50 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E5=88=B0=E6=9D=83=E9=99=90=E9=A1=B5=E9=9D=A22?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/components/touchBtn.vue | 35 +++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/pages/course/components/touchBtn.vue b/src/pages/course/components/touchBtn.vue index 07a5b70d..eb69ea22 100644 --- a/src/pages/course/components/touchBtn.vue +++ b/src/pages/course/components/touchBtn.vue @@ -88,10 +88,15 @@ const initRecord = () => { unref(recordObjCom)?.onStop((res, duration)=>{ audioPath.value = res.tempFilePath }) + unref(recordObjCom).onStart(() => { + console.log('开始录音了'); + showTalkingModel.value = true + }) } const startRecord = () => { unref(recordObjCom).start({format:'mp3'}) } + const stopRecord = () => { if(unref(recordObjCom).stop){ unref(recordObjCom)?.stop?.() @@ -120,21 +125,18 @@ onMounted(async ()=>{ }) } }else{ - let _recordPerm = uni.getAppAuthorizeSetting() - let _state = _recordPerm.microphoneAuthorized - if(_state === 'denied'){ - common.show('提示信息', '当前页面需要使用的录音权限,是否前往开启?',true, '取消','确定').then((res) => { - if(res) { - // 去开启权限 - permission.gotoAppPermissionSetting() - }else{ - // 取消 - common.navigateBack() - } - }) - }else if(_state === 'not determined'){ - startRecord() - } + // let _recordPerm = permission.judgeIosPermission('record') + // if(!_recordPerm){ + // common.show('提示信息', '当前页面需要使用的录音权限,是否前往开启?',true, '取消','确定').then((res) => { + // if(res) { + // // 去开启权限 + // permission.gotoAppPermissionSetting() + // }else{ + // // 取消 + // common.navigateBack() + // } + // }) + // } } // #endif }) @@ -158,6 +160,7 @@ const recNum = ref(1) const activeNum = ref(1) const getRecordPermission = async (obj) => { + //#ifdef APP-PLUS // 安卓端 // let _recordPerm = await permission.requestAndroidPermission('android.permission.RECORD_AUDIO') @@ -184,7 +187,7 @@ const showOverlayTalking = (obj) => { emit('startRecord') recNum.value += 1 if(!isDisabled.value){ - showTalkingModel.value = true + touchX.value = obj.changedTouches[0].pageX touchY.value = obj.changedTouches[0].pageY baseY.value = obj.currentTarget.offsetTop From d3ee3a56ef47976b663a94f9176140580ebd185a Mon Sep 17 00:00:00 2001 From: yanghang Date: Fri, 18 Jul 2025 14:50:06 +0800 Subject: [PATCH 3/7] =?UTF-8?q?fix=EF=BC=9A=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../image-preview/image-preview.vue | 2 +- .../image-preview/video-preview.vue | 4 ++-- src/pages/course/components/touchBtn.vue | 23 ++++++------------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/components/image-preview/image-preview.vue b/src/components/image-preview/image-preview.vue index f368c93f..330050b6 100644 --- a/src/components/image-preview/image-preview.vue +++ b/src/components/image-preview/image-preview.vue @@ -156,7 +156,7 @@ position: absolute; left: 50%; top: 50%; - max-width: 100%; + width: 100vw; max-height: 100%; transform: translate(-50%, -50%); } diff --git a/src/components/image-preview/video-preview.vue b/src/components/image-preview/video-preview.vue index 8f65deec..3eb87594 100644 --- a/src/components/image-preview/video-preview.vue +++ b/src/components/image-preview/video-preview.vue @@ -104,8 +104,8 @@ transform: translate(-50%, -50%); } .overlay-box .video-cont-center{ - max-width: 100%; - max-height: 80%; + width: 100vw; + max-height: 100%; position: absolute; top: 50%; left: 50%; diff --git a/src/pages/course/components/touchBtn.vue b/src/pages/course/components/touchBtn.vue index eb69ea22..9afeaab4 100644 --- a/src/pages/course/components/touchBtn.vue +++ b/src/pages/course/components/touchBtn.vue @@ -87,6 +87,10 @@ const initRecord = () => { // stopRecord() unref(recordObjCom)?.onStop((res, duration)=>{ audioPath.value = res.tempFilePath + showTalkingModel.value = false + if(!isOut.value){ + emit('uploadVoice', audioPath.value) + } }) unref(recordObjCom).onStart(() => { console.log('开始录音了'); @@ -187,7 +191,6 @@ const showOverlayTalking = (obj) => { emit('startRecord') recNum.value += 1 if(!isDisabled.value){ - touchX.value = obj.changedTouches[0].pageX touchY.value = obj.changedTouches[0].pageY baseY.value = obj.currentTarget.offsetTop @@ -208,21 +211,9 @@ const showOverlayTalking = (obj) => { } const hideOverlayTalking = (obj) => { if(!showTalkingModel.value) return - if(activeNum.value + 1 === recNum.value){ - showTalkingModel.value = false - //#ifdef APP-PLUS - stopRecord() - // #endif - if(!isOut.value){ - setTimeout(()=>{ - emit('uploadVoice', audioPath.value) - },1000) - } - }else{ - showTalkingModel.value = false - common.msg('录音失败,请重试!') - } - activeNum.value = recNum.value + //#ifdef APP-PLUS + stopRecord() + // #endif } const handleMove = (obj) => { From de20bf250a50f48eed0cc128037763673e70cfef Mon Sep 17 00:00:00 2001 From: yanghang Date: Fri, 18 Jul 2025 15:00:38 +0800 Subject: [PATCH 4/7] fix: bug --- src/pages/course/components/touchBtn.vue | 27 +++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/pages/course/components/touchBtn.vue b/src/pages/course/components/touchBtn.vue index 9afeaab4..9a40eb77 100644 --- a/src/pages/course/components/touchBtn.vue +++ b/src/pages/course/components/touchBtn.vue @@ -129,18 +129,21 @@ onMounted(async ()=>{ }) } }else{ - // let _recordPerm = permission.judgeIosPermission('record') - // if(!_recordPerm){ - // common.show('提示信息', '当前页面需要使用的录音权限,是否前往开启?',true, '取消','确定').then((res) => { - // if(res) { - // // 去开启权限 - // permission.gotoAppPermissionSetting() - // }else{ - // // 取消 - // common.navigateBack() - // } - // }) - // } + let _recordPerm = uni.getAppAuthorizeSetting() + let _state = _recordPerm.microphoneAuthorized + if(_state === 'denied'){ + common.show('提示信息', '当前页面需要使用的录音权限,是否前往开启?',true, '取消','确定').then((res) => { + if(res) { + // 去开启权限 + permission.gotoAppPermissionSetting() + }else{ + // 取消 + common.navigateBack() + } + }) + }else if(_state === 'not determined'){ + startRecord() + } } // #endif }) From 911fe2f4ee9e45d1b7e7be68bd75f32a4db4b8af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=B9=E6=9E=9C=E7=94=B5=E8=84=91?= Date: Fri, 18 Jul 2025 15:19:02 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E5=88=B0=E6=9D=83=E9=99=90=E9=A1=B5=E9=9D=A23?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/components/touchBtn.vue | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pages/course/components/touchBtn.vue b/src/pages/course/components/touchBtn.vue index 9a40eb77..33e287d4 100644 --- a/src/pages/course/components/touchBtn.vue +++ b/src/pages/course/components/touchBtn.vue @@ -94,7 +94,11 @@ const initRecord = () => { }) unref(recordObjCom).onStart(() => { console.log('开始录音了'); - showTalkingModel.value = true + let _recordPerm = uni.getAppAuthorizeSetting() + let _state = _recordPerm.microphoneAuthorized + if(_state === 'authorized'){ + showTalkingModel.value = true + } }) } const startRecord = () => { @@ -136,13 +140,16 @@ onMounted(async ()=>{ if(res) { // 去开启权限 permission.gotoAppPermissionSetting() + uni.openAppAuthorizeSetting({ + + }) }else{ // 取消 common.navigateBack() } }) }else if(_state === 'not determined'){ - startRecord() + // startRecord() } } // #endif From 39e3965bf5a169c78c8bffa576b5b182b22e5829 Mon Sep 17 00:00:00 2001 From: yanghang Date: Fri, 18 Jul 2025 15:50:32 +0800 Subject: [PATCH 6/7] fix ;bug --- src/api/socket.js | 1 + src/pages/course/components/touchBtn.vue | 64 +++++++++++++++--------- src/pages/course/study.vue | 2 + src/pages/index/components/question.vue | 35 +++++++++---- 4 files changed, 67 insertions(+), 35 deletions(-) diff --git a/src/api/socket.js b/src/api/socket.js index 40957666..f10f1ba3 100644 --- a/src/api/socket.js +++ b/src/api/socket.js @@ -35,6 +35,7 @@ export default class WebSocketUtil { */ init(flag = false) { if(flag) this.reconnectCount = 0 + this.isClose = false; // 手动关闭 // 创建WebSocket连接 this.socketTask = uni.connectSocket({ url: this.url, diff --git a/src/pages/course/components/touchBtn.vue b/src/pages/course/components/touchBtn.vue index 33e287d4..3765cae2 100644 --- a/src/pages/course/components/touchBtn.vue +++ b/src/pages/course/components/touchBtn.vue @@ -61,12 +61,23 @@ const props = defineProps({ default: false, type: Boolean }, + canAnswer:{ + default: true, + type: Boolean + }, + canAnswerText:{ + default: '当前状态不能发送内容!', + type: String + }, }) const { isDisabled, onlyVoice } = toRefs(props) const isLoadingState = computed(() => props.isLoading) watch(()=>props.isLoading,()=>{},{ deep:true,immediate:true }) +watch(()=>props.canAnswer,()=>{},{ + deep:true,immediate:true +}) watch(()=>props.onlyVoice,()=>{},{ deep:true,immediate:true }) @@ -88,12 +99,19 @@ const initRecord = () => { unref(recordObjCom)?.onStop((res, duration)=>{ audioPath.value = res.tempFilePath showTalkingModel.value = false + if(startFlag.value !== 2){ + common.msg('说话时间太短,没有听清!') + return + } if(!isOut.value){ emit('uploadVoice', audioPath.value) } }) unref(recordObjCom).onStart(() => { - console.log('开始录音了'); + startFlag.value = 1 + setTimeout(()=>{ + startFlag.value = 2 + },1000) let _recordPerm = uni.getAppAuthorizeSetting() let _state = _recordPerm.microphoneAuthorized if(_state === 'authorized'){ @@ -101,6 +119,7 @@ const initRecord = () => { } }) } +const startFlag = ref(1) const startRecord = () => { unref(recordObjCom).start({format:'mp3'}) } @@ -139,10 +158,7 @@ onMounted(async ()=>{ common.show('提示信息', '当前页面需要使用的录音权限,是否前往开启?',true, '取消','确定').then((res) => { if(res) { // 去开启权限 - permission.gotoAppPermissionSetting() - uni.openAppAuthorizeSetting({ - - }) + uni.openAppAuthorizeSetting() }else{ // 取消 common.navigateBack() @@ -173,22 +189,10 @@ const outScreen = computed(()=>{ const recNum = ref(1) const activeNum = ref(1) -const getRecordPermission = async (obj) => { - - //#ifdef APP-PLUS - // 安卓端 - // let _recordPerm = await permission.requestAndroidPermission('android.permission.RECORD_AUDIO') - // if(_recordPerm !== 1){ - // permission.gotoAppPermissionSetting() - // return - // } - showOverlayTalking(obj) - // #endif - //#ifndef APP-PLUS - // pc端 - showOverlayTalking(obj) - // #endif +const getRecordPermission = (obj) => { + showOverlayTalking(obj) } +const isMoving = ref(false) const showOverlayTalking = (obj) => { if(isLoadingState.value){ uni.showToast({ @@ -198,6 +202,15 @@ const showOverlayTalking = (obj) => { }) return } + if(!props.canAnswer){ + uni.showToast({ + title: props.canAnswerText, + icon: "none", + duration:1000 + }) + return + } + isMoving.value = true emit('startRecord') recNum.value += 1 if(!isDisabled.value){ @@ -220,6 +233,7 @@ const showOverlayTalking = (obj) => { } } const hideOverlayTalking = (obj) => { + isMoving.value = false if(!showTalkingModel.value) return //#ifdef APP-PLUS stopRecord() @@ -227,10 +241,12 @@ const hideOverlayTalking = (obj) => { } const handleMove = (obj) => { - touchX.value = obj.changedTouches[0].pageX - touchY.value = obj.changedTouches[0].pageY - if(outScreen.value){ - hideOverlayTalking(obj) + if(isMoving.value){ + touchX.value = obj.changedTouches[0].pageX + touchY.value = obj.changedTouches[0].pageY + if(outScreen.value){ + hideOverlayTalking(obj) + } } } // 发送文本 diff --git a/src/pages/course/study.vue b/src/pages/course/study.vue index 30abf488..6c78dcf6 100644 --- a/src/pages/course/study.vue +++ b/src/pages/course/study.vue @@ -85,6 +85,8 @@ @startRecord="changePlayItemId('')" :isLoading="isUploadingVoice" :onlyVoice="answerOnlyVoice" + :canAnswer="testAnswer" + :canAnswerText="'每个问题最多连续发送五次答案!'" :isDisabled="((lastTalkingInfo.type||0) !== 4)" /> diff --git a/src/pages/index/components/question.vue b/src/pages/index/components/question.vue index f6e9a8df..900169d6 100644 --- a/src/pages/index/components/question.vue +++ b/src/pages/index/components/question.vue @@ -1,6 +1,6 @@