新增学习记录加载动画

v2
king 1 year ago
parent 70e61e187e
commit 485bc0815b
  1. 4
      .env
  2. 19
      src/components/learningRecord/learningRecord.tsx
  3. 2
      src/components/lineChart/lineChart.tsx
  4. 13
      src/components/spinner/style.scss

@ -1,5 +1,5 @@
TARO_APP_API=https://yjx.dev.yaojiankang.top #TARO_APP_API=https://yjx.dev.yaojiankang.top
#TARO_APP_API=https://mooc.yaojiankang.top TARO_APP_API=https://mooc.yaojiankang.top
#TARO_APP_API=https://shopfix.yaojiankang.top #TARO_APP_API=https://shopfix.yaojiankang.top
#TARO_APP_API=https://playedu.yaojiankang.top #TARO_APP_API=https://playedu.yaojiankang.top
TARO_APP_LGOIN=true TARO_APP_LGOIN=true

@ -5,6 +5,7 @@ import LineChart from "@/components/lineChart/lineChart";
import {FC, useEffect, useState} from "react"; import {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";
const tabList: TabList<any>[] = [ const tabList: TabList<any>[] = [
{ {
@ -38,16 +39,19 @@ interface Props {
*/ */
const LearningRecord: FC<Props> = ({userId}) => { const LearningRecord: FC<Props> = ({userId}) => {
const [lineData, setLineData] = useState<any[]>([]) const [lineData, setLineData] = useState<any[]>([])
const [loading, setLoading] = useState(false)
async function getStatistics(data: StatisticsParam) { async function getStatistics(data: StatisticsParam) {
try { try {
setLoading(true)
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>) {
@ -60,13 +64,16 @@ const LearningRecord: FC<Props> = ({userId}) => {
return (<View className={styles.box} style={{display: 'block'}}> return (<View className={styles.box} style={{display: 'block'}}>
<Tabs tabList={tabList} onChange={tabChange} backMode/> <Tabs tabList={tabList} onChange={tabChange} backMode/>
<View className={styles.total}> <View style={{position: "relative"}}>
<Spin enable={loading} block/>
<Text style={{margin: '0 10px', color: '#00D6AC'}}> <View className={styles.total}>
{formatTime(lineData.reduce((pre, cur) => pre + cur.value, 0) || 0)}
</Text> <Text style={{margin: '0 10px', color: '#00D6AC'}}>
{formatTime(lineData.reduce((pre, cur) => pre + cur.value, 0) || 0)}
</Text>
</View>
<LineChart data={lineData}/>
</View> </View>
<LineChart data={lineData}/>
</View>) </View>)
} }

@ -35,7 +35,7 @@ const LineChart: FC<Props> = ({data}) => {
</View> </View>
<ScrollView scrollX={!!maxHeight.value} enhanced showScrollbar={false}> <ScrollView scrollX={!!maxHeight.value} enhanced showScrollbar={false}>
<View className={style.lineChart}> <View className={style.lineChart}>
{!maxHeight.value && <View className={style.empty}></View>} {!maxHeight.value && <View className={style.empty}></View>}
{ {
!!maxHeight.value && lineChartList.map(d => <View key={d.time}> !!maxHeight.value && lineChartList.map(d => <View key={d.time}>
<View className={style.columnBox} style={{width: "100px"}}> <View className={style.columnBox} style={{width: "100px"}}>

@ -5,9 +5,16 @@
width: auto; width: auto;
position: absolute; position: absolute;
z-index: 99999; z-index: 99999;
left: 50%; background-color: rgba(#fff, 1.0);
top: 50%; width: 100%;
transform: translate(-50%, -50%); height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
//left: 50%;
//top: 50%;
//transform: translate(-50%, -50%);
} }
&.is-fixed { &.is-fixed {

Loading…
Cancel
Save