首页全局事件(未完成课程变更)

main
king 1 year ago
parent 7da7471724
commit 52da8849a2
  1. 2
      src/components/button/myButton.module.scss
  2. 22
      src/components/video/video.tsx
  3. 15
      src/hooks/eventsIndex.ts
  4. 14
      src/pages/business/curHistory/curHistory.module.scss
  5. 6
      src/pages/business/curHistory/curHistory.tsx
  6. 3
      src/pages/business/test/test.tsx
  7. 6
      src/pages/business/test/text.module.scss
  8. 1
      src/pages/business/videoInfo/components/catalogue.tsx
  9. 6
      src/pages/business/videoInfo/videoInfo.scss
  10. 2
      src/pages/business/videoInfo/videoInfo.tsx
  11. 22
      src/pages/index/components/videoList.tsx

@ -6,7 +6,7 @@
font-size: 32rpx; font-size: 32rpx;
border: none !important; border: none !important;
outline: none !important; outline: none !important;
position: sticky; position: static;
margin: 0; margin: 0;
padding: 0; padding: 0;
box-sizing: border-box; box-sizing: border-box;

@ -53,17 +53,17 @@ const HVideo: FC<HVideoOptions> = (opt: HVideoOptions) => {
return ( return (
<Video <Video
id={'myVideo'} id={'myVideo'}
autoplay autoplay
style={{width: '100%', height: '100%',position:"relative"}} style={{width: '100%', height: '100%', position: "relative"}}
poster={opt?.poster || ''} poster={opt?.poster || ''}
src={opt.src} src={opt.src}
enableProgressGesture={false} enableProgressGesture={false}
direction={90} direction={90}
onTimeUpdate={onTimeUpdate} onTimeUpdate={onTimeUpdate}
onEnded={onEnded} onEnded={onEnded}
/> />
) )
} }

@ -1,13 +1,20 @@
import Taro from "@tarojs/taro"; import Taro from "@tarojs/taro";
/** 首页全局事件 */ /**
const KEY = 'REFRESHINDEX' *
* -
*/
const KEY = 'REFRESH_INDEX'
function on(fn: (arg: any) => void) { interface RefreshIndex {
id: number
}
function on(fn: (arg: RefreshIndex) => void) {
Taro.eventCenter.on(KEY, fn) Taro.eventCenter.on(KEY, fn)
} }
function trigger(data:any){ function trigger(data: RefreshIndex) {
Taro.eventCenter.trigger(KEY, data) Taro.eventCenter.trigger(KEY, data)
} }

