diff --git a/.env b/.env index 51b63d7..86e2b46 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ #TARO_APP_API=https://yjx.dev.yaojiankang.top -#TARO_APP_API=https://mooc.yaojiankang.top -TARO_APP_API=https://shopfix.yaojiankang.top +TARO_APP_API=https://mooc.yaojiankang.top +#TARO_APP_API=https://shopfix.yaojiankang.top #TARO_APP_API=https://playedu.yaojiankang.top TARO_APP_LGOIN=true diff --git a/src/pages/my/components/header/time.tsx b/src/pages/my/components/header/time.tsx index a1e6944..5c2fd88 100644 --- a/src/pages/my/components/header/time.tsx +++ b/src/pages/my/components/header/time.tsx @@ -2,7 +2,7 @@ import {Image, View} from "@tarojs/components"; import styles from '../../my.module.scss' import Taro from "@tarojs/taro"; import {curriculum} from "@/api"; -import {FC, useState} from "react"; +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"; @@ -28,20 +28,17 @@ const Time: FC = () => { // {title: '未完成(必修)', time: '0', src: incomplete, type: 4}, ]) - - Taro.useDidShow(async () => { - try { - const res = await curriculum.course() + useEffect(() => { + curriculum.course().then(res => { 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[2].time = res.finished_count + // oldList[3].time = res.not_finished_count setList(oldList) - } catch (e) { - } + }) }) function jump(type?: number) { diff --git a/src/pages/my/my.tsx b/src/pages/my/my.tsx index 9986748..93a34f3 100644 --- a/src/pages/my/my.tsx +++ b/src/pages/my/my.tsx @@ -61,10 +61,10 @@ const My: FC = () => { Taro.useDidShow(async () => { try { const res = await curriculum.course() - setAuditMode(res.audit_mode) + setAuditMode(!!res?.audit_mode) const oldList: List[] = JSON.parse(JSON.stringify(list)) - oldList[1].time = res.finished_count || 0 - oldList[2].time = res.not_finished_count || 0 + oldList[0].time = res.finished_count || 0 + oldList[1].time = res.not_finished_count || 0 setList(oldList) } catch (e) { }