|
|
@ -5,7 +5,7 @@ import LineChart from "@/components/lineChart/lineChart"; |
|
|
|
import {CSSProperties, FC, useEffect, useState} from "react"; |
|
|
|
import {CSSProperties, FC, useEffect, useState} from "react"; |
|
|
|
import {StatisticsParam, userApi} from "@/api"; |
|
|
|
import {StatisticsParam, userApi} from "@/api"; |
|
|
|
import styles from './learningRecord.module.scss' |
|
|
|
import styles from './learningRecord.module.scss' |
|
|
|
import Spin from "@/components/spinner"; |
|
|
|
// import Spin from "@/components/spinner";
|
|
|
|
import {Profile} from "@/store"; |
|
|
|
import {Profile} from "@/store"; |
|
|
|
import Taro from "@tarojs/taro"; |
|
|
|
import Taro from "@tarojs/taro"; |
|
|
|
|
|
|
|
|
|
|
@ -43,20 +43,19 @@ interface Props { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
const LearningRecord: FC<Props> = ({userId, style, className}) => { |
|
|
|
const LearningRecord: FC<Props> = ({userId, style, className}) => { |
|
|
|
const [lineData, setLineData] = useState<any[]>([]) |
|
|
|
const [lineData, setLineData] = useState<any[]>([]) |
|
|
|
const [loading, setLoading] = useState(false) |
|
|
|
// const [loading, setLoading] = useState(false)
|
|
|
|
const {token} = Profile.useContainer() |
|
|
|
const {token} = Profile.useContainer() |
|
|
|
|
|
|
|
|
|
|
|
async function getStatistics(data: StatisticsParam) { |
|
|
|
async function getStatistics(data: StatisticsParam) { |
|
|
|
if (!userId) return; |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
setLoading(true) |
|
|
|
if (!userId) return; |
|
|
|
|
|
|
|
setLineData([]) |
|
|
|
const res = await userApi.statistics(userId, data) |
|
|
|
const res = await userApi.statistics(userId, data) |
|
|
|
const everyDayValue = everyDay(data.start_time, Number(data.end_time), res.data) |
|
|
|
const everyDayValue = everyDay(data.start_time, Number(data.end_time), res.data) |
|
|
|
setLineData(everyDayValue) |
|
|
|
setLineData(everyDayValue) |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
setLineData([]) |
|
|
|
setLineData([]) |
|
|
|
} |
|
|
|
} |
|
|
|
setLoading(false) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function tabChange({tab}: OnChangOpt<StatisticsParam>) { |
|
|
|
function tabChange({tab}: OnChangOpt<StatisticsParam>) { |
|
|
@ -74,7 +73,7 @@ const LearningRecord: FC<Props> = ({userId, style, className}) => { |
|
|
|
return (<View className={[styles.box, className].filter(Boolean).join(' ')} style={{display: 'block', ...style}}> |
|
|
|
return (<View className={[styles.box, className].filter(Boolean).join(' ')} style={{display: 'block', ...style}}> |
|
|
|
<Tabs tabList={tabList} onChange={tabChange} backMode/> |
|
|
|
<Tabs tabList={tabList} onChange={tabChange} backMode/> |
|
|
|
<View style={{position: "relative"}}> |
|
|
|
<View style={{position: "relative"}}> |
|
|
|
<Spin enable={loading} block/> |
|
|
|
{/*<Spin enable={loading} block/>*/} |
|
|
|
<View className={styles.total}> |
|
|
|
<View className={styles.total}> |
|
|
|
总共学习 |
|
|
|
总共学习 |
|
|
|
<Text style={{margin: '0 10px', color: '#00D6AC'}}> |
|
|
|
<Text style={{margin: '0 10px', color: '#00D6AC'}}> |
|
|
|