|
|
|
@ -1,13 +1,11 @@ |
|
|
|
|
import {Image, View} from "@tarojs/components"; |
|
|
|
|
import styles from '../../my.module.scss' |
|
|
|
|
import Taro from "@tarojs/taro"; |
|
|
|
|
import {curriculum} from "@/api"; |
|
|
|
|
import {Course} from "@/api"; |
|
|
|
|
import {FC, useEffect, useState} from "react"; |
|
|
|
|
import {formatMinute} from "@/utils/time"; |
|
|
|
|
import time1 from "@/static/img/time1.png"; |
|
|
|
|
import time2 from "@/static/img/time2.png"; |
|
|
|
|
// import over from '@/static/img/over.png'
|
|
|
|
|
// import incomplete from '@/static/img/incomplete.png'
|
|
|
|
|
import {Profile} from "@/store"; |
|
|
|
|
|
|
|
|
|
interface List { |
|
|
|
@ -17,29 +15,24 @@ interface List { |
|
|
|
|
type?: number |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const Time: FC = () => { |
|
|
|
|
interface Props { |
|
|
|
|
courseRecord: Course | undefined |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const Time: FC<Props> = ({courseRecord}) => { |
|
|
|
|
const {token} = Profile.useContainer() |
|
|
|
|
const [list, setList] = useState<List[]>([ |
|
|
|
|
{title: '今日时长', time: '00:00', src: time1}, |
|
|
|
|
{title: '累计时长', time: '00:00', src: time2}, |
|
|
|
|
// {title: '必修课', time: '0', src: curriculum1, type: 1},
|
|
|
|
|
// {title: '选修课', time: '0', src: curriculum2, type: 2},
|
|
|
|
|
// {title: '已完成', time: '0', src: over, type: 3},
|
|
|
|
|
// {title: '未完成(必修)', time: '0', src: incomplete, type: 4},
|
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
curriculum.course().then(res => { |
|
|
|
|
if (!courseRecord) return; |
|
|
|
|
const oldList: List[] = JSON.parse(JSON.stringify(list)) |
|
|
|
|
oldList[0].time = formatMinute(res.today_learn_time) |
|
|
|
|
oldList[1].time = formatMinute(res.total_learn_time) |
|
|
|
|
// oldList[2].time = res.required_count
|
|
|
|
|
// oldList[3].time = res.not_required_count
|
|
|
|
|
// oldList[2].time = res.finished_count
|
|
|
|
|
// oldList[3].time = res.not_finished_count
|
|
|
|
|
oldList[0].time = formatMinute(courseRecord.today_learn_time) |
|
|
|
|
oldList[1].time = formatMinute(courseRecord.total_learn_time) |
|
|
|
|
setList(oldList) |
|
|
|
|
}) |
|
|
|
|
}, []) |
|
|
|
|
}, [courseRecord]) |
|
|
|
|
|
|
|
|
|
function jump(type?: number) { |
|
|
|
|
if (!token) { |
|
|
|
|