学习进度

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

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

@ -60,18 +60,25 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => {
function rateOfLearning(id: number, class_hour: number): JSX.Element { function rateOfLearning(id: number, class_hour: number): JSX.Element {
switch (categoryKey) { const find = records.find(d => d?.course_id === id)
case "is_required": if (find) {
case "is_not_required": if (class_hour === find.finished_count) {
const find = records.find(d => d?.course_id === id) return <View></View>
if (find) { }
if (class_hour === find.finished_count) { return (<View>{`${class_hour}节/已学${find.finished_count}`}</View>)
return <View></View> }
} return (<View>{`${class_hour}节/已学0节`}</View>)
return (<View>{`${class_hour}节/已学${find.finished_count}`}</View>) }
}
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} key={c.id}
time={formatMinute(c.course_duration)} time={formatMinute(c.course_duration)}
content={rateOfLearning(c.id, c.class_hour)} content={rateOfLearning(c.id, c.class_hour)}
schedule={`学习进度${rateOfPercent(c.id, c.class_hour)}`}
/>) />)
} }
</View> </View>

Loading…
Cancel
Save