修改pk自动提交增加一个参数,增加签到判断

This commit is contained in:
田岩
2025-11-21 15:15:14 +08:00
parent 3f2b007560
commit 6b8f5bf226
14 changed files with 204 additions and 185 deletions
+3 -3
View File
@@ -6,7 +6,7 @@ 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'
@@ -15,7 +15,7 @@ ENV = 'development'
# 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 = 'http://25.18.122.65:7001'
# 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'
+10 -8
View File
@@ -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 {
@@ -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
};
}
/**
* 积分和徽章处理主方法
* @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': // 06AI问答,仅弹徽章弹窗
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
};
}
+16
View File
@@ -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; // 连续签到天数
});
};
}
+5 -2
View File
@@ -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(() => {});
</script>
<style scoped lang="scss">
+1 -1
View File
@@ -106,7 +106,7 @@
</view>
</view>
<view class="note_div">
{{ data_info.ruleDesc }}
{{data_info.ruleDesc }}
</view>
</view>
</uni-popup>
+1 -1
View File
@@ -419,7 +419,7 @@
}
nextTick(() => {
common.redirectTo(
`/pages/competition/result?mode=${mode}&execId=${pkData.execId}&orgId=${pkData.orgId}&papersId=${pkData.papersId}`
`/pages/competition/result?mode=${mode}&execId=${pkData.execId}&orgId=${pkData.orgId}&papersId=${pkData.papersId}&autoSub=01`
);
});
+3 -1
View File
@@ -118,6 +118,7 @@
const { pointAndBadgesRun, badgeRef, pointsRef } = usePointsAndBadge();
const action = ref('');
const mode = ref(''); // 模式 PK中 pk_in Pk列表查询 pk_result
const autoSub = ref('00'); // 是否是自动提交 00 不是 01是
const pkData = reactive({
// 公共的
execId: '',
@@ -160,6 +161,7 @@
pkData.papersId = e.papersId || '';
pkData.orgId = e.orgId || '';
mode.value = e.mode || 'pk_result';
autoSub.value = e.autoSub || '00';
const pkDataInit = common.getPageCache('competition_pk_to_resulf');
const userInfo = getUserInfo();
console.log('userInfo', userInfo);
@@ -175,7 +177,7 @@
action.value = 'loading';
setTimeout(() => {
queryCompetitionAnswerResult({ execId: pkData.execId }).then(({ body }) => {
queryCompetitionAnswerResult({ execId: pkData.execId, autoSub:autoSub.value }).then(({ body }) => {
// 计算需要额外延时的时间
const currentTime = Math.floor(Date.now() / 1000);
// 2. 计算对手的答题结束时间(秒)
+1
View File
@@ -870,6 +870,7 @@
nextTick(() => {
watermarkRef.value?.updateWatermarkText();
});
});
// #endif
onUnload(() => {
+8 -49
View File
@@ -48,7 +48,6 @@
<view class="work_number_div">工号{{ user_info.loginName }}</view>
<view class="fl1"></view>
</view>
<!-- v-if="user_info.checkInToday === 'N'" -->
<view class="sign-in-div" @click="checkInClick" v-if="user_info.checkInToday === 'N'">签到</view>
<view class="already-sign-in-div" v-if="user_info.checkInToday === 'Y'" @click="checkInClick">已签</view>
</view>
@@ -65,7 +64,7 @@
></uv-count-to>
</view>
</view>
<view class="item-interval" @click="goTest()"></view>
<view class="item-interval"></view>
<view class="item" @click="common.navigateTo('/pages/pointsAndRank/badge')">
<view class="top">徽章墙</view>
<view class="bottom">
@@ -160,8 +159,8 @@
@confirm="avatarOnConfirm"
></avatar-cropper>
<checkIn ref="checkInRef" @checkInFun="checkInFun"></checkIn>
<badge ref="badgeRef" @confirm="badgeConfirm"></badge>
<points ref="pointsRef" @confirm="pointsConfirm"></points>
<badge ref="badgeRef"></badge>
<points ref="pointsRef"></points>
</view>
</template>
@@ -184,7 +183,8 @@
import checkIn from '@/components/points-and-badge/check-in';
import badge from '@/components/points-and-badge/badge';
import points from '@/components/points-and-badge/points';
import { pop_up_time } from '@/enum';
import usePointsAndBadge from '@/components/points-and-badge/usePointsAndBadge';
const { handlePointsBadgePopup, badgeRef, pointsRef } = usePointsAndBadge();
const { avatarCropperUrl, click_update_avatar, avatarCropperStatus, avatarOnCancel, avatarOnConfirm } = useUpdateAvatar({
success: (userData) => {
user_info.imageAddr = userData.imageAddr;
@@ -195,8 +195,7 @@
const socketStore = useSocketStore();
const badgeNumRef = ref(null);
const checkInRef = ref(null);
const badgeRef = ref(null);
const pointsRef = ref(null);
const currentPointsRef = ref(null);
const user_info = reactive({
@@ -207,56 +206,16 @@
checkInToday: '', // 今日是否签到
checkInDays: 0 // 连续签到天数
});
const goTest = () => {
console.log('xxxxxxxxx');
common.navigateTo('/pages/pointsRedemption/index');
};
// 签到打开
const checkInClick = () => {
checkInRef.value.open(user_info.checkInToday, user_info.checkInDays);
// badgeRef.value.open(
// [],
// [
// {
// pointsBadgeImg: '/traoss/tras3/show/S3F0250181220722025110713501700000661177',
// pointsBadgeName: '黄金徽章'
// },
// {
// pointsBadgeImg: '/traoss/tras3/show/S3F0250181220722025110713501700000661177',
// pointsBadgeName: '黄金徽章2'
// }
// ]
// );
};
// 签到成功回调
const checkInFun = (status, pointsList = [], badgesList = []) => {
if (status) {
getCheckInInfo();
}
pointsRef.value.open(pointsList, badgesList);
};
const badgeConfirm = (status, pointsList = [], badgesList = []) => {
// nextTick(() => {
// badgeRef.value.close();
// })
badgeRef.value.close();
};
// 积分确认
const pointsConfirm = (status, pointsList = [], badgesList = []) => {
console.log('xxx', status, pointsList, badgesList);
pointsRef.value.close();
if (badgesList.length > 0) {
nextTick(() => {
setTimeout(() => {
badgeRef.value.open(pointsList, badgesList);
}, pop_up_time);
});
}
handlePointsBadgePopup(pointsList, badgesList)
};
const click_loginout = () => {
@@ -335,7 +294,7 @@
}
}
});
// 获取今日是否签到消息
const getCheckInInfo = () => {
// todo 后续加防止重复多次请求逻辑
+35 -33
View File
@@ -18,36 +18,40 @@
</view>
</template>
<view class="scroll-Y">
<view class="item" v-for="(item, index) in data_list" @click="gotoMessageList">
<view class="item" v-for="(item, index) in data_list" @click="gotoMessageList(item)">
<view class="icon">
<image class="img_100" :src="imageMap[item.noticeTyp]" mode="widthFix"></image>
</view>
<view class="right">
<view class="top">
<view class="title">
{{ item.noticeTitle }}
</view>
<view class="time">
{{ item.ctTime?.substr(0, 16) }}
{{ item.noticeName }}
</view>
</view>
<view class="bottom">
<view class="note ellipsis-text">
{{ item.noticeContent }}
<view class="time">
{{ item.msgTm?.substr(0, 16) }}
</view>
<view class="read_div" v-if="item?.isRead === '01'"></view>
<!-- <view class="note ellipsis-text">
{{ item.noticeContent }}
</view> -->
<view class="read_div" v-if="item?.isMsg === 'Y'"></view>
</view>
</view>
</view>
</view>
</z-paging>
</template>
<script setup>
import { ref, reactive } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { queryTraPersonalMessageNoticePaging, readNotice, oneTimeRead, queryMessageNoticeClass } from '@/api/messageNotification.js';
import {
queryTraPersonalMessageNoticePaging,
readNotice,
oneTimeRead,
queryMessageNoticeClass
} from '@/api/messageNotification.js';
import common from '../../common/common';
import type_01 from '@/static/images/messageNotification/type_01.png';
import type_02 from '@/static/images/messageNotification/type_02.png';
@@ -57,19 +61,19 @@
import type_06 from '@/static/images/messageNotification/type_06.png';
import type_07 from '@/static/images/messageNotification/type_07.png';
import useZpaging from '@/composables/useZpaging.js';
const pagingRef = ref(null)
const pagingRef = ref(null);
const data_list = ref([]);
// const { pagingRef, queryList, data_list, reload } = useZpaging({
// fetchFunction: noticeMessageCount
// });
const queryList = () => {
queryMessageNoticeClass().then((body) => {
pagingRef.value.completeByTotal(body, 8);
})
}
queryMessageNoticeClass().then(({ body }) => {
data_list.value = body;
pagingRef.value.completeByTotal(body, body.length);
});
};
const imageMap = {
'01': type_01,
'02': type_02,
@@ -77,13 +81,13 @@
'04': type_04,
'05': type_05,
'06': type_06,
'07': type_07,
'07': type_07
};
const gotoMessageList = (item) => {
common.navigateTo('/pages/messageNotification/list?type=' + item.noticeTyp);
};
const gotoMessageList = () => {
common.navigateTo('/pages/messageNotification/list?type=1')
}
const oneClickReadMessage = () => {
const state = data_list.value.every((res) => res.isRead === '02');
if (state) {
@@ -177,7 +181,13 @@
width: 78rpx;
height: 78rpx;
}
.time {
font-size: 23rpx;
color: #999999;
line-height: 30rpx;
text-align: right;
font-style: normal;
}
.right {
margin-left: 16rpx;
flex: 1;
@@ -195,14 +205,6 @@
text-align: left;
font-style: normal;
}
.time {
font-size: 23rpx;
color: #999999;
line-height: 30rpx;
text-align: right;
font-style: normal;
}
}
.bottom {
+19 -12
View File
@@ -29,10 +29,10 @@
</view>
</view>
</view>
<view class="note-div" v-if="typeValue !== '07'">{{ item.noticeContent }}</view>
<view class="note-div" v-if="typeValue !== '06'">{{ item.noticeContent }}</view>
<view class="badge-div" v-else>
<image src="/src/static/images/test/xz.png" mode="widthFix" class="badge-img"></image>
<view class="badge-name">恭喜你获得X徽章</view>
<image-preview v-if="item.ossAddr" :src="item.ossAddr" mode="widthFix" class="badge-img"></image-preview>
<view class="badge-name">{{ item.noticeContent }}</view>
</view>
</view>
</view>
@@ -68,23 +68,30 @@
};
const titleMap = {
'01': '课程提醒',
'02': '',
'02': '任务完成提醒',
'03': '积分获取',
'04': '',
'05': '',
'06': '',
'07': '积分上架'
'04': '任务时间提醒',
'05': '新任务提醒',
'06': '徽章获取',
'07': '积分兑换'
};
const typeValue = ref('');
const img = computed(() => imageMap[typeValue.value] ?? '');
const title = computed(() => titleMap[typeValue.value] ?? '');
const itemClick = (item) => {
if(typeValue.value === '06') {
common.navigateTo('/pages/pointsRedemption/index?id=');
if (typeValue.value === '07') {
// 积分兑换跳转
if (item.noticeBusId) {
common.navigateTo('/pages/pointsRedemption/index?id=' + item.noticeBusId);
} else {
common.msg('活动id不存在');
}
}
}
};
onLoad((e) => {
typeValue.value = e.type ?? '07';
typeValue.value = e.type;
});
</script>
+1 -1
View File
@@ -124,7 +124,7 @@
});
};
onLoad((e) => {
data.actId = e.actId ?? 'TRAPOINTSACTIVITY02501812207220251120133928000019482';
data.actId = e.id;
});
onUnload(() => {});
</script>
+12 -12
View File
@@ -1,5 +1,5 @@
<template>
<view class="max_page" :class="{points_bg:showData.num !== 0}">
<view class="max_page" :class="{ points_bg: showData.num !== 0 }">
<view class="" v-if="showData.num === 0">
<image src="@/static/images/common/wc.png" class="show_img"></image>
<view class="show_msg">练习完成</view>
@@ -17,8 +17,8 @@
<view class="points-img-div">
<image class="img_100" src="@/static/images/pointsAndRank/like.png" mode=""></image>
</view>
<view class="points-num-div">+{{showData.num}}</view>
<view class="points-msg-div" v-show="showData.message"> {{showData.message}}</view>
<view class="points-num-div">+{{ showData.num }}</view>
<view class="points-msg-div" v-show="showData.message">{{ showData.message }}</view>
</view>
</view>
<view class="fl1"></view>
@@ -156,7 +156,7 @@
// const changePoints = ref(0);
const showData = ref({
num: 0,
message:''
message: ''
});
onLoad((e) => {
console.log('xx23333');
@@ -173,15 +173,16 @@
practiceCommit({ exrId: exrId.value, examLenTm: examLenTm.value, stat: stat.value }).then(() => {
console.log('提交练习状态成功');
commit.value = true;
pointAndBadgesRun('04', crsId.value).then(({ points, message, taskBadges }) => {
if (Array.isArray(points) && points.length > 0) {
pointAndBadgesRun('04', crsId.value, (status, msg, { points, pointsBadges, message }) => {
if(!status) return;
if (points?.length > 0) {
showData.value.num = points[0]['changePoints'];
showData.value.message = message;
}
if (taskBadges.length > 0) {
if (pointsBadges.length > 0) {
nextTick(() => {
setTimeout(() => {
badgeRef.value.open([], taskBadges);
badgeRef.value.open([], pointsBadges);
}, pop_up_time);
});
}
@@ -220,13 +221,13 @@
text-align: center;
}
}
.title_div {
display: flex;
align-items: center;
justify-content: center;
margin-top: calc(104rpx + var(--status-bar-height));
height: 68rpx;
.img {
width: 36rpx;
@@ -246,10 +247,9 @@
display: flex;
align-items: center;
flex-direction: column;
}
.points_bg {
background: linear-gradient( 180deg, #FFF9EB 0%, #F7F7F7 100%);
background: linear-gradient(180deg, #fff9eb 0%, #f7f7f7 100%);
}
.show_img {
margin-top: 300rpx;