From cecc425f174c92bdb22c021b387cee86b059da13 Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Fri, 8 Sep 2023 17:55:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=91=E7=9A=84=E5=AD=A6=E4=B9=A0=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 4 ++-- src/pages/my/components/header/time.tsx | 15 ++++++--------- src/pages/my/my.tsx | 6 +++--- 3 files changed, 11 insertions(+), 14 deletions(-) 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) { }