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

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

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

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

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

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

@ -1,5 +1,5 @@
import {FC, useCallback, useEffect, useState} from "react"; 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 {ArticleRecord, brandApi, BrandRecord} from "@/api";
import styles from './info.module.scss' import styles from './info.module.scss'
import Taro, {useReachBottom, useRouter} from "@tarojs/taro"; import Taro, {useReachBottom, useRouter} from "@tarojs/taro";
@ -67,40 +67,40 @@ const BrandInfo: FC = () => {
<View className='flex flex-column' style={{display: 'flex'}}> <View className='flex flex-column' style={{display: 'flex'}}>
<Spin enable={enable} overlay/> <Spin enable={enable} overlay/>
{ {
brandInfo?.introductory_video_resource?.url || brandInfo?.brand_album?.length && (brandInfo?.introductory_video_resource?.url || brandInfo?.brand_album?.length) &&
<> <>
<Swiper <Swiper
className={styles['swiper']} className={styles['swiper']}
indicatorColor='#999' indicatorColor='#999'
indicatorActiveColor='#333' indicatorActiveColor='#333'
indicatorDots={false} indicatorDots={false}
onChange={onChange} onChange={onChange}
> >
{brandInfo?.introductory_video_resource?.url && <SwiperItem> {brandInfo?.introductory_video_resource?.url && <SwiperItem>
<Video <Video
style={{width: '750rpx', height: '600rpx'}} style={{width: '750rpx', height: '600rpx'}}
playBtnPosition={"center"} playBtnPosition={"center"}
id='video' id='video'
src={brandInfo?.introductory_video_resource?.url} src={brandInfo?.introductory_video_resource?.url}
initialTime={0} initialTime={0}
controls={true} controls={true}
enableProgressGesture={false} enableProgressGesture={false}
showFullscreenBtn={false} showFullscreenBtn={false}
autoplay={false} autoplay={false}
loop={false} loop={false}
muted={false} muted={false}
/> />
</SwiperItem>} </SwiperItem>}
{brandInfo?.brand_album?.length {brandInfo?.brand_album?.length
&& brandInfo?.brand_album?.split(',').map((d) => && brandInfo?.brand_album?.split(',').map((d) =>
<SwiperItem> <SwiperItem>
<Image mode={'aspectFill'} style={{width: '750rpx', height: '600rpx'}} src={d}></Image> <Img mode={'aspectFill'} width={750} height={600} src={d}/>
</SwiperItem>) </SwiperItem>)
} }
</Swiper> </Swiper>
<View className={styles.curIndexBox}> <View className={styles.curIndexBox}>
<Text>{curIndex} / {(brandInfo?.brand_album?.split(',').length || 0) + ((brandInfo && brandInfo.introductory_video_resource) ? 1 : 0)}</Text> <Text>{curIndex} / {(brandInfo?.brand_album?.split(',').length || 0) + ((brandInfo && brandInfo.introductory_video_resource) ? 1 : 0)}</Text>
</View> </View>
</> </>
} }

Loading…
Cancel
Save