From 8e99f7c99b30428e1e3eb30244d22d9259a31845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=B2=A9?= Date: Sat, 6 Sep 2025 21:50:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=A8=E5=85=AD=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 7 +- .env.production | 1 + src/App.vue | 8 +- src/api/request.js | 3 +- src/components/examination/question.vue | 11 +- src/components/examination/subject.vue | 8 +- .../components/studyRecordItem.vue | 2 +- src/pages/examination/index.vue | 134 ++++++++++++++---- src/pages/index/index.vue | 2 +- src/pages/index/preview.vue | 1 + 10 files changed, 134 insertions(+), 43 deletions(-) diff --git a/.env.development b/.env.development index ad663b78..5135d57a 100644 --- a/.env.development +++ b/.env.development @@ -15,20 +15,21 @@ VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' # h5专用地址 -VITE_APP_BASE_H5_API_Url = 'https://aitstest.jlbank.com.cn:7001' +#VITE_APP_BASE_H5_API_Url = 'http://25.16.122.65:7001' +#VITE_APP_BASE_H5_API_Url = 'http://25.18.122.21:9786' # VITE_APP_BASE_H5_API_Url = 'https://aitstest.jlbank.com.cn:7002' # dev VITE_APP_BASE_H5_API_Url = 'http://25.18.122.65:7001' # sit -# VITE_APP_BASE_H5_API_Url = 'http://25.18.122.91:9786' +#VITE_APP_BASE_H5_API_Url = 'http://25.18.122.91:9786' # UAT # VITE_APP_BASE_H5_API_Url = 'http://25.18.122.78:9786' # 任东 # VITE_APP_BASE_H5_API_Url_TRAAPP = 'http://25.64.16.130:9601' -VITE_APP_BASE_H5_API_Url_TRASTUDY = 'http://25.64.16.130:9602' +# VITE_APP_BASE_H5_API_Url_TRASTUDY = 'http://25.64.16.130:9602' # VITE_APP_BASE_H5_API_Url_TRAEXAM = 'http://25.64.16.140:9604' # 张建成 diff --git a/.env.production b/.env.production index 80b9b345..69e00b3b 100644 --- a/.env.production +++ b/.env.production @@ -3,3 +3,4 @@ ENV = 'production' # base api VITE_APP_BASE_API_Url = 'https://aits.jlbank.com.cn:7001' +# VITE_APP_BASE_API_Url = 'http://25.18.122.21:9786' \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index 934e65bc..bfc6cc8f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -45,10 +45,10 @@ } // 使用示例 - const browserInfo = getBrowserInfo(); - console.log(`浏览器: ${browserInfo.browser}`); - console.log(`版本号: ${browserInfo.version}`); - console.log(`完整用户代理: ${browserInfo.userAgent}`); + // const browserInfo = getBrowserInfo(); + // console.log(`浏览器: ${browserInfo.browser}`); + // console.log(`版本号: ${browserInfo.version}`); + // console.log(`完整用户代理: ${browserInfo.userAgent}`); // console.log('App Show') }, onHide: function () { diff --git a/src/api/request.js b/src/api/request.js index 38c295ba..3e4ac23a 100644 --- a/src/api/request.js +++ b/src/api/request.js @@ -10,7 +10,8 @@ export const get_base_url = (url = '') => { // #ifdef H5 if (url) { let _str = (url.split('/')[0] || url.split('/')[1])?.toUpperCase() - return ENV[`VITE_APP_BASE_H5_API_Url_${_str}`] || ENV.VITE_APP_BASE_H5_API_Url || ENV.VITE_APP_BASE_API_Url + return ENV[`VITE_APP_BASE_H5_API_Url_${_str}`] || ENV.VITE_APP_BASE_H5_API_Url || ENV + .VITE_APP_BASE_API_Url } else { return ENV.VITE_APP_BASE_H5_API_Url || ENV.VITE_APP_BASE_API_Url } diff --git a/src/components/examination/question.vue b/src/components/examination/question.vue index c07cb837..5e7917b6 100644 --- a/src/components/examination/question.vue +++ b/src/components/examination/question.vue @@ -81,6 +81,7 @@ import { computed, unref, ref, toRefs, watch, onMounted, nextTick } from 'vue'; import { onUnload } from '@dcloudio/uni-app'; import { useAudioStore } from '@/store/audioStore'; + import {downloadFile} from '@/api/common.js' const props = defineProps({ dataInfo: { default: () => ({}), @@ -210,11 +211,17 @@ // 赋值显示 voiceTime.value = displayTime + 's'; }); - watch( () => props.dataInfo.voicePath, (newVal) => { - audioStore.setAudioSrc(newVal); + if(newVal === '' && props.dataInfo.ossKey) { // 去下载oss内容 + console.log('去下载oss内容'); + downloadFile(props.dataInfo.ossKey).then(res => { + audioStore.setAudioSrc(res.tempFilePath); + }) + } else { + audioStore.setAudioSrc(newVal); + } }, { deep: true, immediate: true } ); diff --git a/src/components/examination/subject.vue b/src/components/examination/subject.vue index fea4f974..d9d1844c 100644 --- a/src/components/examination/subject.vue +++ b/src/components/examination/subject.vue @@ -270,9 +270,11 @@ // 点击答题 const click_option = (analysisVo) => { if (props.isPreview || !props.clearResult) return; + // 无论什么类型如果表里已经有了,再次点击就是弹出 if (item_answer.value.includes(analysisVo.itemId)) { item_answer.value = item_answer.value.filter((id) => id !== analysisVo.itemId); + modelValue.value = item_answer.value; if (!['study'].includes(props.mode)) { muCheckbox('choose'); } @@ -280,21 +282,25 @@ // 单选 // 单选插入,并且移除其他 item_answer.value[0] = analysisVo.itemId; + modelValue.value = item_answer.value; muCheckbox('choose'); } else if (props.item.qnsTyp === 'MU') { // 多选题 // 多选直接插入 item_answer.value.push(analysisVo.itemId); + modelValue.value = item_answer.value; if (!['study'].includes(props.mode)) { muCheckbox('choose'); } + } else if (props.item.qnsTyp === 'JD') { // 判断题 // 判断插入,并且移除其他 item_answer.value = [analysisVo.itemId]; + modelValue.value = item_answer.value; muCheckbox('choose'); } - modelValue.value = item_answer.value; + }; const muBtnClick = () => { if(item_answer.value.length === 0){ diff --git a/src/pages/courseRecord/components/studyRecordItem.vue b/src/pages/courseRecord/components/studyRecordItem.vue index 4a242543..491aef22 100644 --- a/src/pages/courseRecord/components/studyRecordItem.vue +++ b/src/pages/courseRecord/components/studyRecordItem.vue @@ -76,7 +76,7 @@ // 跳转到详情 const click_list_item = (list_item) => { common.navigateTo( - `/pages/courseRecord/courseStudyRecordDetail?stdyId=${list_item.stdyBatch}&crsName=${item.value.crsName || ''}` + `/pages/courseRecord/courseStudyRecordDetail?stdyId=${list_item.stdyId}&crsName=${item.value.crsName || ''}` ); }; diff --git a/src/pages/examination/index.vue b/src/pages/examination/index.vue index 6e2bb0a8..f9f996ee 100644 --- a/src/pages/examination/index.vue +++ b/src/pages/examination/index.vue @@ -52,7 +52,7 @@ { if (type === 'mark') { topicList[questionNumber.value]['mark'] = !topicList[questionNumber.value]['mark']; @@ -277,15 +278,11 @@ // 问答题点击重答 topic.value.my_answer = {}; topic.value.es_status = ''; // 取消转圈 - } else if (type === 'answer') { - //多选点击按钮答题 - if (params.qnsTyp === 'MU') { - hand_in_paper_cache() - } + hand_in_paper_cache(); } else if (type === 'choose') { - //单选判断点击选项答题 - if (['JD', 'SN'].includes(params.qnsTyp)) { - hand_in_paper_cache() + //单选判断点击选项答题,为了缓存,考试这里多选没按钮,也是按照一个选项一个选项的触发 + if (['JD', 'SN', 'MU'].includes(params.qnsTyp)) { + hand_in_paper_cache(); } } }; @@ -312,6 +309,7 @@ ossAddr: _res.body.ossFileAddr, voicePath: voicePath }; + hand_in_paper_cache(); } } }) @@ -324,14 +322,49 @@ topic.value.my_answer = { anserResult: submitObj // 正确答案文字内容 }; + hand_in_paper_cache(); } }; - + + let examinationAnswerCacheKey; + const answerCacheList = ref({}); + const setAnswerCacheList = (value) => { + console.log('触发变化', value); + answerCacheList.value = value; + common.setValue(examinationAnswerCacheKey, value); + }; + // const answerCacheList = computed({ + // get() { + // const cacheList = common.getValue(examinationAnswerCacheKey); + // if (cacheList) return cacheList; + // return {}; + // }, + // set(value) { + // console.log('触发变化', value); + // common.setValue(examinationAnswerCacheKey, value); // 补充键参数 + // } + // }); + // 添加试题答案缓存 const addTopicAnswerCache = () => { - - } - + const my_answer = topic.value.my_answer; + const qnsId = topic.value.qnsId; + console.log('asdsadas', answerCacheList.value); + const newCache = { ...answerCacheList.value }; + if(topic.value.qnsTyp === 'ES') { // 问答题特殊处理 + if('anserResult' in my_answer && my_answer.anserResult !== '') { + newCache[qnsId] = {...my_answer, voicePath:''}; + } else { + delete newCache[qnsId]; + } + } else { + newCache[qnsId] = my_answer; + } + + setAnswerCacheList(newCache); + // answerCacheList.value = newCache; + }; + // 初始化时检查 onLoad(() => { const examination = getPageCache('examination'); @@ -347,20 +380,58 @@ paperData.papersId = examination.papersId; paperData.limitTm = examination.limitTm; paperData.papersName = examination.papersName; - // 获取上一次答题的缓存 - // const answerCacheList = common.getValue('') + paperData.isCacheExam = examination.isCacheExam || 'N'; + mode = paperData.examId ? 'PAPERS' : 'CRS'; // 课程考试CRS,考试中心考试PAPERS + // 设置缓存的键的名称 + const suffix = mode === 'PAPERS' ? paperData.examId : paperData.crsId; + examinationAnswerCacheKey = 'examinationAnswerCache' + suffix; + answerCacheList.value = common.getValue(examinationAnswerCacheKey) ?? {}; + console.log('刚进入', answerCacheList.value); topicList.push( - ...examination.qnsInfoVos.map((res) => ({ - ...res, - mark: false, - my_answer: [] - })) + ...examination.qnsInfoVos.map((res) => { + const es_status = + paperData.isCacheExam === 'N' + ? '' + : res.qnsId in answerCacheList.value + ? 'ossKey' in answerCacheList.value[res.qnsId] + ? '02' + : '01' + : ''; + const my_answer = + paperData.isCacheExam === 'N' + ? [] + : res.qnsId in answerCacheList.value + ? answerCacheList.value[res.qnsId] + : []; + return { + ...res, + mark: false, + es_status: es_status, + my_answer: my_answer + }; + }) ); setupKeyboardHeightListener((height) => { popup_input_bottom.value = `${height}px`; }); }); + onMounted(() => { + nextTick(() => { + if (paperData.isCacheExam === 'Y') { + // 代表是缓存来的 + dialogRef.value.open({ + title: '中途退出考试,请继续答题', + buttonList: [ + { + key: 'revert', + name: '继续答题', + style: style_button_1 + } + ] + }); + } + }); setTimeout(() => { countDownRef.value.start(); }, 500); @@ -489,16 +560,17 @@ }; // 提交当前所有填写了答案的题的缓存 const hand_in_paper_cache = () => { + // 获取当前题目 + addTopicAnswerCache(); + const answerDtoList = getAnswerDtoList(); commitPaperCache({ examTyp: paperData.examId ? 'PAPERS' : 'CRS', papersId: paperData.papersId, - examId: paperData.examId??'', + examId: paperData.examId ?? '', execId: paperData.execId, answerDtoStr: JSON.stringify(answerDtoList) - }).then((res) => { - console.log('提交当前所有填写了答案的题的缓存222222', res); - }); + }).then((res) => {}); }; // 执行交卷 const hand_in_paper = (strs = '') => { @@ -514,7 +586,7 @@ // 这里是考试中心考试 func = commitPaperExam({ papersId: paperData.papersId, - examId: paperData.examId??'', + examId: paperData.examId ?? '', execId: paperData.execId, examLenTm: examLenTm, answerDtoStr: JSON.stringify(answerDtoList) @@ -528,12 +600,14 @@ }); } func.then((res) => { + // 交卷成功,清除缓存 + common.setValue(examinationAnswerCacheKey, null); // 考试完成事件 uni.$emit('exam_completed'); // 判断是否需要查分 const flagQueryDetail = res.body.flagQueryDetail === '' ? res.body.flagQuery : res.body.flagQueryDetail; common.redirectTo( - `/pages/examination/result?execId=${res.body.execId}&flagQuery=${res.body.flagQuery}&flagQueryDetail=${flagQueryDetail}&examLenTm=${examLenTm}&papersName=${paperData.papersName}&papersId=${paperData.papersId}&mode=${mode}&crsId=${paperData.crsId}` + `/pages/examination/result?execId=${res.body.execId}&flagQuery=${res.body.flagQuery}&flagQueryDetail=${flagQueryDetail}&papersName=${paperData.papersName}&papersId=${paperData.papersId}&mode=examination&crsId=${paperData.crsId}` ); }) .catch((res) => { diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 1eaeb9d0..1e1b6076 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -728,7 +728,7 @@ font-style: normal; display: flex; align-items: center; - + :deep(.uv-notice-bar) { padding: 9px 2px; } diff --git a/src/pages/index/preview.vue b/src/pages/index/preview.vue index 464dd652..1cadf8db 100644 --- a/src/pages/index/preview.vue +++ b/src/pages/index/preview.vue @@ -67,6 +67,7 @@ export default { let _id = data?.fileId let fileUrl = base_url + '/traask/traFilePreview/' + _id this.showUrl = this.viewerUrl + '?url=' + fileUrl + console.log(this.showUrl) this.showView = true } }