@ -1,5 +1,5 @@
page { .page{
padding: 30px; padding: 30px !important;
box-sizing: border-box; box-sizing: border-box;
} }
@ -9,12 +9,12 @@ page {
border-radius: 16px; border-radius: 16px;
font-weight: bold; font-weight: bold;
View { //View {
color: #323635; // color: #323635;
padding: 24px; // padding: 24px;
} //}
Image { .image {
width: 100%; width: 100%;
height: 288rpx; height: 288rpx;
display: block; display: block;

@ -49,10 +49,10 @@ const CurHistory = () => {
} }
return ( return (
<View> <View className={styles.page}>
<View className={styles.cur}> <View className={styles.cur}>
<Image src={course?.thumb || ''} mode='widthFix'/> <Image className='image' src={course?.thumb || ''} mode='widthFix'/>
<View>{name}</View> <View className='px-3'>{name}</View>
</View> </View>

@ -83,6 +83,7 @@ const Test = () => {
return ( return (
<View className={styles.content}> <View className={styles.content}>
{data?.fill.map((d, index) => <ShortAnswer {data?.fill.map((d, index) => <ShortAnswer
key={d.id}
data={d} data={d}
index={index} index={index}
onAnswer={onAnswer} onAnswer={onAnswer}
@ -90,6 +91,7 @@ const Test = () => {
/>)} />)}
{data?.judge.map((d, index) => <Judge {data?.judge.map((d, index) => <Judge
key={d.id}
data={d} data={d}
index={index} index={index}
onAnswer={onAnswer} onAnswer={onAnswer}
@ -98,6 +100,7 @@ const Test = () => {
{ {
data?.multi.map((d, index) => <Multi data?.multi.map((d, index) => <Multi
key={d.id}
data={d} data={d}
onAnswer={onAnswer} onAnswer={onAnswer}
index={index} index={index}

@ -1,4 +1,4 @@
.content{ .content {
padding-bottom: env(safe-area-inset-bottom); padding: 30rpx;
margin-bottom: 20px; background: #fff;
} }

@ -89,7 +89,6 @@ const Catalogue: FC<Props> = ({data, setHors, id}) => {
} }
} }
} }
} else { } else {
Taro.showToast({title: "无播放视频", icon: 'error'}) Taro.showToast({title: "无播放视频", icon: 'error'})
} }

@ -25,7 +25,7 @@
.catalogue { .catalogue {
background: #fff; background: #fff;
border-radius: 40rpx; border-radius: 40rpx;
padding: 0 24px 0 24px; padding: 0 24rpx 24rpx;
margin-top: 20rpx; margin-top: 20rpx;
.short_desc { .short_desc {
@ -79,9 +79,9 @@
position: fixed; position: fixed;
width: 100%; width: 100%;
left: 0; left: 0;
bottom: 0; bottom: env(safe-area-inset-bottom);
box-sizing: border-box; box-sizing: border-box;
padding: 10px 20px env(safe-area-inset-bottom); padding: 10px 20px;
} }
.more { .more {

@ -5,6 +5,7 @@ import './videoInfo.scss'
import Catalogue from "./components/catalogue"; import Catalogue from "./components/catalogue";
import Course from "./components/course"; import Course from "./components/course";
import Taro from "@tarojs/taro"; import Taro from "@tarojs/taro";
import eventsIndex from "@/hooks/eventsIndex";
// import eventsIndex from "@/hooks/eventsIndex"; // import eventsIndex from "@/hooks/eventsIndex";
@ -41,6 +42,7 @@ const VideoInfo: FC = () => {
const flats: Hour[] = Object.values(data?.hours || {}).flat(Infinity) as Hour[] const flats: Hour[] = Object.values(data?.hours || {}).flat(Infinity) as Hour[]
if (playId === flats?.[flats.length - 1]?.id) { if (playId === flats?.[flats.length - 1]?.id) {
Taro.showModal({title: '当前课程结束'}) Taro.showModal({title: '当前课程结束'})
eventsIndex.trigger(id)
return; return;
} }
for (const [index, flat] of flats.entries()) { for (const [index, flat] of flats.entries()) {

@ -1,5 +1,5 @@
import {FC, useEffect, useState} from "react"; import {FC, useEffect, useState} from "react";
import {useReachBottom} from "@tarojs/taro"; import {useDidShow, useReachBottom} from "@tarojs/taro";
import {View} from "@tarojs/components"; import {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";
@ -7,6 +7,7 @@ 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";
interface Props { interface Props {
categoryKey: CoursesKey categoryKey: CoursesKey
@ -23,7 +24,6 @@ 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[]>([])
async function getData() { async function getData() {
try { try {
const res = await publicApi.course({page: 1, pageSize: 10 * page}) const res = await publicApi.course({page: 1, pageSize: 10 * page})
@ -64,9 +64,21 @@ export const VideoList: FC<Props> = ({categoryKey, ready}) => {
setPage(page + 1) setPage(page + 1)
}) })
// eventsIndex.on(()=>{ eventsIndex.on(({id}) => {
// getRecords() 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(() => {
if (ready) {
getRecords().then()
}
})
useEffect(() => { useEffect(() => {
if (ready) { if (ready) {

Loading…
Cancel
Save