From 250b2f52fe7ad4523f35de5ba52a08215d58cc31 Mon Sep 17 00:00:00 2001 From: yanghang Date: Sun, 6 Jul 2025 18:01:31 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E5=AD=A6=E4=B9=A0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- .env.production | 2 +- src/api/common.js | 1 + src/api/socket.js | 4 +- src/api/study.js | 46 +++- src/pages/course/components/chartFour.vue | 51 ++-- src/pages/course/components/chartThree.vue | 44 ++-- src/pages/course/components/talkingItem.vue | 186 ++++++++++---- src/pages/course/study.vue | 259 +++++++++++++++----- 9 files changed, 436 insertions(+), 159 deletions(-) diff --git a/.env.development b/.env.development index e47e198f..53f4e8f1 100644 --- a/.env.development +++ b/.env.development @@ -7,7 +7,7 @@ ENV = 'development' # 苗扬 # VITE_APP_BASE_API_Url = 'http://25.64.16.133:9786' -VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' +VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' # http://25.18.122.65:7001/download/dev-jax.apk # app入口 #VITE_APP_BASE_API_Url = 'http://25.18.122.65:7001' diff --git a/.env.production b/.env.production index 7e159f55..df16bf80 100644 --- a/.env.production +++ b/.env.production @@ -3,4 +3,4 @@ ENV = 'production' # base api -VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' +VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' diff --git a/src/api/common.js b/src/api/common.js index 6ae46633..baf0375f 100644 --- a/src/api/common.js +++ b/src/api/common.js @@ -93,6 +93,7 @@ export const commonUploadVoiceFile = (file, url, data = {}, fileKey='voice') => } }, fail(error) { + console.log(error) reject(new Error('Upload failed')); } }); diff --git a/src/api/socket.js b/src/api/socket.js index ca9c0b7d..927cc195 100644 --- a/src/api/socket.js +++ b/src/api/socket.js @@ -63,7 +63,9 @@ export default class WebSocketUtil { if(res.data){ const { rtnCode } = JSON.parse(res.data) console.log('收到WebSocket消息', JSON.parse(res.data) ); - if(['0005', 'QQ0005'].includes(res.rtnCode)) { + if(['0005', 'QQ0005'].includes(rtnCode)) { + clearInterval(this.reconnectTimer); + this.close() goto_login_fun(); return } diff --git a/src/api/study.js b/src/api/study.js index 77a7c50a..203c30f0 100644 --- a/src/api/study.js +++ b/src/api/study.js @@ -1,5 +1,6 @@ import request from '@/api/request' - +import { getToken } from '@/common/common.js' +import { get_base_url } from '@/api/request' const base_url = '/trastudy' // 获取课程学习信息接口 @@ -31,6 +32,15 @@ export const deleteTraStdyInfoByIdApi = (data) => { }); }; +// 重新学习 +export const afreshStudyCourseApi = (data) => { + return request({ + url: base_url + '/traStdyInfo/afreshStudyCourse', + method: 'post', + toastErrors: true, + data + }); +}; // 学习段落完成 export const studyParagraphOverApi = (data) => { return request({ @@ -94,6 +104,17 @@ export const waitMakeEvaluateApi = (data) => { data }); }; +// 查询问题评价 +// /traStdyInfo/queryQuestionEvalate +export const queryQuestionEvalateApi = (data) => { + return request({ + url: base_url + '/traStdyInfo/queryQuestionEvalate', + method: 'post', + toastErrors: true, + data + }); +}; + // /trastudy/intgask/askAbout // 流式获取文本 @@ -111,25 +132,19 @@ export const getAskAboutRawApi = (data) => { // toastErrors: false, // data // }); - return new Promise((resolve, reject) => { - request({ + return request({ url: base_url + '/intgask/askAbout', header: { 'Accept':'text/event-stream', - 'content-type': 'application/json; charset=UTF-8', + 'content-type': 'text/event-stream; charset=UTF-8', }, + responseType: 'arrayBuffer', method: 'get', isStream: true, timeout: 30000, toastErrors: false, data - }).then(res=>{ - console.log(res.data) - let _str = `[${ res.data.split('}{').join('},{')}]` - console.log(JSON.parse(_str)) - }) - }); // return request({ // url: base_url + '/intgask/askAbout', // header: { @@ -142,4 +157,15 @@ export const getAskAboutRawApi = (data) => { // toastErrors: false, // data // }); +}; + + +// 学习 对话 +export const textChartApi = (data) => { + return request({ + url: base_url + '/traStdychat/textChart', + method: 'post', + toastErrors: true, + data + }); }; \ No newline at end of file diff --git a/src/pages/course/components/chartFour.vue b/src/pages/course/components/chartFour.vue index 41bd8e4e..03559c0b 100644 --- a/src/pages/course/components/chartFour.vue +++ b/src/pages/course/components/chartFour.vue @@ -13,12 +13,12 @@ 改进建议: - 57分 + {{props.score}} - - 词命中率 - 98 + + {{ item.gradeDimensName }} + {{ item.anlyGrade }} @@ -26,15 +26,22 @@ @@ -225,9 +236,9 @@ transform: translateY(v-bind(scoreMarginAbsY)); } &.score-item2{ - left: 0%; + right: 0%; top: 50%; - transform: translate(calc(v-bind(scoreMarginX) - 60rpx), calc(-50% + 25rpx)); + transform: translate(calc(v-bind(scoreMarginAbsX) + 60rpx), calc(-50% + 25rpx)); } &.score-item3{ left: 50%; @@ -236,9 +247,9 @@ transform: translateY(v-bind(scoreMarginY)); } &.score-item4{ - right: 0%; + left: 0%; top: 50%; - transform: translate(calc(v-bind(scoreMarginAbsX) + 60rpx), calc(-50% + 25rpx)); + transform: translate(calc(v-bind(scoreMarginX) - 60rpx), calc(-50% + 25rpx)); } } } diff --git a/src/pages/course/components/chartThree.vue b/src/pages/course/components/chartThree.vue index 426a16e4..34d51e49 100644 --- a/src/pages/course/components/chartThree.vue +++ b/src/pages/course/components/chartThree.vue @@ -16,12 +16,12 @@ 改进建议: - 57分 + {{props.score}} - - 词命中率 - 98 + + {{ item.gradeDimensName }} + {{ item.anlyGrade }} @@ -29,15 +29,22 @@ + + diff --git a/src/pages/course/study.vue b/src/pages/course/study.vue index ee2a14b5..6674a71a 100644 --- a/src/pages/course/study.vue +++ b/src/pages/course/study.vue @@ -3,7 +3,7 @@ - + {{chooseRate}}倍 @@ -36,8 +36,8 @@ - - + + {{chooseRate}} 倍 @@ -75,46 +75,14 @@ - - 按住说话 - - - - - - - - - - + - - - - - - - - 松开发送 - - 取消 - - - - - - - - @@ -161,6 +129,7 @@ import { import common from '@/common/common'; import TalkingItem from '@/pages/course/components/talkingItem.vue' import ImagePreview from '@/components/image-preview/image-preview.vue' +import TouchBtn from '@/pages/course/components/touchBtn.vue' import { useSocketStore } from "@/store/socket.js" import { useStorageStore } from "@/store/storage.js" @@ -240,8 +209,12 @@ const getData = async () => { // }) }; +const showChangeSeekModelNow = () => { + // changePlayItemId() + showSeekModel.value = true +} // 关闭播放状态 -const changePlayItemId = (id) => { +const changePlayItemId = (id = '') => { if(activeVoiceTalkingItemId.value === id){ activeVoiceTalkingItemId.value = '' }else{ @@ -321,18 +294,18 @@ const getGraphInfoUnStudy = () => { }).then(res=>{ let _id = new Date().getTime() + 'id' let _body = res.body|| {} - // if(_body.chatContent.haveNext === 'N'){} - talkingList.value.push({ + lastTalkingInfo.value = { crsId: crsId.value, qstLogId: _body.chatBody, pgrphId: _body.pgrphId, logId:_body.chatBody.logId || '', - talkingContent: _body.chatContent, + chatContent: _body.chatContent, userInfo: {...choiceTeacherInfo.value}, ..._body.chatBody, type: Number(_body.bodyTyp) || 0, id: _id - }) + } + talkingList.value.push(lastTalkingInfo.value) pgrphNum.value = _body.chatBody.pgrphNum showOrder.value = _body.chatBody.showOrder logId.value = _body.chatBody.logId || '' @@ -372,16 +345,17 @@ const getQuestionInfoUnStudy = (pgrphId) => { const nextQuestionSuccess = (info, type='next') => { let _id = new Date().getTime() + 'id' if(type === 'next'){ - talkingList.value.push({ + lastTalkingInfo.value = { crsId: info.crsId, pgrphId: info.pgrphId, talkingContent: '继续', type: 0, id: _id - }) + } + talkingList.value.push(lastTalkingInfo.value) scrollToBottomNow(0) getQuestionInfoUnStudy(info.pgrphId) - }else if( type = 'overGraph'){ + }else if( type === 'overGraph'){ textChartApi({ processType: 'PRGH-OVER', requestBody: JSON.stringify({ @@ -389,33 +363,37 @@ const nextQuestionSuccess = (info, type='next') => { logId: info?.logId, }) }).then(res=>{ - talkingList.value.push({ + lastTalkingInfo.value = { crsId: info.crsId, pgrphId: info.pgrphId, talkingContent: '继续', type: 0, id: _id - }) + } + talkingList.value.push(lastTalkingInfo.value) scrollToBottomNow(0) getQuestionInfoUnStudy(info.pgrphId) }) - }else if( type = 'reStart'){ + }else if( type === 'reStart'){ + console.log( 'qstLogId',info.qstLogId) // 重新回答 textChartApi({ processType: 'NEW-ANSER', requestBody: info.qstLogId }).then(res=>{ let _body = res.body|| {} - talkingList.value.push({ + lastTalkingInfo.value = { crsId: info.crsId, qstLogId: _body.chatBody, pgrphId: info.pgrphId, - talkingContent: _body.chatContent, + chatContent: _body.chatContent, userInfo: {...choiceTeacherInfo.value}, ..._body.chatBody, type: Number(_body.bodyTyp) || 0, id: _id - }) + } + + talkingList.value.push(lastTalkingInfo.value) scrollToBottomNow() }) } @@ -491,219 +469,113 @@ const showTalkingModel = ref(false) // 录音 const audioPath = ref('') const audioObj = uni.createInnerAudioContext() -//#ifdef APP-PLUS -// app端 -const recordObj = uni.getRecorderManager() -const initRecord = () => { - unref(recordObj)?.onStop((res, duration)=>{ - audioPath.value = res.tempFilePath - }) -} -const startRecord = () => { - unref(recordObj).start({format:'mp3'}) -} -const stopRecord = () => { - unref(recordObj)?.stop?.() -} -// #endif -//#ifndef APP-PLUS -const recordObj = {} -const initRecord = () => {} -// #endif onMounted(()=>{ getData(); - initRecord?.() }) onShow(()=>{ // getData(); }) -// onHide(()=>{ -// teacherVoiceObj.stop() -// teacherVoiceObj.src = '' -// }) -onUnmounted(()=>{ - teacherVoiceObj?.stop?.() - teacherVoiceObj.src = '' -}) -const playRecord = () => { - audioObj.src = audioPath.value - unref(audioObj).play() -} -// 录音结束 - -// 记录 按下移动位置 -const touchX = ref(0) -const touchY = ref(0) -const baseY = ref(0) -const systemInfo = uni.getSystemInfoSync() -const widowHeight = systemInfo.windowHeight -// 计算是否超出按下盒子位置 -const isOut = computed(() => { - let moveVal = (widowHeight - baseY.value)/140 * 234 - return (widowHeight - moveVal) > touchY.value -}) -const showOverlayTalking = (obj) => { - if(lastTalkingInfo.value.type === 4){ - //#ifdef APP-PLUS - showTalkingModel.value = true - touchX.value = obj.changedTouches[0].pageX - touchY.value = obj.changedTouches[0].pageY - baseY.value = obj.currentTarget.offsetTop - startRecord() - // #endif - }else{ - uni.showToast({ - title: '请先获取问题信息!', - icon: "none", - duration:1000 - }) - } -} -const hideOverlayTalking = (obj) => { - showTalkingModel.value = false - //#ifdef APP-PLUS - stopRecord() - // #endif - if(!isOut.value){ - setTimeout(()=>{ - let _data = { - qnsId: unref(lastTalkingInfo).qnsId,// 问题ID 必输项:true 类型:String - pgrphId: unref(lastTalkingInfo).pgrphId,// 段落ID 必输项:true 类型:String - qstLogId: unref(qstLogId),// 段落ID 必输项:true 类型:String - crsId: crsId.value,// 课程ID 必输项:true 类型:String - stdyBatch: stdyBatch.value,// 学习批次 必输项:true 类型:String - ansterContent: '',// 回答文本内容 必输项:false 类型:String - } - let _id = new Date().getTime() + 'id' - //#ifndef APP-PLUS - // h5 假数据 - talkingList.value.push({ - crsId: crsId.value, - pgrphId: unref(lastTalkingInfo).pgrphId, - qnsId: unref(lastTalkingInfo).qnsId, - talkingContent: '', - talkingVoice: audioPath.value, - type: 1, - userInfo: {...choiceTeacherInfo.value}, - id: _id - }) - scrollToBottomNow() - // #endif - //#ifdef APP-PLUS +const uploadRecordNow = (voicePath) => { + + let _data = { + qnsId: unref(lastTalkingInfo).qnsId,// 问题ID 必输项:true 类型:String + pgrphId: unref(lastTalkingInfo).pgrphId,// 段落ID 必输项:true 类型:String + qstLogId: unref(qstLogId),// 段落ID 必输项:true 类型:String + crsId: crsId.value,// 课程ID 必输项:true 类型:String + stdyBatch: stdyBatch.value,// 学习批次 必输项:true 类型:String + ansterContent: '',// 回答文本内容 必输项:false 类型:String + } + let _id = new Date().getTime() + 'id' + //#ifndef APP-PLUS + // h5 假数据 talkingList.value.push({ crsId: crsId.value, pgrphId: unref(lastTalkingInfo).pgrphId, qnsId: unref(lastTalkingInfo).qnsId, talkingContent: '', talkingVoice: audioPath.value, - intrctId: '', - isLoading: true, type: 1, userInfo: {...choiceTeacherInfo.value}, id: _id }) - scrollToBottomNow() - commonUploadVoiceFile(audioPath.value, '/trastudy/traStdyInfo/studyAnswerVoiceUp', _data).then(res=>{ - let _res = JSON.parse(res.data) - if(_res.rtnCode === '0000'){ - // talkingList.value.pop() - // talkingList.value.push({ - // crsId: crsId.value, - // pgrphId: _data.pgrphId, - // qstLogId: _data.qstLogId, - // qnsId: _data.qnsId, - // talkingContent: '', - // talkingVoice: audioPath.value, - // intrctId: res.body||'', - // type: 1, - // userInfo: {...choiceTeacherInfo.value}, - // id: _id - // }) - talkingList.value = talkingList.value.map(t=>{ - if(t.id === _id){ - return { - crsId: crsId.value, - pgrphId: _data.pgrphId, - qstLogId: _data.qstLogId, - qnsId: _data.qnsId, - talkingContent: '', - talkingVoice: audioPath.value, - intrctId: res.body||'', - type: 1, - userInfo: {...choiceTeacherInfo.value}, - id: _id - } - }else{ - return t - } - }) - scrollToBottomNow() - }else{} - }).catch(err=>{ - talkingList.value = talkingList.value.filter(t=>t.id !== _id) - uni.showToast({ - title: '系统异常,请联系管理员', - icon: "none", - duration:1000 - }); - }) - // #endif - },1000) - } -} - -const handleMove = (obj) => { - touchX.value = obj.changedTouches[0].pageX - touchY.value = obj.changedTouches[0].pageY -} - -const keyboardIsShow = ref(false) -// 发送文本 -const showKeyboard = () => { - if(lastTalkingInfo.value.type === 4){ - if(keyboardIsShow.value){ - if(answerValue.value){ - let _data = { - qnsId: unref(lastTalkingInfo).qnsId,// 问题ID 必输项:true 类型:String - pgrphId: unref(lastTalkingInfo).pgrphId,// 段落ID 必输项:true 类型:String - qstLogId: unref(qstLogId),// 段落ID 必输项:true 类型:String - crsId: crsId.value,// 课程ID 必输项:true 类型:String - stdyBatch: stdyBatch.value,// 学习批次 必输项:true 类型:String - ansterContent: answerValue.value // 回答文本内容 必输项:false 类型:String - } - studyAnswerTextUpApi(_data).then(res=>{ - if(res.rtnCode === '0000'){ - let _id = new Date().getTime() + 'id' - talkingList.value.push({ + scrollToBottomNow() + // #endif + //#ifdef APP-PLUS + talkingList.value.push({ + crsId: crsId.value, + pgrphId: unref(lastTalkingInfo).pgrphId, + qnsId: unref(lastTalkingInfo).qnsId, + talkingContent: '', + talkingVoice: audioPath.value, + intrctId: '', + isLoading: true, + type: 1, + userInfo: {...choiceTeacherInfo.value}, + id: _id + }) + scrollToBottomNow() + commonUploadVoiceFile(audioPath.value, '/trastudy/traStdyInfo/studyAnswerVoiceUp', _data).then(res=>{ + let _res = JSON.parse(res.data) + if(_res.rtnCode === '0000'){ + talkingList.value = talkingList.value.map(t=>{ + if(t.id === _id){ + return { crsId: crsId.value, pgrphId: _data.pgrphId, qstLogId: _data.qstLogId, qnsId: _data.qnsId, - talkingContent: answerValue.value, - talkingVoice: '', + talkingContent: '', + talkingVoice: audioPath.value, intrctId: res.body||'', - type: 2, + type: 1, userInfo: {...choiceTeacherInfo.value}, id: _id - }) - scrollToBottomNow() - answerValue.value = '' - keyboardIsShow.value = !keyboardIsShow.value + } + }else{ + return t } }) - }else{ - keyboardIsShow.value = !keyboardIsShow.value - } - }else{ - keyboardIsShow.value = !keyboardIsShow.value - } - }else{ - uni.showToast({ - title: '请先获取问题信息!', - icon: "none", - duration:1000 + scrollToBottomNow() + }else{} + }).catch(err=>{ + talkingList.value = talkingList.value.filter(t=>t.id !== _id) + uni.showToast({ + title: '系统异常,请联系管理员', + icon: "none", + duration:1000 + }); }) + // #endif +} +// 发送文本 +const submitAnswerNow = (val, cb) => { + let _data = { + qnsId: unref(lastTalkingInfo).qnsId,// 问题ID 必输项:true 类型:String + pgrphId: unref(lastTalkingInfo).pgrphId,// 段落ID 必输项:true 类型:String + qstLogId: unref(qstLogId),// 段落ID 必输项:true 类型:String + crsId: crsId.value,// 课程ID 必输项:true 类型:String + stdyBatch: stdyBatch.value,// 学习批次 必输项:true 类型:String + ansterContent: val // 回答文本内容 必输项:false 类型:String } + studyAnswerTextUpApi(_data).then(res=>{ + if(res.rtnCode === '0000'){ + let _id = new Date().getTime() + 'id' + talkingList.value.push({ + crsId: crsId.value, + pgrphId: _data.pgrphId, + qstLogId: _data.qstLogId, + qnsId: _data.qnsId, + talkingContent: val, + talkingVoice: '', + intrctId: res.body||'', + type: 2, + userInfo: {...choiceTeacherInfo.value}, + id: _id + }) + scrollToBottomNow() + cb && cb() + } + }) } // 撤回 const withdrawNow = (data) => { @@ -724,18 +596,20 @@ const finishQuestionNow = (data) => { // common.msg('完成成功,开始获取评分维度数据!') loadingQstLogId.value = res.body.qstLogId let _id = new Date().getTime() + 'id' - talkingList.value.push({ + lastTalkingInfo.value = { isLoading: true, id: _id, userInfo: {...choiceTeacherInfo.value}, type: 5 - }) + } + talkingList.value.push(lastTalkingInfo.value) scrollToBottomNow(0) getQuestionEvalateRequest(_id,data) }) } // 查询问题回答评分 const getQuestionEvalateRequest = (id, data) => { + console.log( 'qstLogId',data.qstLogId) if(loadingQstLogId.value){ queryQuestionEvalateApi({ qstLogId:loadingQstLogId.value @@ -744,13 +618,15 @@ const getQuestionEvalateRequest = (id, data) => { let _body = res.body talkingList.value = talkingList.value.map(t=>{ if(t.id === id){ - return { + lastTalkingInfo.value = { ..._body, pgrphId: data.pgrphId, + qstLogId: loadingQstLogId.value, id, userInfo: {...choiceTeacherInfo.value}, type: 5 } + return lastTalkingInfo.value }else{ return t } From 3aa5e7ef558e098e55f06ddeebca21d89f0d0777 Mon Sep 17 00:00:00 2001 From: yanghang Date: Mon, 7 Jul 2025 14:00:49 +0800 Subject: [PATCH 05/10] =?UTF-8?q?fix:=20Bug=20=E7=94=9F=E4=BA=A7=E7=BA=BF?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=90=8D=E7=A7=B0=E5=B1=95=E7=A4=BA=E4=B8=8D?= =?UTF-8?q?=E5=85=A8=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/index.vue | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/course/index.vue b/src/pages/course/index.vue index 4bda093d..3b20226d 100644 --- a/src/pages/course/index.vue +++ b/src/pages/course/index.vue @@ -471,11 +471,12 @@ import { onMounted, ref, computed } from 'vue' .type-item{ height: 90rpx; line-height: 90rpx; - font-size: 28rpx; + font-size: 23rpx; box-sizing: border-box; padding: 0 18rpx; - overflow: hidden; - text-overflow: ellipsis; + // overflow: hidden; + // text-overflow: ellipsis; + text-align: center; white-space: nowrap; &.is-active{ background-color: rgba(44,142,242,.1); From 6d1965c231d890f6ad3931da87c417746ef0d7c7 Mon Sep 17 00:00:00 2001 From: yanghang Date: Mon, 7 Jul 2025 14:49:53 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/study.js | 12 --- src/pages/course/components/talkingItem.vue | 96 +++------------------ src/pages/course/index.vue | 15 ++-- src/pages/course/study.vue | 26 ++---- 4 files changed, 24 insertions(+), 125 deletions(-) diff --git a/src/api/study.js b/src/api/study.js index 203c30f0..df818e4e 100644 --- a/src/api/study.js +++ b/src/api/study.js @@ -145,18 +145,6 @@ export const getAskAboutRawApi = (data) => { toastErrors: false, data }) - // return request({ - // url: base_url + '/intgask/askAbout', - // header: { - // 'Accept':'text/event-stream', - // 'content-type': 'application/json; charset=UTF-8', - // }, - // method: 'get', - // isStream: true, - // timeout: 30000, - // toastErrors: false, - // data - // }); }; diff --git a/src/pages/course/components/talkingItem.vue b/src/pages/course/components/talkingItem.vue index a77f8ef3..41fcf10d 100644 --- a/src/pages/course/components/talkingItem.vue +++ b/src/pages/course/components/talkingItem.vue @@ -96,10 +96,12 @@ - - + {{ showContent }} + + + +