diff --git a/.env.development b/.env.development index fa6a7917..3cd434a5 100644 --- a/.env.development +++ b/.env.development @@ -6,16 +6,16 @@ ENV = 'development' # VITE_APP_BASE_API_Url = 'https://aits.jlbank.com.cn:7001' -# VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' +VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' -VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' +# VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' # VITE_APP_BASE_API_Url = 'http://192.168.247.200' # VITE_APP_BASE_API_Url = 'http://aitscdn.jlbank.com.cn:7001' # VITE_APP_BASE_API_Url = 'http://192.168.108.129' # dev -# VITE_APP_BASE_API_Url = 'http://25.18.122.65:7001' +#VITE_APP_BASE_API_Url = 'http://25.18.122.65:7001' # sit @@ -40,5 +40,5 @@ VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' # VITE_APP_BASE_H5_API_Url_TRAAPP = 'http://25.64.32.158:9601' # VITE_APP_BASE_H5_API_Url_TEST = 'http://127.0.0.1:5000' # VITE_APP_BASE_H5_API_Url_TRAEXAM = 'http://192.168.247.200' -# VITE_APP_BASE_H5_API_Url_TRAASK = 'http://25.64.32.154:9605' +# VITE_APP_BASE_H5_API_Url_TRASTUDY = 'http://25.64.32.154:9602' diff --git a/src/components/points-and-badge/check-in.vue b/src/components/points-and-badge/check-in.vue index ec8fcadc..ac5a731d 100644 --- a/src/components/points-and-badge/check-in.vue +++ b/src/components/points-and-badge/check-in.vue @@ -119,13 +119,15 @@ emits( 'checkInFun', true, - [{ changePoints: 5 }], - [ - { - pointsBadgeImg: '/traoss/tras3/show/S3F0250181220722025110713501700000661177', - pointsBadgeName: '黄金徽章' - } - ] + res.body.points, + res.body.pointsBadges, + // [{ changePoints: 5 }], + // [ + // { + // pointsBadgeImg: '/traoss/tras3/show/S3F0250181220722025110713501700000661177', + // pointsBadgeName: '黄金徽章' + // } + // ] ); }) .catch((err) => { @@ -208,7 +210,7 @@ const open = (checkInToday, days) => { isSigned.value = checkInToday === 'Y' ? true : false; // 今日签到状态 - isSigned.value = false; // 今日签到状态 + // isSigned.value = false; // 今日签到状态 continuousDay.value = days; // 连续签到 // 示例:X=10时,以"10天前"为第1天,生成35天列表 try { diff --git a/src/components/points-and-badge/usePointsAndBadge.js b/src/components/points-and-badge/usePointsAndBadge.js index d84d107d..2a12ca46 100644 --- a/src/components/points-and-badge/usePointsAndBadge.js +++ b/src/components/points-and-badge/usePointsAndBadge.js @@ -26,67 +26,94 @@ import { export default function usePointsAndBadge() { const badgeRef = ref(null); const pointsRef = ref(null); - - const pointAndBadgesRun = async (type, taskId = null, complete = () => {}) => { - try { - // 调用积分接口 - console.log('调用积分接口'); - const res = await addPointsByTask({ - type, - taskId - }); - if (type === '04') { // 完成课程练习,自己处理逻辑 - return { - points: res.body.points, - message: res.body.message, - taskBadges: res.body.taskBadges ?? [], - } - } - console.log('调用积分接口', res); - console.log('pointsRefpointsRef', pointsRef.value); - // 06AI问答 不弹出积分窗口 - if (type === '06') { - if (res.body.pointsBadges.length > 0) { - nextTick(() => { - setTimeout(() => { - badgeRef.value.open(res.body.points, res.body.pointsBadges, () => { - badgeRef.value.close() - complete(true, '', res); - }); - }, pop_up_time); - }); - } else { - complete(true, '', res); - } - return - } - // 弹出积分窗口 - pointsRef.value.open(res.body.points, res.body.pointsBadges, (status, pointsList, badgesList) => { - pointsRef.value.close() - if (badgesList.length > 0) { - nextTick(() => { - setTimeout(() => { - badgeRef.value.open(pointsList, badgesList, () => { - badgeRef.value.close() - complete(true, '积分获取成功', res); - }); - }, pop_up_time); - }); - } else { + /** + * 处理积分和徽章弹窗逻辑(提取的独立方法) + * @param {number} points - 积分值 + * @param {Array} pointsBadges - 积分关联的徽章列表 + * @param {Function} complete - 完成回调函数 + * @param {any} res - 接口返回数据 + */ + const handlePointsBadgePopup = (points, pointsBadges, complete = () => {}, res = {}) => { + // AI问答仅弹徽章弹窗 + if (points?.length > 0) { + // 普通场景:先弹积分弹窗,再弹徽章弹窗 + pointsRef.value?.open(points, pointsBadges, (status, pointsList, badgesList) => { + pointsRef.value.close(); + // 有徽章则弹徽章弹窗,否则直接完成 + if (badgesList?.length > 0) { + nextTick(() => { + setTimeout(() => { + badgeRef.value.open(pointsList, badgesList, () => { + badgeRef.value.close(); + complete(true, '积分获取成功', res); + }); + }, pop_up_time); + }); + } else { + complete(true, '积分获取成功', res); + } + }); + } else if (pointsBadges?.length > 0) { + badgeRef.value.open([], pointsBadges, () => { + badgeRef.value.close(); complete(true, '积分获取成功', res); - } - }); - // complete(true, '积分获取成功', res); - } catch (error) { - // console.error(`类型${type}积分获取失败:`, error); - // console.log('积分获取失败') - complete(false, '积分获取失败', error); - } - }; + }); + } + }; - return { - pointAndBadgesRun, - badgeRef, - pointsRef - }; -} \ No newline at end of file + /** + * 积分和徽章处理主方法 + * @param {string} type - 任务类型(04:课程练习,06:AI问答,其他:普通任务) + * @param {string|null} taskId - 任务ID + * @param {Function} complete - 完成回调(status, message, data) + */ + const pointAndBadgesRun = async (type, taskId = null, complete = () => {}) => { + + try { + console.log('调用积分接口'); + const res = await addPointsByTask({ + type, + taskId + }); + + // 防御性处理:确保res.body存在 + if (!res?.body) { + complete(false, '积分接口返回数据异常', res); + return; + } + const { + points, + pointsBadges, + message = '' + } = res.body; + + // 分支逻辑:按类型处理 + switch (type) { + case '04': // 04:课程练习,自定义返回逻辑,不弹弹窗 + complete(true, '', res.body); // 补充回调,避免调用方等待 + return; + case '06': // 06:AI问答,仅弹徽章弹窗 + if (pointsBadges?.length > 0) { + handlePointsBadgePopup(points, pointsBadges, complete, res); + } else { + complete(true, '', res); + } + return; + // 其他类型:弹积分+徽章弹窗 + default: + handlePointsBadgePopup(points, pointsBadges, complete, res); + return; + } + } catch (error) { + // 细化错误信息:区分网络错误/接口错误 + const errorMsg = error?.message || '积分获取失败'; + complete(false, `积分获取失败:${errorMsg}`, error); + } + }; + return { + pointAndBadgesRun, + handlePointsBadgePopup, + badgeRef, + pointsRef + }; + } \ No newline at end of file diff --git a/src/composables/useCheckIn.js b/src/composables/useCheckIn.js new file mode 100644 index 00000000..9fd831cd --- /dev/null +++ b/src/composables/useCheckIn.js @@ -0,0 +1,16 @@ +import { queryCheckIn } from '@/api/pointsAndRank.js'; +import common from '@/common/common'; + +export default function useCheckIn() { + const getTodayCheckInStatus = () => { + // common.getValue() + } + // 获取今日是否签到消息 + const getCheckInInfo = () => { + // todo 后续加防止重复多次请求逻辑 + queryCheckIn().then(({ body }) => { + user_info.checkInToday = body.checkInToday; // 今日是否签到 + user_info.checkInDays = body.days; // 连续签到天数 + }); + }; +} \ No newline at end of file diff --git a/src/pages/competition/index.vue b/src/pages/competition/index.vue index ac0b1980..d8e40b43 100644 --- a/src/pages/competition/index.vue +++ b/src/pages/competition/index.vue @@ -50,6 +50,11 @@ fetchFunction: queryTraCompetitionInfoPaging }); const goto_competition = (item) => { + if (item.type !== '00') { + if(item.type === '01') common.msg('竞赛未开始'); + if(item.type === '02') common.msg('竞赛已结束'); + return; + } common.loading(); const result = Promise.all([queryTestPapers({ comId: item.comId }), queryTraUserAnonyByUserId(), queryOrgTree()]); result @@ -71,8 +76,6 @@ common.msg('网络繁忙,请稍后再试!'); }); }; - onLoad(() => {}); - onUnload(() => {});