学习进度

v2
king 1 year ago
parent 9f5e6af772
commit 13c6a2d7b9
  1. 2
      src/components/videoCover/videoCover.scss
  2. 14
      src/pages/index/components/videoList.tsx

@ -74,7 +74,7 @@
}
.videoButton {
margin-top: 10rpx;
margin-top: 20rpx;
color: #909795;
font-size: 22rpx;
}

@ -60,9 +60,6 @@ export const VideoList: FC<Props> = ({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) {
@ -72,6 +69,16 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => {
}
return (<View>{`${class_hour}节/已学0节`}</View>)
}
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<Props> = ({categoryKey, setCategoryKey}) => {
key={c.id}
time={formatMinute(c.course_duration)}
content={rateOfLearning(c.id, c.class_hour)}
schedule={`学习进度${rateOfPercent(c.id, c.class_hour)}`}
/>)
}
</View>

Loading…
Cancel
Save