From 4d2b83b9509541cfc5dfefb01a7a12b53b59452c Mon Sep 17 00:00:00 2001 From: xing <2229249788@qq.com> Date: Tue, 5 Sep 2023 21:06:38 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E6=96=87=E7=AB=A0=E6=A0=87?= =?UTF-8?q?=E9=A2=98=E5=92=8C=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4=202.?= =?UTF-8?q?=E6=9C=AA=E7=99=BB=E5=BD=95=E6=83=85=E5=86=B5=E4=B8=8B=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=88=91=E7=9A=84=E9=A1=B5=E9=9D=A2=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=8C=BA=E5=BA=94=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../learningRecord/learningRecord.tsx | 11 +++- src/components/spinner/index.tsx | 6 +- src/pages/my/my.tsx | 11 ++-- src/pages/preview/brand/article/article.tsx | 2 - src/pages/preview/illness/article/article.tsx | 60 ++++++++++++------- 5 files changed, 54 insertions(+), 36 deletions(-) diff --git a/src/components/learningRecord/learningRecord.tsx b/src/components/learningRecord/learningRecord.tsx index c4118e9..4313472 100644 --- a/src/components/learningRecord/learningRecord.tsx +++ b/src/components/learningRecord/learningRecord.tsx @@ -6,6 +6,8 @@ import {FC, useEffect, useState} from "react"; import {StatisticsParam, userApi} from "@/api"; import styles from './learningRecord.module.scss' import Spin from "@/components/spinner"; +import {Profile} from "@/store"; +import Taro from "@tarojs/taro"; const tabList: TabList[] = [ { @@ -30,7 +32,7 @@ const tabList: TabList[] = [ ] interface Props { - userId: string | number + userId?: string | number } @@ -40,9 +42,10 @@ interface Props { const LearningRecord: FC = ({userId}) => { const [lineData, setLineData] = useState([]) const [loading, setLoading] = useState(false) - + const {token} = Profile.useContainer() async function getStatistics(data: StatisticsParam) { + if (!userId) return; try { setLoading(true) const res = await userApi.statistics(userId, data) @@ -55,6 +58,10 @@ const LearningRecord: FC = ({userId}) => { } function tabChange({tab}: OnChangOpt) { + if (!token) { + Taro.navigateTo({url: '/pages/login/login'}) + return + } getStatistics(tab?.value! as StatisticsParam) } diff --git a/src/components/spinner/index.tsx b/src/components/spinner/index.tsx index a99d6f9..0e08962 100644 --- a/src/components/spinner/index.tsx +++ b/src/components/spinner/index.tsx @@ -138,9 +138,9 @@ export default class Spin extends Component { this.setState((s) => ({...s, ...state})) } - // componentDidMount(): void { - // this.controller.setTick(this.props.enable) - // } + componentDidMount(): void { + this.controller.setTick(this.props.enable) + } componentDidUpdate(): void { this.controller.setTick(this.props.enable) diff --git a/src/pages/my/my.tsx b/src/pages/my/my.tsx index cf62fcb..2c00ac0 100644 --- a/src/pages/my/my.tsx +++ b/src/pages/my/my.tsx @@ -84,12 +84,11 @@ const My: FC = () => {