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 = () => {