king 1 year ago
parent 6b052df04c
commit c0038a7e93
  1. 4
      src/api/public.ts
  2. 3
      src/components/tabs/tabs.scss
  3. 50
      src/pages/index/components/videoList.tsx
  4. 2
      src/pages/index/index.config.ts
  5. 31
      src/pages/index/index.tsx
  6. 6
      src/pages/preview/brand/info/info.tsx

@ -15,9 +15,9 @@ interface CategoryList {
export interface Courses {
/** 已完成 */
is_finished: Curriculum[]
// is_finished: Curriculum[]
/** 未完成 */
is_not_finished: Curriculum[]
// is_not_finished: Curriculum[]
/** 选秀 */
is_not_required: Curriculum[]
/** 必修 */

@ -15,11 +15,12 @@ View::-webkit-scrollbar {
display: -webkit-flex;
display: flex;
text-align: center;
align-items: baseline;
}
.tabs-item {
padding: 20rpx;
font-size: 36rpx;
font-size: 30rpx;
font-family: PingFang SC-Medium, PingFang SC;
font-weight: 500;
color: #606563;

@ -7,7 +7,8 @@ import styles from '../index.module.scss'
import {formatMinute} from "@/utils/time";
import {userApi} from "@/api";
import Empty from "@/components/empty/empty";
import eventsIndex from "@/hooks/eventsIndex";
import {Profile} from "@/store";
import LoginView from "@/components/loginView";
interface Props {
categoryKey: CoursesKey
@ -18,11 +19,12 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => {
const [data, setData] = useState<Courses>({
is_required: [],
is_not_required: [],
is_finished: [],
is_not_finished: [],
// is_finished: [],
// is_not_finished: [],
})
const [page, setPage] = useState(1)
const [records, setRecords] = useState<LearnRecord[]>([])
const {token} = Profile.useContainer()
function screen(oldData: Curriculum[], data: Curriculum[]): Curriculum[] {
return data.reduce((pre, cur) => {
@ -43,8 +45,8 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => {
setData({
is_required: screen(old.is_required, res.is_required || []),
is_not_required: screen(old.is_not_required, res.is_not_required || []),
is_finished: screen(old.is_finished, res.is_finished || []),
is_not_finished: screen(old.is_not_finished, res.is_not_finished || []),
// is_finished: screen(old.is_finished, res.is_finished || []),
// is_not_finished: screen(old.is_not_finished, res.is_not_finished || []),
})
} catch (e) {
}
@ -63,7 +65,6 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => {
switch (categoryKey) {
case "is_required":
case "is_not_required":
case "is_not_finished":
const find = records.find(d => d?.course_id === id)
if (find) {
if (class_hour === find.finished_count) {
@ -72,21 +73,19 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => {
return (<View>{`${class_hour}节/已学${find.finished_count}`}</View>)
}
return (<View>{`${class_hour}节/已学0节`}</View>)
case "is_finished":
return <View></View>
}
}
eventsIndex.on(({id}) => {
if (id == null) return;
for (const [index, notFinished] of data.is_not_finished.entries()) {
if (notFinished.id === id) {
data.is_finished.push(notFinished)
data.is_not_finished.splice(index, 1)
return
}
}
})
// eventsIndex.on(({id}) => {
// if (id == null) return;
// for (const [index, notFinished] of data.is_not_finished.entries()) {
// if (notFinished.id === id) {
// data.is_finished.push(notFinished)
// data.is_not_finished.splice(index, 1)
// return
// }
// }
// })
useDidShow(() => {
getData().then()
@ -115,11 +114,16 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => {
onChange={changeSwiper}
current={categoryIndex}>
{
Object.values(data).map((value) => <SwiperItem>
<ScrollView scrollY className={styles.swiper} onScrollToLower={() => setPage(page + 1)}>
Object.entries(data).map(([key, value]) => <SwiperItem>
<ScrollView scrollY className={styles.swiper} onScrollToLower={() => setPage(page + 1)} enhanced
showScrollbar={false}>
<View className='py-2 flex justify-between flex-wrap'>
{
value?.length ? value?.map(c =>
!token
&& key === 'is_required'
? <LoginView/> : value?.length ?
<>
{value?.map(c =>
<VideoCover
thumb={c.thumb}
title={c.title}
@ -128,7 +132,9 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => {
key={c.id}
time={formatMinute(c.course_duration)}
content={rateOfLearning(c.id, c.class_hour)}
/>)
/>)}
<View className='text-center text-muted'></View>
</>
: <Empty name='暂无课程'/>
}
</View>

@ -1,3 +1,3 @@
export default definePageConfig({
navigationStyle: 'custom'
navigationStyle: 'custom',
})

@ -1,21 +1,17 @@
import {FC, useState} from "react";
import {View, Text} from "@tarojs/components";
import {View} from "@tarojs/components";
import styles from './index.module.scss'
import {VideoList} from "@/pages/index/components/videoList";
import Tabs, {OnChangOpt, TabList} from "@/components/tabs/tabs";
import {CoursesKey} from "@/api/public";
import LoginView from "@/components/loginView";
import Taro from "@tarojs/taro";
import {Profile} from "@/store"
import NavigationBar from "@/components/navigationBar/navigationBar";
const Index: FC = () => {
const globalData = Taro.getApp().globalData
const {token} = Profile.useContainer()
const category: TabList[] = [
{title: "必修", value: 'is_required'},
{title: "选修", value: 'is_not_required'},
{title: "已完成", value: 'is_finished'},
{title: "未完成", value: 'is_not_finished'},
// {title: "已完成", value: 'is_finished'},
// {title: "未完成", value: 'is_not_finished'},
]
const [categoryKey, setCategoryKey] = useState<CoursesKey>('is_required')
@ -25,18 +21,13 @@ const Index: FC = () => {
return (
<View className={styles.content} style={`paddingTop:${globalData.statusBarHeight}px`}>
{ !token ?
<LoginView></LoginView>
:
<>
<View className="flex justify-center align-center" style={{height:`${(globalData.menu.top-globalData.statusBarHeight)*2+globalData.menu.height}px`}}>
<Text className="font-28 text-white"></Text>
</View>
<Tabs tabList={category} onChange={tabChange} current={categoryKey}/>
<VideoList categoryKey={categoryKey} setCategoryKey={(categoryKey) => setCategoryKey(categoryKey)}/>
</>
}
<View className={styles.content}>
<NavigationBar cancelBack
leftNode={<Tabs tabList={category} onChange={tabChange} current={categoryKey}/>}
backgroundColor={'transparent'}/>
<VideoList
categoryKey={categoryKey}
setCategoryKey={(categoryKey) => setCategoryKey(categoryKey)}/>
</View>
)
}

@ -1,5 +1,5 @@
import {FC, useCallback, useEffect, useState} from "react";
import {Image, Swiper, SwiperItem, Text, Video, View} from "@tarojs/components";
import {Swiper, SwiperItem, Text, Video, View} from "@tarojs/components";
import {ArticleRecord, brandApi, BrandRecord} from "@/api";
import styles from './info.module.scss'
import Taro, {useReachBottom, useRouter} from "@tarojs/taro";
@ -67,7 +67,7 @@ const BrandInfo: FC = () => {
<View className='flex flex-column' style={{display: 'flex'}}>
<Spin enable={enable} overlay/>
{
brandInfo?.introductory_video_resource?.url || brandInfo?.brand_album?.length &&
(brandInfo?.introductory_video_resource?.url || brandInfo?.brand_album?.length) &&
<>
<Swiper
className={styles['swiper']}
@ -94,7 +94,7 @@ const BrandInfo: FC = () => {
{brandInfo?.brand_album?.length
&& brandInfo?.brand_album?.split(',').map((d) =>
<SwiperItem>
<Image mode={'aspectFill'} style={{width: '750rpx', height: '600rpx'}} src={d}></Image>
<Img mode={'aspectFill'} width={750} height={600} src={d}/>
</SwiperItem>)
}
</Swiper>

Loading…
Cancel
Save