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

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;
border: none !important;
outline: none !important;
position: sticky;
position: static;
margin: 0;
padding: 0;
box-sizing: border-box;

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

@ -1,13 +1,20 @@
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)
}
function trigger(data:any){
function trigger(data: RefreshIndex) {
Taro.eventCenter.trigger(KEY, data)
}

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

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

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

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

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

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

@ -5,6 +5,7 @@ import './videoInfo.scss'
import Catalogue from "./components/catalogue";
import Course from "./components/course";
import Taro from "@tarojs/taro";
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[]
if (playId === flats?.[flats.length - 1]?.id) {
Taro.showModal({title: '当前课程结束'})
eventsIndex.trigger(id)
return;
}
for (const [index, flat] of flats.entries()) {

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

Loading…
Cancel
Save