web-课程列表

This commit is contained in:
2025-10-21 17:59:34 +08:00
parent 9824a7d686
commit eef1c029b4
26 changed files with 2742 additions and 602 deletions

View File

@@ -1,227 +1,440 @@
<template>
<div class="course-center">
<div class="course-header">
<h2>课程中心</h2>
<div class="course-categories">
<div
class="category-tab"
v-for="category in categories"
:key="category.id"
:class="{ active: activeCategory === category.id }"
@click="activeCategory = category.id"
>
{{ category.name }}
<StudyPlanLayout category-name="课程中心">
<!-- 主要内容区 -->
<div class="main-content">
<div class="container">
<!-- 页面标题 -->
<h2 class="page-title">课程列表</h2>
<!-- 搜索和筛选 -->
<div class="search-filter-bar">
<div class="search-box">
<el-input
v-model="searchKeyword"
placeholder="搜索思政资源"
class="search-input"
clearable
@keyup.enter="handleSearch"
>
<template #suffix>
<el-button
type="danger"
circle
@click="handleSearch"
class="search-button"
>
<el-icon><Search /></el-icon>
</el-button>
</template>
</el-input>
</div>
</div>
<!-- 课程列表 -->
<div v-if="loading" class="loading-container">
<el-skeleton :rows="6" animated />
</div>
<div v-else-if="courseList.length > 0" class="course-grid">
<div
v-for="course in courseList"
:key="course.courseID"
class="course-card"
@click="handleCourseClick(course.courseID || '')"
>
<!-- 课程封面 -->
<div class="course-cover">
<img
:src="course.coverImage ? FILE_DOWNLOAD_URL + course.coverImage : defaultCover"
:alt="course.name"
class="cover-image"
/>
<!-- 课程类型标签 -->
<div class="course-type-tag">
<el-icon><VideoPlay /></el-icon>
<span>视频课程</span>
</div>
<!-- 分类标签 -->
<div class="category-tag">
{{ getCategoryName() }}
</div>
</div>
<!-- 课程信息 -->
<div class="course-info">
<div class="view-count">
{{ formatViewCount(course.viewCount) }}次浏览
</div>
<h3 class="course-title">{{ course.name }}</h3>
<p class="course-desc">
{{ course.description || '暂无描述' }}
</p>
</div>
</div>
</div>
<div v-else class="empty-state">
<el-empty description="暂无课程" />
</div>
<!-- 分页 -->
<div v-if="total > 0" class="pagination-container">
<el-pagination
v-model:current-page="pageParam.page"
v-model:page-size="pageParam.size"
:total="total"
:page-sizes="[6, 12, 24, 48]"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
</div>
</div>
<div class="course-grid">
<div class="course-card" v-for="course in filteredCourses" :key="course.id" @click="viewCourse(course)">
<div class="course-cover">
<img :src="course.cover" :alt="course.title" />
<div class="course-duration">{{ course.duration }}</div>
</div>
<div class="course-info">
<h3>{{ course.title }}</h3>
<p class="course-description">{{ course.description }}</p>
<div class="course-meta">
<span class="course-teacher">
<i class="icon">👨🏫</i>
{{ course.teacher }}
</span>
<span class="course-students">
<i class="icon">👥</i>
{{ course.students }} 人学习
</span>
</div>
<div class="course-footer">
<div class="course-rating">
<span class="rating-stars"></span>
<span class="rating-score">{{ course.rating }}</span>
</div>
<el-button type="primary" size="small">开始学习</el-button>
</div>
</div>
</div>
</div>
</div>
<!-- 课程详情对话框 -->
<el-drawer
v-model="detailDrawerVisible"
size="100%"
:show-close="false"
:with-header="false"
direction="rtl"
>
<CourseDetail
v-if="selectedCourseId"
:course-id="selectedCourseId"
@back="handleCloseDetail"
@start-learning="handleStartLearning"
/>
</el-drawer>
<!-- 课程学习对话框 -->
<el-drawer
v-model="learningDrawerVisible"
size="100%"
:show-close="false"
:with-header="false"
direction="rtl"
>
<CourseLearning
v-if="learningCourseId"
:course-id="learningCourseId"
:chapter-index="chapterIndex"
:node-index="nodeIndex"
@back="handleCloseLearning"
/>
</el-drawer>
</StudyPlanLayout>
</template>
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { ElButton } from 'element-plus';
import { ref, onMounted } from 'vue';
import { ElMessage } from 'element-plus';
import { Search, VideoPlay } from '@element-plus/icons-vue';
import { CourseDetail, CourseLearning } from '@/views/course';
import { courseApi } from '@/apis/study';
import type { Course, PageParam } from '@/types';
import { StudyPlanLayout } from '@/views/study-plan';
import defaultCover from '@/assets/imgs/default-course-bg.png'
import { FILE_DOWNLOAD_URL } from '@/config';
const router = useRouter();
const activeCategory = ref('all');
const courses = ref<any[]>([]);
const categories = [
{ id: 'all', name: '全部课程' },
{ id: 'party-history', name: '党史教育' },
{ id: 'theory', name: '理论学习' },
{ id: 'policy', name: '政策解读' },
{ id: 'ethics', name: '道德修养' }
];
const filteredCourses = computed(() => {
if (activeCategory.value === 'all') return courses.value;
return courses.value.filter(course => course.category === activeCategory.value);
defineOptions({
name: 'CourseCenterView'
});
const loading = ref(false);
const searchKeyword = ref('');
const courseList = ref<Course[]>([]);
const total = ref(0);
// 分页参数
const pageParam = ref<PageParam>({
page: 1,
size: 6
});
// 课程详情
const detailDrawerVisible = ref(false);
const selectedCourseId = ref<string>('');
// 课程学习
const learningDrawerVisible = ref(false);
const learningCourseId = ref<string>('');
const chapterIndex = ref(0);
const nodeIndex = ref(0);
onMounted(() => {
// TODO: 加载课程数据
loadCourseList();
});
function viewCourse(course: any) {
router.push(`/study/course/${course.id}`);
// 加载课程列表
async function loadCourseList() {
loading.value = true;
try {
const filter: Course = {
status: 1 // 只显示已上线的课程
};
if (searchKeyword.value) {
filter.name = searchKeyword.value;
}
const res = await courseApi.getCoursePage(pageParam.value, filter);
if (res.success) {
courseList.value = res.dataList || [];
total.value = res.pageParam?.totalElements || 0;
} else {
ElMessage.error('加载课程列表失败');
}
} catch (error) {
console.error('加载课程列表失败:', error);
ElMessage.error('加载课程列表失败');
} finally {
loading.value = false;
}
}
// 搜索
function handleSearch() {
pageParam.value.page = 1;
loadCourseList();
}
// 分页大小改变
function handleSizeChange() {
loadCourseList();
}
// 当前页改变
function handleCurrentChange() {
loadCourseList();
}
// 点击课程卡片
function handleCourseClick(courseId: string) {
selectedCourseId.value = courseId;
detailDrawerVisible.value = true;
}
// 关闭课程详情
function handleCloseDetail() {
detailDrawerVisible.value = false;
selectedCourseId.value = '';
}
// 开始学习
function handleStartLearning(courseId: string, chapter: number, node: number) {
detailDrawerVisible.value = false;
learningCourseId.value = courseId;
chapterIndex.value = chapter;
nodeIndex.value = node;
learningDrawerVisible.value = true;
}
// 关闭学习页面
function handleCloseLearning() {
learningDrawerVisible.value = false;
learningCourseId.value = '';
chapterIndex.value = 0;
nodeIndex.value = 0;
}
// 格式化浏览次数
function formatViewCount(count?: number): string {
if (!count) return '0';
if (count >= 10000) {
return (count / 10000).toFixed(1) + 'w';
}
return count.toString();
}
// 获取分类名称(这里简化处理,实际应该从课程标签中获取)
function getCategoryName(): string {
// TODO: 从 courseTags 中获取第一个标签作为分类
return '党史学习';
}
</script>
<style lang="scss" scoped>
.course-center {
padding: 40px;
}
.course-header {
margin-bottom: 32px;
.main-content {
padding: 40px 0 80px;
h2 {
font-size: 24px;
font-weight: 600;
color: #141F38;
margin-bottom: 20px;
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 24px;
}
}
.course-categories {
display: flex;
gap: 12px;
flex-wrap: wrap;
.page-title {
font-size: 28px;
font-weight: 600;
color: #141F38;
margin: 0 0 32px 0;
}
.category-tab {
padding: 8px 20px;
background: #f5f5f5;
border-radius: 20px;
font-size: 14px;
color: #666;
cursor: pointer;
transition: all 0.3s;
.search-filter-bar {
margin-bottom: 40px;
&:hover {
background: #ffe6e6;
color: #C62828;
}
&.active {
background: #C62828;
color: white;
.search-box {
max-width: 400px;
.search-input {
:deep(.el-input__wrapper) {
border-radius: 30px;
padding-right: 4px;
}
.search-button {
width: 36px;
height: 36px;
background: #C62828;
border: none;
&:hover {
background: #A82020;
}
}
}
}
}
.loading-container {
padding: 40px 0;
}
.course-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
grid-template-columns: repeat(3, 1fr);
gap: 24px;
margin-bottom: 40px;
@media (max-width: 1024px) {
grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 768px) {
grid-template-columns: 1fr;
}
}
.course-card {
border: 1px solid #e0e0e0;
border-radius: 8px;
background: #fff;
border-radius: 10px;
overflow: hidden;
cursor: pointer;
transition: all 0.3s;
border: 1px solid transparent;
&:hover {
border-color: #C62828;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
transform: translateY(-4px);
box-shadow: 0 8px 20px rgba(164, 182, 199, 0.2);
border-color: rgba(0, 0, 0, 0.1);
}
}
.course-cover {
position: relative;
width: 100%;
height: 200px;
background: #f5f5f5;
img {
.course-cover {
position: relative;
width: 100%;
height: 100%;
object-fit: cover;
height: 221px;
overflow: hidden;
.cover-image {
width: 100%;
height: 100%;
object-fit: cover;
transition: transform 0.3s;
}
.course-type-tag {
position: absolute;
top: 12px;
left: 12px;
display: flex;
align-items: center;
gap: 4px;
padding: 4px 10px;
background: rgba(198, 40, 40, 0.9);
color: #fff;
border-radius: 4px;
font-size: 14px;
font-weight: 500;
.el-icon {
font-size: 16px;
}
}
.category-tag {
position: absolute;
bottom: -1px;
right: -2px;
padding: 3px 26px;
background: #D1AD79;
color: #fff;
font-size: 14px;
font-weight: 600;
border-radius: 0 0 10px 0;
}
}
}
.course-duration {
position: absolute;
bottom: 12px;
right: 12px;
padding: 4px 12px;
background: rgba(0, 0, 0, 0.7);
color: white;
border-radius: 4px;
font-size: 12px;
}
.course-info {
padding: 20px;
h3 {
font-size: 18px;
font-weight: 600;
color: #141F38;
margin-bottom: 12px;
line-height: 1.4;
&:hover .cover-image {
transform: scale(1.05);
}
}
.course-description {
font-size: 14px;
color: #666;
line-height: 1.6;
margin-bottom: 16px;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.course-meta {
display: flex;
gap: 20px;
margin-bottom: 16px;
font-size: 13px;
color: #999;
.icon {
margin-right: 4px;
.course-info {
padding: 22px;
.view-count {
position: absolute;
top: 232px;
right: 22px;
font-size: 14px;
color: rgba(0, 0, 0, 0.3);
margin-bottom: 8px;
}
.course-title {
font-size: 20px;
font-weight: 600;
color: #141F38;
margin: 0 0 8px 0;
line-height: 1.4;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.course-desc {
font-size: 14px;
color: rgba(0, 0, 0, 0.3);
line-height: 1.6;
margin: 0;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 4;
line-clamp: 4;
overflow: hidden;
text-overflow: ellipsis;
min-height: 88px;
}
}
}
.course-footer {
.empty-state {
padding: 80px 0;
text-align: center;
}
.pagination-container {
display: flex;
justify-content: space-between;
align-items: center;
padding-top: 16px;
border-top: 1px solid #f0f0f0;
justify-content: center;
margin-top: 40px;
}
.course-rating {
display: flex;
align-items: center;
gap: 8px;
}
.rating-stars {
color: #FFB400;
font-size: 14px;
}
.rating-score {
font-size: 14px;
font-weight: 600;
color: #141F38;
:deep(.el-drawer) {
.el-drawer__body {
padding: 0;
}
}
</style>

View File

@@ -0,0 +1,60 @@
<template>
<div class="study-plan-layout">
<!-- Banner 横幅 -->
<CenterHead
title="学习中心"
:category-name="categoryName"
/>
<!-- Tab 导航 -->
<MenuNav :menus="menus" @menu-click="handleMenuClick" />
<!-- 内容插槽 -->
<slot></slot>
</div>
</template>
<script setup lang="ts">
import { useRouter, useRoute } from 'vue-router';
import { MenuNav, CenterHead } from '@/components/base';
import { getParentChildrenRoutes } from '@/utils/routeUtils';
import type { SysMenu } from '@/types';
defineOptions({
name: 'StudyPlanLayout'
});
interface Props {
categoryName?: string;
}
withDefaults(defineProps<Props>(), {
categoryName: '学习中心'
});
const router = useRouter();
const route = useRoute();
const routes = getParentChildrenRoutes(route);
// 将路由转换为菜单格式
const menus = routes.map((r, index) => ({
menuID: r.name?.toString() || `menu-${index}`,
name: (r.meta?.title as string) || '',
url: r.path || '',
orderNum: index
})) as SysMenu[];
// 菜单点击事件
function handleMenuClick(menu: SysMenu) {
if (menu.url) {
router.push(menu.url);
}
}
</script>
<style lang="scss" scoped>
.study-plan-layout {
min-height: 100vh;
background: #F9F9F9;
}
</style>

View File

@@ -1,113 +0,0 @@
<template>
<div class="study-plan-page">
<div class="page-header">
<h1>学习计划</h1>
<p class="page-description">制定学习计划完成学习任务提升思政素养</p>
</div>
<div class="plan-tabs">
<div
class="plan-tab"
v-for="tab in tabs"
:key="tab.key"
:class="{ active: activeTab === tab.key }"
@click="activeTab = tab.key"
>
{{ tab.label }}
</div>
</div>
<div class="plan-content">
<component :is="currentComponent" />
</div>
</div>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue';
import StudyTasks from './components/StudyTasks.vue';
import CourseCenter from './components/CourseCenter.vue';
const activeTab = ref('tasks');
const tabs = [
{ key: 'tasks', label: '学习任务' },
{ key: 'courses', label: '课程中心' }
];
const componentMap: Record<string, any> = {
'tasks': StudyTasks,
'courses': CourseCenter
};
const currentComponent = computed(() => componentMap[activeTab.value]);
</script>
<style lang="scss" scoped>
.study-plan-page {
min-height: 100vh;
background: #f5f5f5;
padding: 20px;
}
.page-header {
background: white;
padding: 40px;
border-radius: 8px;
margin-bottom: 20px;
h1 {
font-size: 32px;
font-weight: 600;
color: #141F38;
margin-bottom: 8px;
}
}
.page-description {
font-size: 16px;
color: #666;
}
.plan-tabs {
background: white;
padding: 0 40px;
display: flex;
gap: 8px;
border-radius: 8px 8px 0 0;
}
.plan-tab {
padding: 16px 24px;
cursor: pointer;
font-size: 16px;
color: #666;
position: relative;
transition: all 0.3s;
&:hover {
color: #C62828;
}
&.active {
color: #C62828;
font-weight: 600;
&::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 3px;
background: #C62828;
}
}
}
.plan-content {
background: white;
border-radius: 0 0 8px 8px;
}
</style>

View File

@@ -1,297 +1,589 @@
<template>
<div class="study-tasks">
<!-- 任务统计 -->
<div class="task-statistics">
<div class="stat-card" v-for="stat in statistics" :key="stat.label">
<div class="stat-value">{{ stat.value }}</div>
<div class="stat-label">{{ stat.label }}</div>
</div>
</div>
<StudyPlanLayout category-name="学习任务">
<!-- 主要内容区 -->
<div class="main-content">
<div class="container">
<!-- 任务进度 -->
<h2 class="section-title">任务进度</h2>
<div class="progress-card">
<div class="progress-info">
<div class="progress-header">
<span class="progress-text">当前学习进度{{ completedCount }}/{{ totalCount }}</span>
<span class="progress-percent">{{ progressPercent }}%</span>
<span class="progress-level">{{ userLevel }}</span>
</div>
<div class="progress-bar-container">
<div class="progress-bar">
<div class="progress-fill" :style="{ width: progressPercent + '%' }"></div>
</div>
</div>
</div>
<div class="task-stats">
<div class="stat-card pending">
<div class="stat-content">
<div class="stat-title">待完成任务</div>
<div class="stat-number">{{ pendingCount }}</div>
</div>
<div class="stat-icon pending-icon">
<el-icon><DocumentCopy /></el-icon>
</div>
</div>
<div class="stat-card completed">
<div class="stat-content">
<div class="stat-title">已完成任务</div>
<div class="stat-number">{{ completedCount }}</div>
</div>
<div class="stat-icon completed-icon">
<el-icon><DocumentChecked /></el-icon>
</div>
</div>
</div>
</div>
<!-- 任务列表 -->
<div class="task-section">
<div class="section-header">
<h2>任务列表</h2>
<div class="filter-tabs">
<div
class="filter-tab"
v-for="filter in filters"
:key="filter.key"
:class="{ active: activeFilter === filter.key }"
@click="activeFilter = filter.key"
<!-- 任务列表 -->
<h2 class="section-title">任务列表</h2>
<div v-if="loading" class="loading-container">
<el-skeleton :rows="6" animated />
</div>
<div v-else-if="taskList.length > 0" class="task-grid">
<div
v-for="task in taskList"
:key="task.taskID"
class="task-card"
@click="handleTaskClick(task)"
>
{{ filter.label }}
<!-- 内容容器 -->
<div class="task-content">
<!-- 状态标签小标签自适应宽度 -->
<div
class="status-tag"
:class="{
'status-pending': task.status === 0,
'status-processing': task.status === 1,
'status-completed': task.status === 2
}"
>
{{ task.status === 0 ? '待完成' : task.status === 1 ? '进行中' : '已完成' }}
</div>
<!-- 任务标题 -->
<h3 class="task-title">{{ task.name }}</h3>
<!-- 任务描述 -->
<p class="task-desc">{{ task.description || '暂无描述' }}</p>
<!-- 任务底部信息 -->
<div class="task-footer">
<span class="task-time">
任务时间{{ formatDate(task.startTime) }}-{{ formatDate(task.endTime) }}
</span>
<div
v-if="getDeadlineStatus(task).show"
class="deadline-tag"
:class="{
'deadline-danger': getDeadlineStatus(task).type === 'danger',
'deadline-info': getDeadlineStatus(task).type === 'info',
'deadline-success': getDeadlineStatus(task).type === 'success',
'deadline-primary': getDeadlineStatus(task).type === 'primary',
}"
>
{{ getDeadlineStatus(task).text }}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="task-list">
<div class="task-item" v-for="task in filteredTasks" :key="task.id">
<div class="task-icon" :class="`status-${task.status}`">
<i :class="getTaskIcon(task.status)"></i>
</div>
<div class="task-content">
<h3>{{ task.title }}</h3>
<p class="task-description">{{ task.description }}</p>
<div class="task-meta">
<span class="task-type">{{ task.type }}</span>
<span class="task-deadline">截止时间{{ task.deadline }}</span>
</div>
</div>
<div class="task-progress">
<div class="progress-bar">
<div class="progress-fill" :style="{ width: task.progress + '%' }"></div>
</div>
<span class="progress-text">{{ task.progress }}%</span>
</div>
<div class="task-actions">
<el-button
type="primary"
size="small"
@click="goToTask(task)"
v-if="task.status !== 'completed'"
>
{{ task.status === 'not-started' ? '开始学习' : '继续学习' }}
</el-button>
<el-button
size="small"
@click="viewTaskDetail(task)"
>
查看详情
</el-button>
</div>
<div v-else class="empty-state">
<el-empty description="暂无学习任务" />
</div>
</div>
</div>
</div>
</StudyPlanLayout>
</template>
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { ElButton } from 'element-plus';
import { ref, onMounted, computed } from 'vue';
import { ElMessage } from 'element-plus';
import { DocumentCopy, DocumentChecked } from '@element-plus/icons-vue';
import { learningTaskApi } from '@/apis/study';
import type { LearningTask } from '@/types';
import { StudyPlanLayout } from '@/views/study-plan';
const router = useRouter();
const activeFilter = ref('all');
const tasks = ref<any[]>([]);
defineOptions({
name: 'StudyTasksView'
});
const statistics = ref([
{ label: '总任务数', value: 0 },
{ label: '进行中', value: 0 },
{ label: '已完成', value: 0 },
{ label: '完成率', value: '0%' }
]);
const loading = ref(false);
const taskList = ref<LearningTask[]>([]);
const filters = [
{ key: 'all', label: '全部任务' },
{ key: 'not-started', label: '未开始' },
{ key: 'in-progress', label: '进行中' },
{ key: 'completed', label: '已完成' }
];
// 统计数据
const totalCount = ref(16);
const completedCount = ref(10);
const pendingCount = ref(6);
const userLevel = ref('Level1');
const filteredTasks = computed(() => {
if (activeFilter.value === 'all') return tasks.value;
return tasks.value.filter(task => task.status === activeFilter.value);
// 计算进度百分比
const progressPercent = computed(() => {
if (totalCount.value === 0) return 0;
return Math.round((completedCount.value / totalCount.value) * 100);
});
onMounted(() => {
// TODO: 加载学习任务数据
loadTaskList();
loadStatistics();
});
function getTaskIcon(status: string) {
const iconMap: Record<string, string> = {
'not-started': '⭕',
'in-progress': '⏳',
'completed': '✅'
// ==================== MOCK 数据(临时使用,后续删除) ====================
const useMock = true; // 改为 false 即可使用真实接口
function getMockTaskList(): LearningTask[] {
return [
{
taskID: '1',
name: '新时代中国特色社会主义发展历程',
description: '习近平新时代中国特色社会主义思想是当代中国马克思主义、二十一世纪马克思主义,是中华文化和中国精神的时代精华,其核心要义与实践要求内涵丰富、意义深远。',
startTime: '2025-10-01',
endTime: '2025-10-25',
status: 0,
},
{
taskID: '2',
name: '党的二十大精神学习',
description: '深入学习贯彻党的二十大精神,全面把握新时代新征程党和国家事业发展的目标任务,为全面建设社会主义现代化国家、全面推进中华民族伟大复兴而团结奋斗。',
startTime: '2025-09-15',
endTime: '2025-11-30',
status: 1,
},
{
taskID: '3',
name: '党史学习教育',
description: '学习党的百年奋斗历程,从党的历史中汲取智慧和力量,做到学史明理、学史增信、学史崇德、学史力行。',
startTime: '2025-08-01',
endTime: '2025-10-15',
status: 2,
},
{
taskID: '4',
name: '红色经典阅读',
description: '阅读红色经典著作,传承革命精神,赓续红色血脉,坚定理想信念。',
startTime: '2025-10-10',
endTime: '2025-12-31',
status: 0,
},
];
}
function getMockStatistics() {
return {
totalCount: 16,
completedCount: 10,
pendingCount: 6,
level: 'Level1'
};
return iconMap[status] || '⭕';
}
// ==================== MOCK 数据结束 ====================
// 加载任务列表
async function loadTaskList() {
loading.value = true;
try {
// MOCK: 使用模拟数据(临时)
if (useMock) {
await new Promise(resolve => setTimeout(resolve, 500)); // 模拟加载延迟
taskList.value = getMockTaskList();
loading.value = false;
return;
}
// TODO: 真实接口调用useMock 改为 false 后生效)
const res = await learningTaskApi.getTaskList();
if (res.success) {
taskList.value = res.dataList || [];
} else {
ElMessage.error('加载学习任务失败');
}
} catch (error) {
console.error('加载学习任务失败:', error);
ElMessage.error('加载学习任务失败');
} finally {
loading.value = false;
}
}
function goToTask(task: any) {
router.push(`/study/task/${task.id}`);
// 加载统计数据
async function loadStatistics() {
try {
// MOCK: 使用模拟数据(临时)
if (useMock) {
const mockData = getMockStatistics();
totalCount.value = mockData.totalCount;
completedCount.value = mockData.completedCount;
pendingCount.value = mockData.pendingCount;
userLevel.value = mockData.level;
return;
}
// TODO: 真实接口调用useMock 改为 false 后生效)
// const res = await learningTaskApi.getStatistics();
// if (res.success && res.data) {
// totalCount.value = res.data.totalCount;
// completedCount.value = res.data.completedCount;
// pendingCount.value = res.data.pendingCount;
// userLevel.value = res.data.level;
// }
} catch (error) {
console.error('加载统计数据失败:', error);
}
}
function viewTaskDetail(task: any) {
router.push(`/study/task/${task.id}/detail`);
// 点击任务卡片
function handleTaskClick(task: LearningTask) {
// TODO: 跳转到任务详情或开始任务
console.log('点击任务:', task);
}
// 格式化日期
function formatDate(dateString?: string): string {
if (!dateString) return '';
const date = new Date(dateString);
return `${date.getFullYear()}.${(date.getMonth() + 1).toString().padStart(2, '0')}.${date.getDate().toString().padStart(2, '0')}`;
}
// 获取截止时间状态
function getDeadlineStatus(task: LearningTask): { show: boolean; text: string; type: 'danger' | 'info' | 'success' | 'primary' } {
if (!task.endTime) {
return { show: false, text: '', type: 'primary' };
}
const now = new Date();
const endTime = new Date(task.endTime);
const diffTime = endTime.getTime() - now.getTime();
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
if (task.status === 2) {
// 已完成
return { show: true, text: '已截止', type: 'success' };
} else if (diffDays < 0) {
// 已过期
return { show: true, text: '已截止', type: 'info' };
} else if (diffDays <= 8) {
// 即将截止
return { show: true, text: `${diffDays}天后截止`, type: 'danger' };
}
return { show: true, text: `${diffDays}天后截止`, type: 'primary' };
}
</script>
<style lang="scss" scoped>
.study-tasks {
padding: 40px;
.main-content {
padding: 40px 0 80px;
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 24px;
}
}
.task-statistics {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 20px;
margin-bottom: 40px;
}
.stat-card {
padding: 24px;
background: linear-gradient(135deg, #C62828, #E53935);
border-radius: 8px;
color: white;
text-align: center;
}
.stat-value {
font-size: 32px;
.section-title {
font-size: 28px;
font-weight: 600;
margin-bottom: 8px;
color: #141F38;
margin: 0 0 20px 0;
}
.stat-label {
font-size: 14px;
opacity: 0.9;
}
.task-section {
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24px;
// 进度卡片
.progress-card {
background: #fff;
border-radius: 10px;
padding: 50px;
margin-bottom: 60px;
box-shadow: 0 17px 22.4px rgba(164, 182, 199, 0.1);
.progress-info {
margin-bottom: 40px;
h2 {
font-size: 24px;
font-weight: 600;
color: #141F38;
.progress-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
.progress-text {
font-size: 16px;
font-weight: 500;
color: #334155;
}
.progress-percent {
font-size: 16px;
font-weight: 500;
color: #C62828;
}
.progress-level {
font-size: 16px;
font-weight: 500;
color: #334155;
}
}
.progress-bar-container {
.progress-bar {
width: 100%;
height: 12px;
background: #F7F8F9;
border-radius: 27px;
overflow: hidden;
.progress-fill {
height: 100%;
background: linear-gradient(143deg, #FD9082 1%, #FD6D78 99%);
border-radius: 27px;
transition: width 0.3s ease;
}
}
}
}
.task-stats {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 30px;
.stat-card {
background: #FFFDFD;
border: 1px solid rgba(0, 0, 0, 0.05);
border-radius: 10px;
padding: 30px 40px;
display: flex;
justify-content: space-between;
align-items: center;
&.pending {
.stat-icon {
background: #FFF5F4;
:deep(.el-icon) {
font-size: 44px;
background: linear-gradient(143deg, #FD9082 1%, #FD6D78 99%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
}
}
&.completed {
background: #FBFDFF;
.stat-icon {
background: #EFF8FF;
:deep(.el-icon) {
font-size: 44px;
background: linear-gradient(143deg, #82B7FD 1%, #2F6AFF 99%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
}
}
.stat-content {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 30px;
.stat-title {
font-size: 20px;
font-weight: 600;
color: #141F38;
text-align: right;
width: 100px;
}
.stat-number {
font-size: 40px;
font-weight: 600;
line-height: 0.95;
color: #334155;
width: 100px;
}
}
.stat-icon {
width: 77px;
height: 77px;
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
}
}
}
}
.filter-tabs {
display: flex;
gap: 8px;
// 任务列表
.loading-container {
padding: 40px 0;
}
.filter-tab {
padding: 8px 16px;
background: #f5f5f5;
border-radius: 20px;
font-size: 14px;
color: #666;
.task-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 24px;
margin-bottom: 40px;
@media (max-width: 1024px) {
grid-template-columns: 1fr;
}
}
.task-card {
background: #FFFFFF;
border: 1px solid rgba(0, 0, 0, 0.05);
border-radius: 10px;
padding: 40px;
cursor: pointer;
transition: all 0.3s;
min-height: 278px;
&:hover {
background: #ffe6e6;
color: #C62828;
box-shadow: 0 8px 20px rgba(164, 182, 199, 0.2);
transform: translateY(-2px);
}
&.active {
background: #C62828;
color: white;
}
}
.task-list {
display: flex;
flex-direction: column;
gap: 16px;
}
.task-item {
display: flex;
align-items: center;
gap: 20px;
padding: 20px;
border: 1px solid #e0e0e0;
border-radius: 8px;
transition: all 0.3s;
&:hover {
border-color: #C62828;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
}
.task-icon {
width: 48px;
height: 48px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 24px;
flex-shrink: 0;
&.status-not-started {
background: #f5f5f5;
.task-content {
display: flex;
flex-direction: column;
gap: 18px;
// 状态标签 - 小标签,自适应宽度
.status-tag {
align-self: flex-start;
display: inline-flex;
align-items: center;
gap: 4px;
padding: 3px 8px;
font-size: 14px;
font-weight: 500;
line-height: 1.5714285714285714;
border-radius: 2px;
// 待完成 - 红色
&.status-pending {
background-color: #FFECE8;
color: #F53F3F;
}
// 进行中 - 蓝色
&.status-processing {
background-color: #E8F7FF;
color: #3491FA;
}
// 已完成 - 绿色
&.status-completed {
background-color: #E8FFEA;
color: #00B42A;
}
}
}
&.status-in-progress {
background: #fff3e0;
}
&.status-completed {
background: #e8f5e9;
}
}
.task-content {
flex: 1;
h3 {
font-size: 18px;
.task-title {
font-size: 20px;
font-weight: 600;
color: #141F38;
margin-bottom: 8px;
margin: 0;
line-height: 1.4;
}
}
.task-description {
font-size: 14px;
color: #666;
margin-bottom: 12px;
}
.task-meta {
display: flex;
gap: 16px;
font-size: 13px;
}
.task-type {
color: #C62828;
font-weight: 500;
}
.task-deadline {
color: #999;
}
.task-progress {
width: 150px;
flex-shrink: 0;
.progress-bar {
width: 100%;
height: 8px;
background: #f5f5f5;
border-radius: 4px;
.task-desc {
font-size: 14px;
font-weight: 400;
color: #334155;
line-height: 1.5714285714285714;
margin: 0;
flex: 1;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
line-clamp: 2;
overflow: hidden;
margin-bottom: 4px;
text-overflow: ellipsis;
}
.progress-fill {
height: 100%;
background: linear-gradient(90deg, #C62828, #E53935);
transition: width 0.3s;
}
.progress-text {
font-size: 12px;
color: #666;
.task-footer {
display: flex;
justify-content: space-between;
align-items: center;
gap: 20px;
.task-time {
font-size: 14px;
font-weight: 400;
color: #979797;
line-height: 1.5714285714285714;
flex: 1;
}
// 截止时间标签
.deadline-tag {
flex-shrink: 0;
display: inline-flex;
align-items: center;
gap: 4px;
padding: 0 8px;
font-size: 12px;
font-weight: 500;
line-height: 1.6666666666666667;
border-radius: 2px;
border: 1px solid;
background-color: transparent;
// 即将截止 - 红色边框
&.deadline-danger {
border-color: #F53F3F;
color: #F53F3F;
}
// 已截止 - 灰色边框
&.deadline-info {
border-color: #979797;
color: #979797;
}
// 已完成 - 绿色边框
&.deadline-success {
border-color: #00B42A;
color: #00B42A;
}
// 进行中 - 蓝色边框
&.deadline-primary {
border-color: #3491FA;
color: #3491FA;
}
}
}
}
.task-actions {
.empty-state {
padding: 80px 0;
text-align: center;
}
.pagination-container {
display: flex;
gap: 8px;
flex-shrink: 0;
justify-content: center;
margin-top: 40px;
}
</style>

View File

@@ -0,0 +1,4 @@
export { default as StudyPlanLayout } from './StudyPlanLayout.vue';
export { default as StudyPlanView } from './StudyTasksView.vue';
export { default as CourseCenterView } from './CourseCenterView.vue';
export { default as StudyTasksView } from './StudyTasksView.vue';