|
|
@@ -15,12 +15,12 @@
|
|
|
<div class="course-items-container">
|
|
|
<el-card v-for="item in getCoursesSlice(0, 5)" :key="item.courseId" class="course-item active" @click="handleClick(item.courseId)">
|
|
|
<div style="width: 200px; height: 120px">
|
|
|
- <img :src="item.courseImages[0]" :alt="item.courseName" class="course-item-img">
|
|
|
+ <img :src="convertImageUrl(item.courseImages[0], item.courseName)" :alt="item.courseName" class="course-item-img">
|
|
|
</div>
|
|
|
<div class="course-item-content">
|
|
|
<div style="font-weight: bold; font-size: 16px; margin: 5px 0">{{item.courseName}}</div>
|
|
|
<div style="line-height: 1.5" class="collapsed" ><span style="color: rgba(0, 0, 0, 0.6)">课程描述:</span>{{item.description}}</div>
|
|
|
- <div style="line-height: 1.5; margin-top: 5px" class="collapsed" ><span style="color: rgba(0, 0, 0, 0.6)">任课教师:</span>{{item.teacherIds.join(",")}}</div>
|
|
|
+ <div style="line-height: 1.5; margin-top: 5px" class="collapsed" ><span style="color: rgba(0, 0, 0, 0.6)">任课教师:</span>{{item.teacherNames.join(",")}}</div>
|
|
|
</div>
|
|
|
</el-card>
|
|
|
|
|
|
@@ -33,12 +33,12 @@
|
|
|
<div class="course-items-container">
|
|
|
<el-card v-for="item in getCoursesSlice(5, 10)" :key="item.courseId" class="course-item active" @click="handleClick(item.courseId)">
|
|
|
<div style="width: 200px; height: 120px">
|
|
|
- <img :src="item.courseImages[0]" :alt="item.courseName" class="course-item-img">
|
|
|
+ <img :src="convertImageUrl(item.courseImages[0], item.courseName)" :alt="item.courseName" class="course-item-img">
|
|
|
</div>
|
|
|
<div class="course-item-content">
|
|
|
<div style="font-weight: bold; font-size: 16px; margin: 5px 0">{{item.courseName}}</div>
|
|
|
<div style="line-height: 1.5" class="collapsed" ><span style="color: rgba(0, 0, 0, 0.6)">课程描述:</span>{{item.description}}</div>
|
|
|
- <div style="line-height: 1.5; margin-top: 5px" class="collapsed" ><span style="color: rgba(0, 0, 0, 0.6)">任课教师:</span>{{item.teacherIds.join(",")}}</div>
|
|
|
+ <div style="line-height: 1.5; margin-top: 5px" class="collapsed" ><span style="color: rgba(0, 0, 0, 0.6)">任课教师:</span>{{item.teacherNames.join(",")}}</div>
|
|
|
</div>
|
|
|
</el-card>
|
|
|
|
|
|
@@ -70,6 +70,7 @@ import type {CourseQuery} from "@/types/query";
|
|
|
import router from "@/router";
|
|
|
import {useStore} from "@/store";
|
|
|
import {Refresh, Search} from "@element-plus/icons-vue";
|
|
|
+import {convertImageUrl} from "@/utils/convertUtil";
|
|
|
|
|
|
const apis = useApis()
|
|
|
const store = useStore()
|
|
|
@@ -171,29 +172,12 @@ const fetchData = () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const processData = () => {
|
|
|
- for(let i:number = 0; i < pageInfo.courseData.length; i++){
|
|
|
- for(let j = 0; j < pageInfo.courseData[i].teacherIds.length; j++){
|
|
|
- apis.findUserById(pageInfo.courseData[i].teacherIds[j])
|
|
|
- .then((res:any) => {
|
|
|
- pageInfo.courseData[i].teacherIds[j] = res.data.data.records[0].name
|
|
|
- })
|
|
|
- .catch((err:any) => {
|
|
|
- console.log("错误信息",err)
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- for(let i:number = 0; i < pageInfo.courseData.length; i++){
|
|
|
- pageInfo.courseData[i].courseImages[0] = pageInfo.courseData[i].courseImages[0].split("?")[0]
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
const fetchAllCourse = () => {
|
|
|
apis.getAllCourse(query, queryInfo.pageNow, queryInfo.pageSize)
|
|
|
.then((res: any) => {
|
|
|
console.log(res)
|
|
|
pageInfo.courseData = res.data.data.records
|
|
|
- processData()
|
|
|
pageInfo.total = res.data.data.total
|
|
|
Object.assign(pageInfo2Show, pageInfo)
|
|
|
})
|
|
|
@@ -205,11 +189,10 @@ const fetchAllCourse = () => {
|
|
|
|
|
|
const fetchCourseByUserId = () => {
|
|
|
if(role === 'student'){
|
|
|
- apis.getCourseByStudentId(store.user.id, queryInfo.pageNow, queryInfo.pageSize)
|
|
|
+ apis.getCourseByStudentId(queryInfo.pageNow, queryInfo.pageSize)
|
|
|
.then((res: any) => {
|
|
|
console.log(res)
|
|
|
pageInfo.courseData = res.data.data.records
|
|
|
- processData()
|
|
|
pageInfo.total = res.data.data.total
|
|
|
Object.assign(pageInfo2Show, pageInfo)
|
|
|
})
|
|
|
@@ -218,11 +201,10 @@ const fetchCourseByUserId = () => {
|
|
|
})
|
|
|
.finally(() => {});
|
|
|
} else if(role === "teachers"){
|
|
|
- apis.getCourseByTeacherId(store.user.id, queryInfo.pageNow, queryInfo.pageSize)
|
|
|
+ apis.getCourseByTeacherId(queryInfo.pageNow, queryInfo.pageSize)
|
|
|
.then((res: any) => {
|
|
|
console.log(res.data.data)
|
|
|
pageInfo.courseData = res.data.data.records
|
|
|
- processData()
|
|
|
pageInfo.total = res.data.data.total
|
|
|
Object.assign(pageInfo2Show, pageInfo)
|
|
|
})
|