diff --git a/src/components/videoCover/videoCover.scss b/src/components/videoCover/videoCover.scss index 3a64267..ba15b0e 100644 --- a/src/components/videoCover/videoCover.scss +++ b/src/components/videoCover/videoCover.scss @@ -74,7 +74,7 @@ } .videoButton { - margin-top: 10rpx; + margin-top: 20rpx; color: #909795; font-size: 22rpx; } diff --git a/src/pages/index/components/videoList.tsx b/src/pages/index/components/videoList.tsx index f734078..c19f6ab 100644 --- a/src/pages/index/components/videoList.tsx +++ b/src/pages/index/components/videoList.tsx @@ -60,18 +60,25 @@ export const VideoList: FC = ({categoryKey, setCategoryKey}) => { function rateOfLearning(id: number, class_hour: number): JSX.Element { - switch (categoryKey) { - case "is_required": - case "is_not_required": - const find = records.find(d => d?.course_id === id) - if (find) { - if (class_hour === find.finished_count) { - return 已完成 - } - return ({`共${class_hour}节/已学${find.finished_count}节`}) - } - return ({`共${class_hour}节/已学0节`}) + const find = records.find(d => d?.course_id === id) + if (find) { + if (class_hour === find.finished_count) { + return 已完成 + } + return ({`共${class_hour}节/已学${find.finished_count}节`}) + } + return ({`共${class_hour}节/已学0节`}) + } + + function rateOfPercent(id: number, class_hour: number): string { + const find = records.find(d => d?.course_id === id) + if (find) { + if (class_hour === find.finished_count) { + return '100%' + } + return ` ${((find.finished_count / class_hour) * 100).toFixed(0)}%` } + return '0%' } @@ -117,6 +124,7 @@ export const VideoList: FC = ({categoryKey, setCategoryKey}) => { key={c.id} time={formatMinute(c.course_duration)} content={rateOfLearning(c.id, c.class_hour)} + schedule={`学习进度${rateOfPercent(c.id, c.class_hour)}`} />) }