fix: bug
This commit is contained in:
+2
-2
@@ -4,8 +4,8 @@ ENV = 'development.yh'
|
|||||||
|
|
||||||
VITE_APP_BASE_API_Url = 'http://25.18.122.65:7001'
|
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_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'
|
# VITE_APP_BASE_H5_API_Url_TRAAPP = 'http://25.64.32.154:9601'
|
||||||
|
|
||||||
|
|||||||
@@ -16,87 +16,26 @@ import {
|
|||||||
addPointsByTask
|
addPointsByTask
|
||||||
} from '@/api/pointsAndRank.js'
|
} from '@/api/pointsAndRank.js'
|
||||||
import {
|
import {
|
||||||
ref, nextTick
|
ref,
|
||||||
|
nextTick
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
import {
|
import {
|
||||||
pop_up_time
|
pop_up_time
|
||||||
} from '@/enum';
|
} 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() {
|
export default function usePointsAndBadge() {
|
||||||
const badgeRef = ref(null);
|
const badgeRef = ref(null);
|
||||||
const pointsRef = ref(null);
|
const pointsRef = ref(null);
|
||||||
|
|
||||||
const pointAndBadgesRun = async (type, params = null, complete = () => {}) => {
|
const pointAndBadgesRun = async (type, taskId = 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 调用积分接口
|
// 调用积分接口
|
||||||
console.log('调用积分接口');
|
console.log('调用积分接口');
|
||||||
const res = await addPointsByTask(requestParams);
|
const res = await addPointsByTask({
|
||||||
if(type=== '04') { // 完成课程练习,自己处理逻辑
|
type,
|
||||||
|
taskId
|
||||||
|
});
|
||||||
|
if (type === '04') { // 完成课程练习,自己处理逻辑
|
||||||
return {
|
return {
|
||||||
points: res.body.points,
|
points: res.body.points,
|
||||||
message: res.body.message,
|
message: res.body.message,
|
||||||
@@ -106,7 +45,7 @@ export default function usePointsAndBadge() {
|
|||||||
console.log('调用积分接口', res);
|
console.log('调用积分接口', res);
|
||||||
console.log('pointsRefpointsRef', pointsRef.value);
|
console.log('pointsRefpointsRef', pointsRef.value);
|
||||||
// 06AI问答 不弹出积分窗口
|
// 06AI问答 不弹出积分窗口
|
||||||
if(type=== '06'){
|
if (type === '06') {
|
||||||
if (badgesList.length > 0) {
|
if (badgesList.length > 0) {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -116,7 +55,7 @@ export default function usePointsAndBadge() {
|
|||||||
});
|
});
|
||||||
}, pop_up_time);
|
}, pop_up_time);
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
complete(true, '', res);
|
complete(true, '', res);
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@@ -133,7 +72,7 @@ export default function usePointsAndBadge() {
|
|||||||
});
|
});
|
||||||
}, pop_up_time);
|
}, pop_up_time);
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
complete(true, '积分获取成功', res);
|
complete(true, '积分获取成功', res);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user