From 187698c247b18cb28d21464fc8e14e1589f1eda0 Mon Sep 17 00:00:00 2001 From: yanghang Date: Thu, 17 Jul 2025 10:55:44 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix=20=EF=BC=9B=20bug=20=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=9F=A5=E8=AF=86=E7=82=B9=E8=BF=9B=E5=85=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/study.vue | 25 +++++++++++++------------ src/pages/index/dialog.vue | 7 +++++++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/pages/course/study.vue b/src/pages/course/study.vue index 7ae7e1d7..5d5e9996 100644 --- a/src/pages/course/study.vue +++ b/src/pages/course/study.vue @@ -182,7 +182,7 @@ const getData = async (flag) => { // return // } try{ - await initsocketTask() + initsocketTask() const { body } = await getCourseStudyInfoApi({crsId: crsId.value}) teacherList.value = body.teacheList.map(t=>({ ...t, @@ -192,16 +192,18 @@ const getData = async (flag) => { if(body.stdyProgressFlag === 'N'){ step.value = 1 }else{ + choiceTeacher.value = body.choiceTeacher if(startPgrphId.value){ - choiceTeacher.value = body.choiceTeacher - sendMessage({ - "commond" : 'STDY', - "body" : { - crsId: crsId.value, - teacherNo: choiceTeacher.value - } + setTimeout(() => { + sendMessage({ + "commond" : 'STDY', + "body" : { + crsId: crsId.value, + teacherNo: choiceTeacher.value + } + },300) + step.value = 2 }) - step.value = 2 return } common.show('提示', '系统检测到您已存在学习记录,要继续学习吗?',true, '重新学习','继续学习').then((res) => { @@ -209,7 +211,6 @@ const getData = async (flag) => { // 继续学习 , 获取学习历史接口 // 滚动到最下面 scrollToBottomNow() - choiceTeacher.value = body.choiceTeacher sendMessage({ "commond" : 'STDY', "body" : { @@ -587,8 +588,8 @@ const stdyId = ref('') const stdyBatch = ref('') const logId = ref('') // ws 初始化逻辑 -const initsocketTask = async () => { - await socketStore.creatSocket() +const initsocketTask = () => { + socketStore.creatSocket() unref(SocketObj).on('message', (res)=>{ const { rtnCode, body, commond } = JSON.parse(res.data) if(rtnCode === '0000'){ diff --git a/src/pages/index/dialog.vue b/src/pages/index/dialog.vue index f1562bdd..a1f5b782 100644 --- a/src/pages/index/dialog.vue +++ b/src/pages/index/dialog.vue @@ -415,6 +415,13 @@ import { onShow(()=>{ if(watchFlag.value === 1) return socketStore?.createSocket?.() + sendMessage({ + "commond" : 'ASK-START', + "body" : { + mascotId: mascotId.value, + deviceImei: '' + } + }) }) onUnload(()=>{ watchFlag.value = 1 From 484d5c78f71b3c6eb70007fc93f5396b50c11c8d Mon Sep 17 00:00:00 2001 From: yanghang Date: Thu, 17 Jul 2025 11:32:29 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix=20=EF=BC=9Bbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/study.vue | 41 +++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/src/pages/course/study.vue b/src/pages/course/study.vue index 5d5e9996..f2ecb9e2 100644 --- a/src/pages/course/study.vue +++ b/src/pages/course/study.vue @@ -181,6 +181,7 @@ const getData = async (flag) => { // }else{ // return // } + console.log(11111111) try{ initsocketTask() const { body } = await getCourseStudyInfoApi({crsId: crsId.value}) @@ -194,15 +195,12 @@ const getData = async (flag) => { }else{ choiceTeacher.value = body.choiceTeacher if(startPgrphId.value){ - setTimeout(() => { - sendMessage({ - "commond" : 'STDY', - "body" : { - crsId: crsId.value, - teacherNo: choiceTeacher.value - } - },300) - step.value = 2 + sendMessage({ + "commond" : 'STDY', + "body" : { + crsId: crsId.value, + teacherNo: choiceTeacher.value + } }) return } @@ -590,6 +588,18 @@ const logId = ref('') // ws 初始化逻辑 const initsocketTask = () => { socketStore.creatSocket() + unref(SocketObj).on('open', (res)=>{ + if(startPgrphId.value){ + sendMessage({ + "commond" : 'STDY', + "body" : { + crsId: crsId.value, + teacherNo: choiceTeacher.value + } + }) + step.value = 2 + } + }) unref(SocketObj).on('message', (res)=>{ const { rtnCode, body, commond } = JSON.parse(res.data) if(rtnCode === '0000'){ @@ -598,6 +608,7 @@ const initsocketTask = () => { stdyBatch.value = body.stdyBatch || '' logId.value = body.logId || '' getGraphInfoUnStudy(1) + step.value = 2 } }else{ // if(['0005', 'QQ0005'].includes(res.rtnCode)) { @@ -623,13 +634,14 @@ onLoad((params) => { crsNum.value = params.crsNum||''; imageId.value = params.imgId || '' startPgrphId.value = params.pgrphId||''; - getData('1'); + console.log('onLoad') }); const showTalkingModel = ref(false) // 录音 -// onMounted(()=>{ -// getData('1'); -// }) +onMounted(()=>{ + getData('1'); + console.log('onMounted') +}) onHide(()=>{ if(watchFlag.value === 1) return changePlayItemId('') @@ -639,8 +651,9 @@ onHide(()=>{ }).finally(() => {}) }) onShow(()=>{ + console.log('onShow') if(watchFlag.value === 1) return - socketStore.createSocket() + getData('1'); }) const watchFlag = ref(1) onUnload(()=>{ From 08385da211ec2e8d486adfe70aa569c2cd3e6c58 Mon Sep 17 00:00:00 2001 From: yanghang Date: Thu, 17 Jul 2025 13:47:03 +0800 Subject: [PATCH 3/5] =?UTF-8?q?fix=EF=BC=9A=20=E5=9B=BE=E7=89=87=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/components/chartFour.vue | 2 +- src/pages/course/components/chartThree.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/course/components/chartFour.vue b/src/pages/course/components/chartFour.vue index 2c930ba6..17d70295 100644 --- a/src/pages/course/components/chartFour.vue +++ b/src/pages/course/components/chartFour.vue @@ -14,7 +14,7 @@ {{props.score}}分 - + {{ item.gradeDimensName }} diff --git a/src/pages/course/components/chartThree.vue b/src/pages/course/components/chartThree.vue index d5889b59..44e0160a 100644 --- a/src/pages/course/components/chartThree.vue +++ b/src/pages/course/components/chartThree.vue @@ -17,7 +17,7 @@ {{props.score}}分 - + {{ item.gradeDimensName }} From cfcda80e03a40f372f7e05ea4123ec2c0a1e6e31 Mon Sep 17 00:00:00 2001 From: yanghang Date: Thu, 17 Jul 2025 16:00:09 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix=EF=BC=9A=20=E8=AF=BE=E7=A8=8B=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E6=A0=A1=E9=AA=8C=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/common.js | 32 +++++++++++++++++++++ src/pages/course/components/talkingItem.vue | 30 ++++++++++++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/api/common.js b/src/api/common.js index 61154a68..7b3a4a92 100644 --- a/src/api/common.js +++ b/src/api/common.js @@ -157,6 +157,38 @@ export function downloadVoiceFile(url) { }); }); } + + +export function getAudioByText(data) { + const token = getToken(); + const header = { + "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", + }; + if (token) + header['summary'] = token + let baseUrl = get_base_url(); + + return new Promise((resolve, reject) => { + uni.request({ + url: `${baseUrl}/trastudy/traStdyInfo/readContent`, + header, + method:"POST", + data, + responseType: "arraybuffer", + success(result) { + if(result.statusCode === 200){ + resolve(result.data) + }else{ + reject(new Error(result)) + } + }, + fail(error) { + reject(new Error(error)); + } + }); + }); +} + // 对象存储预览 /traoss/tras3/show/{文件ID} export function previewFile(id, responseType = 'arraybuffer') { const token = getToken(); diff --git a/src/pages/course/components/talkingItem.vue b/src/pages/course/components/talkingItem.vue index b2d61564..edc1b881 100644 --- a/src/pages/course/components/talkingItem.vue +++ b/src/pages/course/components/talkingItem.vue @@ -185,7 +185,7 @@ import { watch, unref, ref, toRefs, computed, nextTick,onMounted } from 'vue' import ImagePreview from '@/components/image-preview/image-preview.vue' import VideoPreview from '@/components/image-preview/video-preview.vue' -import { downloadVoiceFile, uploadVoiceFile, } from "@/api/common.js" +import { downloadVoiceFile, uploadVoiceFile, getAudioByText } from "@/api/common.js" import { studyParagraphOverApi, getAskAboutRawApi } from "@/api/study.js" import ChartFour from "./chartFour.vue" import ChartThree from "./chartThree.vue" @@ -373,6 +373,8 @@ const audioCacheObj = computed(() => storageStore.audioObj) teachNo: unref(teacherInfo)?.teacherNo, // 必填 content: _content } + + let _url = '/trastudy/traStdyInfo/readContent?' + Object.keys(_params).map(t=>{ return encodeURIComponent(t) + '=' + encodeURIComponent(_params[t]) }).join('&') @@ -384,6 +386,19 @@ const audioCacheObj = computed(() => storageStore.audioObj) talkVoiceObj.value.src = url talkVoiceObj.value.play() }else{ + // getAudioByText(_params).then(res=>{ + // // uni.env.USER_DATA_PATH || + // let filePath = `${'/'}/${dataInfo.value.id}.mp3` + // saveFile(res, filePath, () => { + // voiceLoading.value = false + // itemVoice.value = filePath + // talkVoiceObj.value.src = filePath + // talkVoiceObj.value.play() + // storageStore.setStorage('audio', _url + _params.teachNo, itemVoice.value) + // }) + // }).catch(err=>{ + // console.log(err) + // }) downloadVoiceFile(_url).then(res=>{ if(res?.data){ common.msg(res.data.message) @@ -401,6 +416,19 @@ const audioCacheObj = computed(() => storageStore.audioObj) }) } } + const saveFile = (buffer,filePath, cb = ()=>{}) => { + let fileManager = uni.getFileSystemManager() + fileManager.writeFile({ + filePath: filePath, + data: buffer, + encoding: 'binary', + success: cb, + file: ()=>{ + voiceLoading.value = false + console.log('文件保存失败!') + } + }) + } const initVoice = (readType = 'qns', item, isplay=false) => { if(unref(dataInfo).talkingVoice){ itemVoice.value = unref(dataInfo).talkingVoice From 212c25a67707ff93fef1140bf3e8e1950eda3d9b Mon Sep 17 00:00:00 2001 From: yanghang Date: Thu, 17 Jul 2025 17:05:49 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=E7=9F=A5=E8=AF=86=E7=82=B9=E6=97=A0?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/socket.js | 3 +++ src/pages/course/study.vue | 7 ------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/api/socket.js b/src/api/socket.js index 454df64a..40957666 100644 --- a/src/api/socket.js +++ b/src/api/socket.js @@ -155,6 +155,9 @@ export default class WebSocketUtil { } else { console.error('WebSocket连接未打开,无法发送消息'); this.triggerEvent('error', new Error('WebSocket连接未打开')); + setTimeout(()=>{ + this.send(message) + },500) } return this; } diff --git a/src/pages/course/study.vue b/src/pages/course/study.vue index f2ecb9e2..dfe9dd51 100644 --- a/src/pages/course/study.vue +++ b/src/pages/course/study.vue @@ -176,12 +176,6 @@ const flagVal = ref('1') const isUploadingVoice = ref(false) // 初始化数据 const getData = async (flag) => { - // if(flag === flagVal.value){ - // flagVal.value = '2' - // }else{ - // return - // } - console.log(11111111) try{ initsocketTask() const { body } = await getCourseStudyInfoApi({crsId: crsId.value}) @@ -373,7 +367,6 @@ const getGraphInfoUnStudy = (flag = 0) => { if(!_body.chatBody) { return } - console.log('prgh', _body) if(Number(_body.bodyTyp) === 7){ common.show('恭喜你已学完全部知识点', '有什么心得跟我们分享吗?',true, '取消','去评论').then((res) => { if(res) {