From a895c928bd867a02be8db85bd020a804b6126523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=88=AA?= Date: Fri, 19 Sep 2025 10:52:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=96=B0=E5=A2=9E=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E5=8F=96=E6=B6=88ws?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/study.js | 19 +++++++- src/pages/course/components/talkingItem.vue | 2 +- src/pages/course/study.vue | 51 ++++++++++++++++++--- 3 files changed, 64 insertions(+), 8 deletions(-) diff --git a/src/api/study.js b/src/api/study.js index 344c743d..eec4f21e 100644 --- a/src/api/study.js +++ b/src/api/study.js @@ -12,7 +12,6 @@ export const getCourseStudyInfoApi = (data) => { data }); }; - // 获取课程学习 知识点 接口 export const queryTraStdyBatchWaitParagraphInfoApi = (data) => { return request({ @@ -147,6 +146,24 @@ export const getAskAboutRawApi = (data) => { }) }; +// 学习开始 +export const studyStartApi = (data) => { + return request({ + url: base_url + '/traStdychat/studyStart', + method: 'post', + toastErrors: true, + data + }); +}; +// 学习结束 +export const studyEndApi = (data) => { + return request({ + url: base_url + '/traStdychat/studyEnd', + method: 'post', + toastErrors: true, + data + }); +}; // 学习 对话 export const textChartApi = (data) => { diff --git a/src/pages/course/components/talkingItem.vue b/src/pages/course/components/talkingItem.vue index f17aadf9..6a3805ee 100644 --- a/src/pages/course/components/talkingItem.vue +++ b/src/pages/course/components/talkingItem.vue @@ -453,7 +453,7 @@ }); talkVoiceObj.value.onError(() => { - console.log('onError'); + if(!talkVoiceObj.value.src) return talkVoiceObj.value.src = ''; emit('changePlay', ''); }); diff --git a/src/pages/course/study.vue b/src/pages/course/study.vue index 06dc8751..d33d6990 100644 --- a/src/pages/course/study.vue +++ b/src/pages/course/study.vue @@ -126,7 +126,17 @@ import { onLoad, onShow, onUnload, onHide } from '@dcloudio/uni-app' import { previewFile, downloadFile, commonUploadVoiceFile, downloadVoiceFile, uploadVoiceFile } from '@/api/common.js' import { getToken, getPhoneEnvBool } from '@/common/common.js' import { get_base_url, goto_login_fun } from '@/api/request' -import { getCourseStudyInfoApi, afreshStudyCourseApi, queryQuestionEvalateApi, textChartApi, setStudyTeacherApi, textChartPreviewApi, previewAfreshStudyCourse } from '@/api/study.js' +import { + getCourseStudyInfoApi, + afreshStudyCourseApi, + queryQuestionEvalateApi, + textChartApi, + setStudyTeacherApi, + textChartPreviewApi, + previewAfreshStudyCourse, + studyEndApi, + studyStartApi +} from '@/api/study.js' import common from '@/common/common' import TalkingItem from '@/pages/course/components/talkingItem.vue' import ImagePreview from '@/components/image-preview/image-preview.vue' @@ -231,6 +241,17 @@ const getData = async flag => { watchFlag.value += 1 } } +const startStudy = (data) => { + studyStartApi(data).then(res=>{ + const { body } = res + stdyId.value = body.stdyId || '' + stdyBatch.value = body.stdyBatch || '' + oldStdyId.value = body.oldStdyId || '' + logId.value = body.logId || '' + getGraphInfoUnStudy(1) + step.value = 2 + }).catch(err=>{}) +} // 重新学习 const resStartStudyNow = ($list = []) => { let _ajax = isPreview.value ? previewAfreshStudyCourse : afreshStudyCourseApi @@ -680,7 +701,8 @@ const reconnect = () => { initsocketTask() } const sendMessage = data => { - unref(SocketObj).send(data) + // unref(SocketObj).send(data) + startStudy(data.body) } // ws 结束 const startPgrphId = ref('') @@ -697,7 +719,7 @@ onLoad(params => { const showTalkingModel = ref(false) // 录音 onMounted(() => { - initsocketTask() + // initsocketTask() getData('1') }) const keyboardHeight = ref('0px') @@ -721,9 +743,15 @@ const changeAppHeightBottom = height => { bottomHeight.value = systemInfo.screenHeight - systemInfo.safeArea.bottom + 'px' // #endif } +const closeStudy = () => { + return studyEndApi({ + stdyId: stdyId.value + }) +} onHide(() => { changePlayItemId('') - socketStore.closeSocket() + closeStudy() + // socketStore.closeSocket() //#ifdef APP-PLUS uni.offKeyboardHeightChange(setHeight) // #endif @@ -738,12 +766,23 @@ onShow(() => { // #endif if (watchFlag.value === 1) return // getData('2'); - initsocketTask() + // initsocketTask() + sendMessage({ + commond: 'STDY', + body: { + crsId: crsId.value, + teacherNo: choiceTeacher.value, + studyType: isPreview.value ? 'P' : 'S', + isContinue: isContinue.value, + stdyId: stdyId.value + } + }) }) const watchFlag = ref(1) onUnload(() => { console.log('onUnload') - socketStore.closeSocket() + closeStudy() + // socketStore.closeSocket() changePlayItemId('') console.log(typeof teacherVoiceObj) try {