diff --git a/.env.development b/.env.development index 46718ed4..ad663b78 100644 --- a/.env.development +++ b/.env.development @@ -15,7 +15,6 @@ 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 = 'https://aitstest.jlbank.com.cn:7002' diff --git a/src/api/request.js b/src/api/request.js index 3e09b012..38c295ba 100644 --- a/src/api/request.js +++ b/src/api/request.js @@ -98,12 +98,12 @@ export default function request({ const res = response.data if (res?.rtnCode === '0000') { return resolve(res) - } else if (res?.rtnCode === '0001') { // 为前后端约定不公共拦截的码值(王洋洋20250830定) + } else if (res?.rtnCode === '1001') { // 为前后端约定不公共拦截的码值(小树20250903定) return reject(res) } else if (res?.rtnCode === '0002' && res?.message) { if (toastErrors) { common.msg(res.message) - } + } return reject(response) } //到这里下面全是异常的处理 diff --git a/src/components/examination/subject.vue b/src/components/examination/subject.vue index 4d23ef20..fea4f974 100644 --- a/src/components/examination/subject.vue +++ b/src/components/examination/subject.vue @@ -69,7 +69,7 @@ class="send_evaluate" :custom-style="customStyle" :throttleTime="300" - @click="muCheckbox('answer')" + @click="muBtnClick" :hairline="false" > 确定 @@ -112,6 +112,7 @@ import questionVue from './question.vue'; import { markIcon, feedbackIcon } from '@/common/imgSvg'; import { SUBJECT_TYPE } from '@/enum.js'; + import common from '@/common/common'; // 多选的确定按钮的样式 const customStyle = { @@ -295,6 +296,13 @@ } modelValue.value = item_answer.value; }; + const muBtnClick = () => { + if(item_answer.value.length === 0){ + common.msg('请至少选择一个选项!') + return + } + muCheckbox('answer') + } const muCheckbox = (type = 'answer') => { emit('subject_click', type, { qnsTyp: props.item.qnsTyp, diff --git a/src/pages/courseDetail/index.vue b/src/pages/courseDetail/index.vue index d13730d8..ae540e68 100644 --- a/src/pages/courseDetail/index.vue +++ b/src/pages/courseDetail/index.vue @@ -261,6 +261,7 @@ } }; onMounted(async () => { + // 监听评论列表更新 uni.$on('refresh_comment_data', () => { commentRef.value?.getData('submit'); tabAct.value = 2; @@ -276,13 +277,14 @@ }); onUnload(() => { uni.$off('refresh_comment_data'); + + // 如果收藏变了,并且上一页是收藏页,更新收藏列表 if (form.value.collectId !== collectId.value) { const pages = getCurrentPages(); if (pages.length >= 2) { const prevPage = pages[pages.length - 2]; if (prevPage.route === 'pages/favorites/index') { - // 更新 - uni.$emit('refresh_favorites_data', { + uni.$emit('refresh_favorites_list', { type: 'course', state: !!form.value.collectId, // 最终是收藏了还是取消了 old: collectId.value, // 进入时候的收藏id diff --git a/src/pages/examination/result.vue b/src/pages/examination/result.vue index 7c9dab2b..67bf0957 100644 --- a/src/pages/examination/result.vue +++ b/src/pages/examination/result.vue @@ -3,7 +3,7 @@ 考试结算 - + @@ -105,11 +105,7 @@ 您暂无权限查看此试卷详情 - + @@ -125,7 +121,7 @@ import { onLoad, onUnload } from '@dcloudio/uni-app'; import { ref, reactive, computed, onMounted, nextTick, getCurrentInstance } from 'vue'; import { queryPaperExamScore, queryCrsExamScore } from '@/api/examination.js'; - + import Subject from '@/components/examination/subject.vue'; import common from '@/common/common'; const pass_status = ref(0); @@ -162,10 +158,10 @@ // 答题卡判断每道题的状态 const completedListStatus = computed(() => { return topicList.map((res) => { - if(res.judgeResult === 'P') { - return 'success' - }else if(res.judgeResult === 'U' && res.anserResult !== '') { - return 'error' + if (res.judgeResult === 'P') { + return 'success'; + } else if (res.judgeResult === 'U' && res.anserResult !== '') { + return 'error'; } }); }); @@ -220,10 +216,9 @@ } }; const goto_back = () => { - common.navigateBack() + common.navigateBack(); }; - const getStatusClass = (index) => { const remainder = index % 3; if (remainder === 0) return 'in_progress'; @@ -239,24 +234,16 @@ const timerId = ref(null); const get_result = () => { - // 重置计数器(首次调用时) - if (requestCount.value === 0) { - requestCount.value = 0; - } - // 检查是否已达到最大请求次数 if (requestCount.value >= 15) { console.log('已达到最大请求次数(15次),停止请求'); + requestCount.value = 0; return; } - let req - if (result.crsId !== '') { // 试卷跳入 - req = queryCrsExamScore - } else { - req = queryPaperExamScore - } - - timerId.value = setTimeout(() => { + // 确定请求方法 + const req = result.crsId !== '' ? queryCrsExamScore : queryPaperExamScore; + // 抽离请求逻辑为单独函数 + const fetchData = () => { // 每次请求前计数器+1 requestCount.value++; req({ @@ -264,13 +251,14 @@ }) .then(({ body }) => { console.log(`第${requestCount.value}次请求返回`, body); - if (body.isWait === 'Y') { // 未完成且未达上限,继续请求 if (requestCount.value < 15) { - get_result(); + // 这里用定时器延迟下次请求 + timerId.value = setTimeout(fetchData, 2000); } else { console.log('已达到最大请求次数,停止等待'); + requestCount.value = 0; } } else if (body.isWait === 'N') { // 完成请求,处理结果 @@ -282,7 +270,7 @@ result.examLenTm = body.examLenTm; } topicList.push(...body.qnsInfoVo); - + requestCount.value = 0; // 触发考试完成事件 } }) @@ -290,10 +278,15 @@ console.error('请求失败', err); // 请求失败也计入次数,避免无限重试 if (requestCount.value < 15) { - get_result(); + timerId.value = setTimeout(fetchData, 2000); + } else { + // 失败次数达上限,重置计数器 + requestCount.value = 0; } }); - }, 2000); + }; + // 立即执行第一次请求 + fetchData(); }; // 初始化时检查 @@ -371,7 +364,6 @@ margin-left: $bg-margin-left; } - .scroll-Y { // max-height: calc(100vh - var(--status-bar-height) - 70rpx - 70rpx - 40rpx - 64rpx - 68rpx - 60rpx); height: calc(100vh - var(--status-bar-height) - 70rpx - 10rpx); @@ -458,7 +450,7 @@ width: 80rpx; margin: 0 auto; border-radius: 10rpx; - background-color: #FCE8E9; + background-color: #fce8e9; } .sheet_table { @@ -479,25 +471,23 @@ .circle.success { // 已完成 - background-color: #E7F8ED; - border-color: #15B859; - color: #15B859; + background-color: #e7f8ed; + border-color: #15b859; + color: #15b859; } - + .circle.error { // 已完成 - background-color: #FCE8E9; - border-color: #F5212D; - color: #F5212D; + background-color: #fce8e9; + border-color: #f5212d; + color: #f5212d; } - + .current { // background-color: rgba(0, 102, 255, 0.6); // border-color: #0066ff; // color: #ffffff; } - - } // 主内容框 diff --git a/src/pages/favorites/components/favoritesCourse.vue b/src/pages/favorites/components/favoritesCourse.vue index d1836fff..56a99ce1 100644 --- a/src/pages/favorites/components/favoritesCourse.vue +++ b/src/pages/favorites/components/favoritesCourse.vue @@ -116,8 +116,14 @@ getData('first'); }; + const updateData = (item) => { + console.log('收藏的updateData'); + + }; + defineExpose({ getData, + updateData, refreshData }); diff --git a/src/pages/favorites/components/favoritesTask.vue b/src/pages/favorites/components/favoritesTask.vue index 45c21eaa..546974a8 100644 --- a/src/pages/favorites/components/favoritesTask.vue +++ b/src/pages/favorites/components/favoritesTask.vue @@ -144,9 +144,19 @@ console.log('子组件refreshData'); }; + const updateData = (item) => { + console.log('收藏的updateData'); + const index = data_list.findIndex((res) => res.taskId === item.taskId); + console.log('updateData', index, item); + if (index !== -1) { + data_list[index] = item; + } + }; + defineExpose({ getData, - refreshData + refreshData, + updateData }); diff --git a/src/pages/favorites/index.vue b/src/pages/favorites/index.vue index e6f24736..647d0a70 100644 --- a/src/pages/favorites/index.vue +++ b/src/pages/favorites/index.vue @@ -82,17 +82,28 @@ } ); // 这里的immediate会在onMounted之后执行 }); - onLoad(async () => { - uni.$on('refresh_favorites_data', (params) => { + onLoad(() => { + // 里面取消收藏后重新刷新列表 + uni.$on('refresh_favorites_list', (params) => { if (params.type === 'course') { courseRef.value?.refreshData(params); } else if (params.type === 'task') { taskRef.value?.refreshData(params); } }); + // 完成任务后更新列表单条信息 + uni.$on('refresh_favorites_data', (res) => { + console.log('列表监听里面学习完成后更新任务历程', res); + if (tabAct.value === 0) { + courseRef.value?.updateData(res); + } else if (tabAct.value === 1) { + taskRef.value?.updateData(res); + } + }); }); onUnload(() => { uni.$off('refresh_favorites_data'); + uni.$off('refresh_favorites_list'); }); diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 229f329a..a580dd90 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -438,7 +438,7 @@ return; } const userInfo = getUserInfo(); - console.log('首页userInfo', userInfo); + // console.log('首页userInfo', userInfo); if (userInfo) { mascotInfo.value = userInfo?.mascotInfo; } @@ -462,17 +462,13 @@