学习页面技术高度

v2
king 1 year ago
parent 9d8b36f300
commit 451828b70c
  1. 10
      src/pages/index/components/videoList.tsx
  2. 7
      src/pages/index/index.module.scss

@ -1,9 +1,8 @@
import {FC, useEffect, useMemo, useState} from "react"; import {FC, useEffect, useMemo, useState} from "react";
import {useDidShow} from "@tarojs/taro"; import Taro, {useDidShow} from "@tarojs/taro";
import {ScrollView, Swiper, SwiperItem, View} from "@tarojs/components"; import {ScrollView, Swiper, SwiperItem, View} from "@tarojs/components";
import {Courses, CoursesKey, publicApi} from "@/api/public"; import {Courses, CoursesKey, publicApi} from "@/api/public";
import VideoCover from "@/components/videoCover/videoCover"; import VideoCover from "@/components/videoCover/videoCover";
import styles from '../index.module.scss'
import {formatMinute} from "@/utils/time"; import {formatMinute} from "@/utils/time";
import {userApi} from "@/api"; import {userApi} from "@/api";
import Empty from "@/components/empty/empty"; import Empty from "@/components/empty/empty";
@ -23,6 +22,9 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => {
const [page, setPage] = useState(1) const [page, setPage] = useState(1)
const [records, setRecords] = useState<LearnRecord[]>([]) const [records, setRecords] = useState<LearnRecord[]>([])
const {token} = Profile.useContainer() const {token} = Profile.useContainer()
const {windowHeight, textBarHeight, statusBarHeight} = Taro.getApp().globalData
const pageHeight = windowHeight - textBarHeight - statusBarHeight
function screen(oldData: Curriculum[], data: Curriculum[]): Curriculum[] { function screen(oldData: Curriculum[], data: Curriculum[]): Curriculum[] {
return data.reduce((pre, cur) => { return data.reduce((pre, cur) => {
@ -93,12 +95,12 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => {
}, [data, categoryKey]) }, [data, categoryKey])
return ( return (
<Swiper className={styles.swiper} <Swiper style={{height: pageHeight}}
onChange={changeSwiper} onChange={changeSwiper}
current={categoryIndex}> current={categoryIndex}>
{ {
Object.entries(data).map(([key, value]) => <SwiperItem> Object.entries(data).map(([key, value]) => <SwiperItem>
<ScrollView scrollY className={styles.swiper} onScrollToLower={() => setPage(page + 1)} enhanced <ScrollView scrollY style={{height: pageHeight}} onScrollToLower={() => setPage(page + 1)} enhanced
showScrollbar={false}> showScrollbar={false}>
{ {
!token && key === 'is_required' !token && key === 'is_required'

@ -2,6 +2,8 @@
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
right: 0;
bottom: 0;
padding: 0 20px; padding: 0 20px;
min-height: 100vh; min-height: 100vh;
box-sizing: border-box; box-sizing: border-box;
@ -21,11 +23,6 @@
} }
} }
.swiper {
height: calc(100vh - 88rpx);
}
.videoListBox { .videoListBox {
border-radius: 20px; border-radius: 20px;
} }

Loading…
Cancel
Save