diff --git a/.env.development.yh b/.env.development.yh index 69c6c09e..37f4a114 100644 --- a/.env.development.yh +++ b/.env.development.yh @@ -4,8 +4,8 @@ ENV = 'development.yh' VITE_APP_BASE_API_Url = 'http://25.18.122.65:7001' -VITE_APP_BASE_H5_API_Url = 'http://25.18.122.91:9786' +# VITE_APP_BASE_H5_API_Url = 'http://25.18.122.91:9786' # VITE_APP_BASE_H5_API_Url_TRAEXAM = 'http://25.64.32.154:9604' -VITE_APP_BASE_H5_API_Url_TRAPRACTICE = 'http://25.64.32.156:9603' +# VITE_APP_BASE_H5_API_Url_TRAPRACTICE = 'http://25.64.32.156:9603' # VITE_APP_BASE_H5_API_Url_TRAAPP = 'http://25.64.32.154:9601' diff --git a/src/components/points-and-badge/usePointsAndBadge.js b/src/components/points-and-badge/usePointsAndBadge.js index 63cd6caa..194ff8d1 100644 --- a/src/components/points-and-badge/usePointsAndBadge.js +++ b/src/components/points-and-badge/usePointsAndBadge.js @@ -16,87 +16,26 @@ import { addPointsByTask } from '@/api/pointsAndRank.js' import { - ref, nextTick + ref, + nextTick } from 'vue' import { pop_up_time } from '@/enum'; -// 徽章类型配置:映射类型编码、参数键、规则描述 -const typeConfig = { - '02': { - name: '完成课程学习', - paramsKey: 'crsId', - rule: '首次完成1分,每天最多5分' - }, - '03': { - name: '通过课程考试', - paramsKey: 'crsId', - rule: '首次完成1分,每天最多5分' - }, - '04': { - name: '完成课程练习', - paramsKey: 'crsId', - rule: '首次完成1分,每天最多5分' - }, - '05': { - name: '完成考试中心考试', - paramsKey: 'papersId', - rule: '首次完成1分,每天最多5分' - }, - '06': { - name: 'AI问答次数徽章', - paramsKey: 'taskId', - rule: '' - }, - '07': { - name: '通过AI陪练练习', - paramsKey: '', - rule: '每次1分,每天最多5分' - }, - '08': { - name: '通过AI陪练考试', - paramsKey: '', - rule: '每次1分,每天最多5分' - }, - '11': { - name: '完成竞赛PK', - paramsKey: '', - rule: '每次1分,每天最多5分' - } -} export default function usePointsAndBadge() { const badgeRef = ref(null); const pointsRef = ref(null); - const pointAndBadgesRun = async (type, params = null, complete = () => {}) => { - // 校验类型合法性 - if (!typeConfig[type] && type !== 'sign') { - console.warn(`不支持的徽章类型:${type}`); - complete(false, '类型不合法'); - return; - } - - let requestParams = { - type - }; - const config = typeConfig[type]; - - // 适配参数键(crsId/papersId/无参数) - if (config?.paramsKey) { - if (!params && type !== '06') { - console.warn(`类型${type}(${config.name})需传入${config.paramsKey}参数`); - complete(false, '缺少必要参数'); - return; - } - requestParams[config.paramsKey] = params; - } - + const pointAndBadgesRun = async (type, taskId = null, complete = () => {}) => { try { // 调用积分接口 console.log('调用积分接口'); - const res = await addPointsByTask(requestParams); - if(type=== '04') { // 完成课程练习,自己处理逻辑 + const res = await addPointsByTask({ + type, + taskId + }); + if (type === '04') { // 完成课程练习,自己处理逻辑 return { points: res.body.points, message: res.body.message, @@ -106,7 +45,7 @@ export default function usePointsAndBadge() { console.log('调用积分接口', res); console.log('pointsRefpointsRef', pointsRef.value); // 06AI问答 不弹出积分窗口 - if(type=== '06'){ + if (type === '06') { if (badgesList.length > 0) { nextTick(() => { setTimeout(() => { @@ -116,7 +55,7 @@ export default function usePointsAndBadge() { }); }, pop_up_time); }); - }else{ + } else { complete(true, '', res); } return @@ -133,7 +72,7 @@ export default function usePointsAndBadge() { }); }, pop_up_time); }); - }else{ + } else { complete(true, '积分获取成功', res); } });