diff --git a/.env.development b/.env.development index 1ff2639c..8904c30c 100644 --- a/.env.development +++ b/.env.development @@ -9,21 +9,20 @@ ENV = 'development' VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' # app入口 -VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' +VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' #VITE_APP_BASE_API_Url = 'http://25.16.122.65:7001' #VITE_APP_BASE_API_Url = 'http://25.16.122.91:9786' #VITE_APP_BASE_API_Url = 'http://25.18.122.66:9786' -# h5专用地址 +# h5专用地址x2 # 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:7001' - +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' +# 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' @@ -32,7 +31,7 @@ VITE_APP_BASE_H5_API_Url = 'http://25.18.122.65:7001' # 任东 # 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/src/pages/examination/index.vue b/src/pages/examination/index.vue index f9f996ee..c094d706 100644 --- a/src/pages/examination/index.vue +++ b/src/pages/examination/index.vue @@ -351,9 +351,10 @@ 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:''}; + if (topic.value.qnsTyp === 'ES') { + // 问答题特殊处理 + if ('anserResult' in my_answer && my_answer.anserResult !== '') { + newCache[qnsId] = { ...my_answer, voicePath: '' }; } else { delete newCache[qnsId]; } @@ -385,24 +386,85 @@ // 设置缓存的键的名称 const suffix = mode === 'PAPERS' ? paperData.examId : paperData.crsId; examinationAnswerCacheKey = 'examinationAnswerCache' + suffix; - answerCacheList.value = common.getValue(examinationAnswerCacheKey) ?? {}; - console.log('刚进入', answerCacheList.value); + answerCacheList.value = common.getValue(examinationAnswerCacheKey); + if (typeof answerCacheList.value !== 'object') { + answerCacheList.value = {}; + paperData.isCacheExam = 'N' + } + topicList.push( ...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] - : []; + // const es_status = + // paperData.isCacheExam === 'N' + // ? '' + // : res.qnsId in answerCacheList.value + // ? 'ossKey' in answerCacheList.value[res.qnsId] + // ? '02' + // : '01' + // : ''; + const es_status = (() => { + try { + // 基础数据校验 + if (!paperData || typeof paperData !== 'object') return ''; + if (paperData.isCacheExam === 'N') return ''; + + // 缓存列表校验 + if (!answerCacheList?.value || typeof answerCacheList.value !== 'object') return ''; + + // 问题ID校验 + if (!res || !res.qnsId || typeof res.qnsId !== 'string') return ''; + + // 检查缓存中是否存在该问题 + if (!(res.qnsId in answerCacheList.value)) return ''; + + const cachedAnswer = answerCacheList.value[res.qnsId]; + if (!cachedAnswer || typeof cachedAnswer !== 'object') return '01'; + + // 最终判断 + return 'ossKey' in cachedAnswer ? '02' : '01'; + } catch (error) { + // 捕获所有意外错误,如变量未定义、类型异常等 + console.error('获取es_status出错:', error); + return ''; // 错误情况下的默认值,可根据业务调整 + } + })(); + // const my_answer = + // paperData.isCacheExam === 'N' + // ? [] + // : res.qnsId in answerCacheList.value + // ? answerCacheList.value[res.qnsId] + // : []; + const my_answer = (() => { + try { + // 基础数据校验 + if (!paperData || typeof paperData !== 'object') { + return []; + } + // 如果不需要缓存,直接返回空数组 + if (paperData.isCacheExam === 'N') { + return []; + } + // 校验缓存列表是否存在且为对象类型 + if (!answerCacheList?.value || typeof answerCacheList.value !== 'object') { + return []; + } + // 校验问题ID是否有效 + if (!res || typeof res.qnsId === 'undefined') { + return []; + } + // 检查缓存中是否存在该问题的答案 + if (res.qnsId in answerCacheList.value) { + const cachedAnswer = answerCacheList.value[res.qnsId]; + // 确保返回值是数组类型(根据原逻辑推测应该返回数组) + return Array.isArray(cachedAnswer) ? cachedAnswer : []; + } + // 缓存中不存在时返回空数组 + return []; + } catch (error) { + console.error('获取my_answer出错:', error); + return []; // 任何异常都返回空数组,保证程序稳定性 + } + })(); return { ...res, mark: false, diff --git a/src/pages/learningTasks/components/content.vue b/src/pages/learningTasks/components/content.vue index 494044d3..098ce5e3 100644 --- a/src/pages/learningTasks/components/content.vue +++ b/src/pages/learningTasks/components/content.vue @@ -65,7 +65,6 @@ }; const searchText = ref(''); const search = (value, state) => { - console.log('value', value, state); total.value = -1; searchText.value = value; if (state) { @@ -76,6 +75,12 @@ data_list.length = 0; } }; + const clear = (state) => { + total.value = -1; + page.value = 1; + data_list.length = 0; + }; + const updateData = (item) => { const index = data_list.findIndex((res) => res.taskId === item.taskId); @@ -88,7 +93,8 @@ defineExpose({ getData, search, - updateData + updateData, + clear }); diff --git a/src/pages/learningTasks/details.vue b/src/pages/learningTasks/details.vue index 2e467789..650de210 100644 --- a/src/pages/learningTasks/details.vue +++ b/src/pages/learningTasks/details.vue @@ -213,17 +213,17 @@ } }; onLoad((e) => { - collectId.value = e.collectId || ''; const learning_tasks_details = getPageCache('learning_tasks_details'); Object.assign(detailData, { ...learning_tasks_details }); + collectId.value = learning_tasks_details.collectionId || ''; getData(); const updateFun = () => { setTimeout(() => { console.log('详情监听里面学习完成后更新任务历程'); queryTraTaskInfoByTaskId({ taskId: detailData.taskId }).then(({ body }) => { - uni.$emit('refresh_favorites_data', body); + uni.$emit('refresh_tasks_data', body); Object.assign(detailData, { ...body }); @@ -255,6 +255,7 @@ }); } else if (prevPage.route === 'pages/learningTasks/index') { // 学习任务页跳入,更新外部列表否则下次列表数据还是老的 + console.log('学习任务页跳入,更新外部列表否则下次列表数据还是老的'); uni.$emit('refresh_tasks_list', detailData); } } diff --git a/src/pages/learningTasks/index.vue b/src/pages/learningTasks/index.vue index c6d6a3aa..18e406f0 100644 --- a/src/pages/learningTasks/index.vue +++ b/src/pages/learningTasks/index.vue @@ -69,11 +69,9 @@ tabAct.value = item.detail.current; }; const search = (value) => { - listItemRefs.value[0]?.search(value, tabAct.value === 0); listItemRefs.value[1]?.search(value, tabAct.value === 1); listItemRefs.value[2]?.search(value, tabAct.value === 2); - }; onMounted(() => { @@ -91,14 +89,28 @@ onLoad(() => { uni.$on('refresh_tasks_list', (res) => { - // 更新列表内单挑item数据 - if (typeof listItemRefs.value[tabAct.value]?.updateData === 'function') { - listItemRefs.value[tabAct.value]?.updateData(res); + console.log('refresh_tasks_list'); + listItemRefs.value[0]?.updateData(res); + listItemRefs.value[1]?.updateData(res); + listItemRefs.value[2]?.updateData(res); + }); + // 完成任务后更新列表单条信息 + uni.$on('refresh_tasks_data', (res) => { + console.log('refresh_tasks_data'); + listItemRefs.value[0]?.updateData(res); + listItemRefs.value[1]?.clear(); + listItemRefs.value[2]?.clear(); + listItemRefs.value[tabAct.value]?.getData('first'); + if (tabAct.value === 0) { + courseRef.value?.updateData(res); + } else if (tabAct.value === 1) { + taskRef.value?.updateData(res); } }); }); onUnload(() => { uni.$off('refresh_tasks_list'); + uni.$off('refresh_tasks_data'); }); diff --git a/src/pages/testingHall/components/content.vue b/src/pages/testingHall/components/content.vue index 825f94d8..d4e8b711 100644 --- a/src/pages/testingHall/components/content.vue +++ b/src/pages/testingHall/components/content.vue @@ -92,10 +92,15 @@ data_list.length = 0; } }; - + const clear = (state) => { + total.value = -1; + page.value = 1; + data_list.length = 0; + }; defineExpose({ getData, - search + search, + clear });