fix: 新增逻辑,取消ws

This commit is contained in:
杨航
2025-09-19 10:52:25 +08:00
parent 5394124185
commit a895c928bd
3 changed files with 64 additions and 8 deletions
+18 -1
View File
@@ -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) => {
+1 -1
View File
@@ -453,7 +453,7 @@
});
talkVoiceObj.value.onError(() => {
console.log('onError');
if(!talkVoiceObj.value.src) return
talkVoiceObj.value.src = '';
emit('changePlay', '');
});
+45 -6
View File
@@ -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 {