修改个人中心学习记录

v2
king 1 year ago
parent fd06be84d5
commit 380b7be4fa
  1. 27
      src/pages/my/components/header/time.tsx
  2. 6
      src/pages/my/my.tsx

@ -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) {

@ -8,7 +8,7 @@ import Service from "@/pages/my/components/header/service";
import {Profile} from "@/store";
import Img from "@/components/image/image";
import GreenNike from "@/static/img/greenNike.png"
import {curriculum, userApi} from "@/api";
import {Course, curriculum, userApi} from "@/api";
import LearningRecord from "@/components/learningRecord/learningRecord";
import NavigationBar from "@/components/navigationBar/navigationBar";
import over from "@/static/img/over.png";
@ -36,6 +36,7 @@ const My: FC = () => {
const {token, company, setCompany, user} = Profile.useContainer()
const [companyShow, setCompanyShow] = useState(false)
const [companyList, setCompanyList] = useState<Company[]>([])
const [courseRecord,setCourseRecord] = useState<Course | undefined>(undefined)
const [navbarOpacity, setNavbarOpacity] = useState('0')
const navbarHeight = globalData.statusBarHeight + globalData.textBarHeight;
const [auditMode, setAuditMode] = useState(true)
@ -61,6 +62,7 @@ const My: FC = () => {
Taro.useDidShow(async () => {
try {
const res = await curriculum.course()
setCourseRecord(res)
setAuditMode(!!res?.audit_mode)
const oldList: List[] = JSON.parse(JSON.stringify(list))
oldList[0].time = res.finished_count || 0
@ -95,7 +97,7 @@ const My: FC = () => {
{
!auditMode && <>
<Time/>
<Time courseRecord={courseRecord}/>
<View className="bg-white rounded-20 mb-2 clip">
<View className="flex p-2">
{list.map((d) => (

Loading…
Cancel
Save