首页onshow 过滤

main
king 1 year ago
parent 164511130e
commit 88db099a7d
  1. 1
      src/components/lineChart/lineChart.module.scss
  2. 2
      src/components/lineChart/lineChart.tsx
  3. 5
      src/components/topic/judge.tsx
  4. 4
      src/components/video/video.tsx
  5. 25
      src/pages/index/components/videoList.tsx
  6. 9
      src/pages/manage/userInfo/userInfo.tsx

@ -5,7 +5,6 @@
flex-wrap: nowrap; flex-wrap: nowrap;
height: 420px; height: 420px;
position: relative; position: relative;
margin-top: 30rpx;
} }
.empty { .empty {

@ -30,7 +30,7 @@ const LineChart: FC<Props> = ({data}) => {
return ( return (
<> <>
<ScrollView scrollX={!!maxHeight.value}> <ScrollView scrollX={!!maxHeight.value}>
{maxHeight.time && <View>{maxHeight.time}{formatMinute(maxHeight.value)}</View>} <View style={{marginBottom: '30px'}}>{maxHeight.time}{formatMinute(maxHeight.value)}</View>
<View className={style.lineChart}> <View className={style.lineChart}>
{!maxHeight.value && <View className={style.empty}></View>} {!maxHeight.value && <View className={style.empty}></View>}

@ -1,5 +1,5 @@
import {FC, useEffect, useState} from "react"; import {FC, useEffect, useState} from "react";
import { Radio, RadioGroup, Text, View} from "@tarojs/components"; import {Radio, RadioGroup, Text, View} from "@tarojs/components";
import './topic.scss' import './topic.scss'
interface Props { interface Props {
@ -11,7 +11,7 @@ interface Props {
const Judge: FC<Props> = ({data, onAnswer, validate, frequency}) => { const Judge: FC<Props> = ({data, onAnswer, validate, frequency}) => {
const [rightAnswer, setRightAnswer] = useState<string | null>(null) //答案 const [rightAnswer, setRightAnswer] = useState<string | null>(null) //答案
const rightKey = data.right_answer ? 'correct' : 'error' // 正确答案数组 const rightKey = data.right_answer === 'true' ? 'correct' : 'error' // 正确答案数组
const [error, setError] = useState(false) const [error, setError] = useState(false)
@ -55,7 +55,6 @@ const Judge: FC<Props> = ({data, onAnswer, validate, frequency}) => {
</RadioGroup> </RadioGroup>
{error && frequency == 0 && <View className='mt-3'> {error && frequency == 0 && <View className='mt-3'>
<View className='right_answer'>{data.right_answer ? '正确' : '错误'}</View> <View className='right_answer'>{data.right_answer ? '正确' : '错误'}</View>
<View className='font-weight my-3'></View> <View className='font-weight my-3'></View>

@ -45,7 +45,9 @@ const HVideo: FC<HVideoOptions> = (opt: HVideoOptions) => {
video?.pause() video?.pause()
video?.seek(d - deviation) video?.seek(d - deviation)
if (process.env.TARO_ENV === 'h5') { if (process.env.TARO_ENV === 'h5') {
document?.exitFullscreen() try {
document?.exitFullscreen().then()
} catch (e) {}
} }
video?.exitFullScreen() video?.exitFullScreen()

@ -24,10 +24,29 @@ export const VideoList: FC<Props> = ({categoryKey, ready}) => {
const [page, setPage] = useState(1) const [page, setPage] = useState(1)
const [records, setRecords] = useState<LearnRecord[]>([]) const [records, setRecords] = useState<LearnRecord[]>([])
function screen(oldData: Curriculum[], data: Curriculum[]): Curriculum[] {
return data.reduce((pre, cur) => {
const index = pre.findIndex(d => d.id === cur.id)
if (index === -1) {
pre.push(cur)
} else {
pre.splice(index, 1, cur)
}
return pre
}, oldData)
}
async function getData() { async function getData() {
try { try {
const res = await publicApi.course({page: 1, pageSize: 10 * page}) const res = await publicApi.course({page: page, pageSize: 10})
setData(res)
const old: Courses = JSON.parse(JSON.stringify(data))
setData({
is_finished: screen(old.is_finished, res.is_finished || []),
is_required: screen(old.is_required, res.is_required || []),
is_not_finished: screen(old.is_not_finished, res.is_not_finished || []),
is_not_required: screen(old.is_not_required, res.is_not_required || []),
})
} catch (e) { } catch (e) {
} }
} }
@ -64,6 +83,7 @@ export const VideoList: FC<Props> = ({categoryKey, ready}) => {
}) })
eventsIndex.on(({id}) => { eventsIndex.on(({id}) => {
if (id == null) return;
for (const [index, notFinished] of data.is_not_finished.entries()) { for (const [index, notFinished] of data.is_not_finished.entries()) {
if (notFinished.id === id) { if (notFinished.id === id) {
data.is_finished.push(notFinished) data.is_finished.push(notFinished)
@ -75,6 +95,7 @@ export const VideoList: FC<Props> = ({categoryKey, ready}) => {
useDidShow(() => { useDidShow(() => {
if (ready) { if (ready) {
getData().then()
getRecords().then() getRecords().then()
} }
}) })

@ -7,7 +7,7 @@ import Tabs, {OnChangOpt, TabList} from "@/components/tabs/tabs";
import MyButton from "@/components/button/MyButton"; import MyButton from "@/components/button/MyButton";
import {ManageApi, StatisticsParam, userApi} from "@/api"; import {ManageApi, StatisticsParam, userApi} from "@/api";
import {Profile} from "@/store"; import {Profile} from "@/store";
import {everyDay, getMonday, getSunday, monthEnd, monthFirst} from "@/utils/time"; import {everyDay, formatMinute, getMonday, getSunday, monthEnd, monthFirst} from "@/utils/time";
import LineChart from "@/components/lineChart/lineChart"; import LineChart from "@/components/lineChart/lineChart";
@ -74,7 +74,8 @@ const UserInfo: FC = () => {
await ManageApi.del(userId) await ManageApi.del(userId)
Taro.showToast({title: '删除成功'}) Taro.showToast({title: '删除成功'})
Taro.navigateBack() Taro.navigateBack()
} catch (e) {} } catch (e) {
}
} }
} }
}) })
@ -117,7 +118,9 @@ const UserInfo: FC = () => {
<Tabs tabList={tabList} onChange={tabChange}/> <Tabs tabList={tabList} onChange={tabChange}/>
<View className='font-weight font-36 mt-5 mb-3'> <View className='font-weight font-36 mt-5 mb-3'>
<Text style={{margin: '0 10px', color: '#00D6AC'}}>{lineData.reduce((pre, cur) => pre + cur.value, 0)}</Text> <Text style={{margin: '0 10px', color: '#00D6AC'}}>
{formatMinute(lineData.reduce((pre, cur) => pre + cur.value, 0) || 0)}
</Text>
</View> </View>
<LineChart data={lineData}/> <LineChart data={lineData}/>

Loading…
Cancel
Save