From 1de0d7401015a73def923cd75a30d29c9a2c7fc7 Mon Sep 17 00:00:00 2001 From: yanghang Date: Mon, 7 Jul 2025 15:45:50 +0800 Subject: [PATCH] fix: Bug --- src/api/socket.js | 2 ++ src/pages/course/components/touchBtn.vue | 4 ---- src/pages/course/study.vue | 18 ++++++++++++++---- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/api/socket.js b/src/api/socket.js index 71b84695..98392b08 100644 --- a/src/api/socket.js +++ b/src/api/socket.js @@ -65,12 +65,14 @@ export default class WebSocketUtil { console.log('收到WebSocket消息', JSON.parse(res.data) ); if(['0005', 'QQ0005'].includes(rtnCode)) { clearInterval(this.reconnectTimer); + this.reconnectTimer = null this.close() goto_login_fun(); return } }else{ clearInterval(this.reconnectTimer); // 清除重连计时器 + this.reconnectTimer = null goto_login_fun(); return } diff --git a/src/pages/course/components/touchBtn.vue b/src/pages/course/components/touchBtn.vue index 8105040a..1d11dbdb 100644 --- a/src/pages/course/components/touchBtn.vue +++ b/src/pages/course/components/touchBtn.vue @@ -76,10 +76,6 @@ const initRecord = () => {} onMounted(()=>{ initRecord?.() }) -onUnmounted(()=>{ - teacherVoiceObj?.stop?.() - teacherVoiceObj.src = '' -}) // const playRecord = () => { // audioObj.src = audioPath.value // unref(audioObj).play() diff --git a/src/pages/course/study.vue b/src/pages/course/study.vue index a901ef57..fec4fbec 100644 --- a/src/pages/course/study.vue +++ b/src/pages/course/study.vue @@ -151,8 +151,14 @@ const talkingList = ref([]) const activeVoiceTalkingItemId = ref('') const answerValue = ref('') const inputRef = ref('') +const flagVal = ref('1') // 初始化数据 -const getData = async () => { +const getData = async (flag) => { + if(flag === flagVal.value){ + flagVal.value = '2' + }else{ + return + } try{ const { body } = await getCourseStudyInfoApi({crsId: crsId.value}) initsocketTask() @@ -223,7 +229,7 @@ const choiceTeacherInfo = computed(()=>{ }) // 选择教师语音对象 const activeVoiceTeachNo = ref('') -const teacherVoiceObj = uni.createInnerAudioContext() +let teacherVoiceObj = uni.createInnerAudioContext() teacherVoiceObj.onEnded(()=>{ activeVoiceTeachNo.value = '' @@ -455,10 +461,14 @@ onLoad((params) => { const showTalkingModel = ref(false) // 录音 onMounted(()=>{ - getData(); + getData('1'); }) onShow(()=>{ - // getData(); + getData('2'); +}) +onUnmounted(()=>{ + teacherVoiceObj?.stop?.() + teacherVoiceObj.src = '' }) const uploadRecordNow = (voicePath) => {