|
|
@ -8,7 +8,7 @@ import CustomPageContainer from "@/components/custom-page-container/custom-page- |
|
|
|
|
|
|
|
|
|
|
|
const CurHistory = () => { |
|
|
|
const CurHistory = () => { |
|
|
|
const [show, setShow] = useState(false) |
|
|
|
const [show, setShow] = useState(false) |
|
|
|
const {course_id, name} = Taro.getCurrentInstance().preloadData as { course_id: number, name: string } |
|
|
|
const {course_id} = Taro.getCurrentInstance().router?.params as unknown as { course_id: string } |
|
|
|
const [data, setData] = useState<userRecord[]>([]) |
|
|
|
const [data, setData] = useState<userRecord[]>([]) |
|
|
|
const [course, setCourse] = useState<Curriculum | null>(null) |
|
|
|
const [course, setCourse] = useState<Curriculum | null>(null) |
|
|
|
const [hours, setHours] = useState<Hour[] | null>(null) |
|
|
|
const [hours, setHours] = useState<Hour[] | null>(null) |
|
|
@ -16,7 +16,7 @@ const CurHistory = () => { |
|
|
|
const [time, setTime] = useState<Record<number, { start: number, end: number }> | null>(null) |
|
|
|
const [time, setTime] = useState<Record<number, { start: number, end: number }> | null>(null) |
|
|
|
|
|
|
|
|
|
|
|
Taro.useLoad(() => { |
|
|
|
Taro.useLoad(() => { |
|
|
|
Taro.setNavigationBarTitle({title: name}) |
|
|
|
// Taro.setNavigationBarTitle({title: name})
|
|
|
|
userApi.courseRecord(course_id).then(res => { |
|
|
|
userApi.courseRecord(course_id).then(res => { |
|
|
|
setData(Object.values(res.data)) |
|
|
|
setData(Object.values(res.data)) |
|
|
|
setCourse(res.course) |
|
|
|
setCourse(res.course) |
|
|
@ -37,37 +37,48 @@ const CurHistory = () => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getTime(id: number): string { |
|
|
|
function getTime(id: number): string { |
|
|
|
const start = formatDateTime(new Date(time?.[id].start || 0), 'MM/dd HH:mm') |
|
|
|
const day = formatDateTime(new Date(time?.[id].start || 0), 'MM-dd') |
|
|
|
const end = formatDateTime(new Date(time?.[id].end || 0), 'MM/dd HH:mm') |
|
|
|
const start = formatDateTime(new Date(time?.[id].start || 0), 'HH:mm:ss') |
|
|
|
return `${start} - ${end}` |
|
|
|
const end = formatDateTime(new Date(time?.[id].end || 0), 'HH:mm:ss') |
|
|
|
|
|
|
|
return `${day} ${start} - ${end}` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getCurTime(startNow: string, endNow: string): string { |
|
|
|
|
|
|
|
const day = formatDateTime(new Date(startNow), 'MM-dd') |
|
|
|
|
|
|
|
const start = formatDateTime(new Date(startNow), 'HH:mm:ss') |
|
|
|
|
|
|
|
const end = formatDateTime(new Date(endNow), 'HH:mm:ss') |
|
|
|
|
|
|
|
return `${day} ${start} - ${end}` |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function hourPercent(id: number, duration: number): number { |
|
|
|
function hourPercent(id: number, duration: number): number { |
|
|
|
const viewingTime = durations?.[id] || 0 |
|
|
|
const viewingTime = durations?.[id] || 0 |
|
|
|
console.log(viewingTime,duration) |
|
|
|
|
|
|
|
return Number((viewingTime / duration * 100).toFixed(2)) |
|
|
|
return Number((viewingTime / duration * 100).toFixed(2)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<View className={styles.page}> |
|
|
|
<View className={styles.page}> |
|
|
|
<View className={styles.cur}> |
|
|
|
<View className={styles.cur}> |
|
|
|
<Image className='image' src={course?.thumb || ''} mode='widthFix'/> |
|
|
|
<Image className={styles.image} src={course?.thumb || ''} mode='center'/> |
|
|
|
<View className='px-3'>{name}</View> |
|
|
|
<View className={styles.classHour}>共{course?.class_hour}节/已学{course?.finished_hour_count || 0}节</View> |
|
|
|
|
|
|
|
<View className={styles.title}>{course?.title}</View> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<View className={styles.record}> |
|
|
|
<View className={styles.record}> |
|
|
|
{data.map(d => <View key={d.id} onClick={() => setHour(d.unique_ident)} className={styles.recordItem}> |
|
|
|
{data.map((d, index) => <View key={d.id} onClick={() => setHour(d.unique_ident)} className={styles.recordItem}> |
|
|
|
<View>{formatDateTime(new Date(d.start_at), "MM/dd HH:ss")} - {formatDateTime(new Date(d.end_at), "MM/dd HH:ss")}</View> |
|
|
|
<View className='text-hover-dark'>第{index + 1}次观看</View> |
|
|
|
|
|
|
|
<View>{getCurTime(d.start_at, d.end_at)} </View> |
|
|
|
<View>观看视频:{formatMinute(d.duration)}</View> |
|
|
|
<View>观看视频:{formatMinute(d.duration)}</View> |
|
|
|
<Progress |
|
|
|
<Progress |
|
|
|
|
|
|
|
className={styles.progress} |
|
|
|
percent={percent(d.duration)} |
|
|
|
percent={percent(d.duration)} |
|
|
|
showInfo |
|
|
|
showInfo |
|
|
|
borderRadius={10} |
|
|
|
borderRadius={10} |
|
|
|
active |
|
|
|
active |
|
|
|
duration={10} |
|
|
|
duration={10} |
|
|
|
strokeWidth={10} |
|
|
|
strokeWidth={10} |
|
|
|
color={'#45D4A8'} |
|
|
|
color='#45D4A8' |
|
|
|
|
|
|
|
activeColor='#45D4A8' |
|
|
|
/> |
|
|
|
/> |
|
|
|
</View>)} |
|
|
|
</View>)} |
|
|
|
</View> |
|
|
|
</View> |
|
|
@ -75,11 +86,11 @@ const CurHistory = () => { |
|
|
|
<CustomPageContainer |
|
|
|
<CustomPageContainer |
|
|
|
show={show} |
|
|
|
show={show} |
|
|
|
round |
|
|
|
round |
|
|
|
onAfterLeave={() => setShow(false)}> |
|
|
|
position='bottom' |
|
|
|
|
|
|
|
onClickOverlay={() => setShow(false)}> |
|
|
|
{show && <View className={styles.hourRecord}> |
|
|
|
{show && <View className={styles.hourRecord}> |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{hours?.map(d => <View> |
|
|
|
hours?.map(d => <View> |
|
|
|
|
|
|
|
<View className={styles.recordItem}> |
|
|
|
<View className={styles.recordItem}> |
|
|
|
<View>{d.title}</View> |
|
|
|
<View>{d.title}</View> |
|
|
|
<View>{getTime(d.id)}</View> |
|
|
|
<View>{getTime(d.id)}</View> |
|
|
@ -91,11 +102,11 @@ const CurHistory = () => { |
|
|
|
active |
|
|
|
active |
|
|
|
strokeWidth={10} |
|
|
|
strokeWidth={10} |
|
|
|
color={'#45D4A8'} |
|
|
|
color={'#45D4A8'} |
|
|
|
|
|
|
|
activeColor={'#45D4A8'} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
) |
|
|
|
)} |
|
|
|
} |
|
|
|
|
|
|
|
</View>} |
|
|
|
</View>} |
|
|
|
</CustomPageContainer> |
|
|
|
</CustomPageContainer> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|