diff --git a/.env b/.env index 1eee7ad..0cde6d6 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ -TARO_APP_API=https://yjx.dev.yaojiankang.top -#TARO_APP_API=https://playedu.yaojiankang.top +#TARO_APP_API=https://yjx.dev.yaojiankang.top +TARO_APP_API=https://playedu.yaojiankang.top TARO_APP_LGOIN=true diff --git a/src/app.scss b/src/app.scss index d75e1b0..6df0891 100644 --- a/src/app.scss +++ b/src/app.scss @@ -255,7 +255,7 @@ .text-hover-primary { color: #0056b3;} .text-secondary {color: #6c757d;} .text-hover-secondary { color: #494f54;} -.text-success {color: #28a745;} +.text-success {color: #45D4A8;} .text-hover-success{color: #19692c;} .text-info { color: #17a2b8;} .text-hover-info {color: #0f6674;} diff --git a/src/components/topic/judge.tsx b/src/components/topic/judge.tsx index e947c90..6def01c 100644 --- a/src/components/topic/judge.tsx +++ b/src/components/topic/judge.tsx @@ -43,14 +43,14 @@ const Judge: FC = ({data, onAnswer, validate, frequency}) => { color={validate ? 'correct' !== rightKey ? 'red' : '#45d4a8' : '#45d4a8'} disabled={validate ? 'correct' !== rightAnswer : false} > - 正确 + 正确 - 错误 + 错误 diff --git a/src/components/topic/multi.tsx b/src/components/topic/multi.tsx index e2db7b2..e97e30d 100644 --- a/src/components/topic/multi.tsx +++ b/src/components/topic/multi.tsx @@ -1,4 +1,4 @@ -import {FC, useEffect, useState} from "react"; +import {FC, useCallback, useEffect, useState} from "react"; import {Checkbox, CheckboxGroup, Radio, RadioGroup, Text, View} from "@tarojs/components"; import './topic.scss' @@ -22,20 +22,37 @@ const Multi: FC = ({data, onAnswer, validate, frequency}) => { {value: "D", title: data.answerD}, ] - function onChange(e) { + function RadioChange(e) { const value = e.detail.value - if (data.type) { - setRightAnswer(value) + setRightAnswer([value]) + } + + const changeCheckbox = useCallback((value: string) => { + const index = rightAnswer.indexOf(value) + if (index === -1) { + setRightAnswer([...rightAnswer, value]) } else { - setRightAnswer([value]) + const oldRightAnswer: string[] = JSON.parse(JSON.stringify(rightAnswer)) + oldRightAnswer.splice(index, 1) + setRightAnswer(oldRightAnswer) } - } + }, [rightAnswer]) useEffect(() => { if (validate) { - const isAnswer = rightKey.toString() === rightAnswer.toString() - onAnswer(isAnswer) - setError(!isAnswer) + if (rightAnswer.length !== rightKey.length) { + onAnswer(false) + setError(false) + } else { + const isAnswer = rightAnswer.reduce((pre, cut) => { + if (!pre) { + return false + } + return rightKey.indexOf(cut) !== -1 + }, true) + onAnswer(isAnswer) + setError(!isAnswer) + } } }, [validate]) @@ -47,17 +64,19 @@ const Multi: FC = ({data, onAnswer, validate, frequency}) => { - {data.type ? + {data.type ? {answers.map(d => changeCheckbox(d.value)} key={d.value} value={d.value} className='option' disabled={validate} + checked={rightAnswer.includes(d.value)} > {d.value}:{d.title} )} - : + : {answers.map(d => = (opt: HVideoOptions) => { let video: Taro.VideoContext @@ -13,8 +13,17 @@ const HVideo: FC = (opt: HVideoOptions) => { try { video = Taro.createVideoContext('myVideo') - } catch (e) { - } + videoEvents.onSetVideoState(({name}) => { + switch (name) { + case "pause": + video?.pause() + break + case "play": + video?.play() + break + } + }) + } catch (e) {} function onTimeUpdate(event: BaseEventOrig) { // if (opt.preview) return; @@ -38,8 +47,10 @@ const HVideo: FC = (opt: HVideoOptions) => { }) } - opt.setTime((time: number) => { - video?.seek(time) + opt.setTime((time?: number) => { + if (typeof time === 'number') { + video?.seek(time) + } video?.play() }) @@ -53,11 +64,20 @@ const HVideo: FC = (opt: HVideoOptions) => { } } + function onPlay() { + videoEvents.videoState('play') + } + + function onPause() { + videoEvents.videoState('pause') + } + Taro.useDidHide(() => { video?.pause() unique_ident.put(Number(currentTime.toFixed(2)), Date.now()) }) + Taro.useDidShow(() => { if (!video) { video = Taro.createVideoContext('myVideo') @@ -67,6 +87,7 @@ const HVideo: FC = (opt: HVideoOptions) => { } }) + return ( - 立即学习 + { + playing ? 暂停 + : 立即学习 + } + setShow(true)}>... diff --git a/src/pages/business/videoInfo/components/course.tsx b/src/pages/business/videoInfo/components/course.tsx index 5a288fc..692c640 100644 --- a/src/pages/business/videoInfo/components/course.tsx +++ b/src/pages/business/videoInfo/components/course.tsx @@ -16,7 +16,7 @@ interface Props { id: number, courseId: number preview?: boolean - curEnd: (test?:boolean) => void + curEnd: (test?: boolean) => void } @@ -243,29 +243,31 @@ const Course: FC = ({id, courseId, preview, curEnd}: Props) => { )} - - 考试次数:{frequency} - { - (index + 1) === examAll?.[time]?.length && - {!validate && setValidate(true)}>交卷} - {frequency > 0 && validate && 重考} - {frequency === 0 && validate && 重新学习} - - } - - - {index !== 0 && setIndex(index - 1)}>上一题} + {index !== 0 && setIndex(index - 1)}>上一题} { (index + 1) !== examAll?.[time]?.length - && setIndex(index + 1)}>下一题 + && + setIndex(index + 1)}>下一题 } + + + 考试次数:{frequency} + { + (index + 1) === examAll?.[time]?.length && + {!validate && setValidate(true)}>交卷} + {frequency > 0 && validate && 重考} + {frequency === 0 && validate && 重新学习} + + } + diff --git a/src/pages/business/videoInfo/components/hours.tsx b/src/pages/business/videoInfo/components/hours.tsx index 4cbf7c0..2937ed6 100644 --- a/src/pages/business/videoInfo/components/hours.tsx +++ b/src/pages/business/videoInfo/components/hours.tsx @@ -1,6 +1,6 @@ import {FC} from "react"; import '../videoInfo.scss' -import {Image, View} from "@tarojs/components"; +import {Image, Text, View} from "@tarojs/components"; import playOk from "@/static/img/play-ok.png"; import play from "@/static/img/play.png"; import {formatMinute} from "@/utils/time"; @@ -9,6 +9,7 @@ import {curriculum} from "@/api"; import lock from '@/static/img/lock.png' interface Props { + playId: number | null data?: Hour[] | null learn_hour_records?: LearnHourRecords[] click: (is_complete: boolean, id: number) => void @@ -21,7 +22,7 @@ async function jumTest(hour: Hour) { }) } -const Hours: FC = ({data, click, learn_hour_records}) => { +const Hours: FC = ({data, click, learn_hour_records, playId}) => { const complete = (id: number): number | undefined => { const find = learn_hour_records?.find(d => d.id === id) if (find) { @@ -53,7 +54,7 @@ const Hours: FC = ({data, click, learn_hour_records}) => { } if (upId && complete(upId) !== 1) { - Taro.showToast({title: '禁止播放', icon: 'none'}) + Taro.showToast({title: '锁定中', icon: 'none'}) return } @@ -63,23 +64,26 @@ const Hours: FC = ({data, click, learn_hour_records}) => { return ( <> {data?.map((d, index) => - onClick(d.id, complete(d.id), d, data?.[index - 1]?.id)}> - - - - {index + 1}.{d.title} - {formatMinute(d.duration)}分钟 - {complete(d.id) === 0 && 考卷未完成} + <> + onClick(d.id, complete(d.id), d, data?.[index - 1]?.id)}> + + + + {playId === d.id && 正在播放:}{index + 1}. {d.title} + 时长:{formatMinute(d.duration)} + {complete(d.id) === 0 && 考卷未完成} + + { + complete(data?.[index - 1]?.id) == null + && index !== 0 + && + } - { - complete(data?.[index - 1]?.id) == null - && index !== 0 - && - } - )} + )} + ) } diff --git a/src/pages/business/videoInfo/videoInfo.scss b/src/pages/business/videoInfo/videoInfo.scss index e95b841..cc75946 100644 --- a/src/pages/business/videoInfo/videoInfo.scss +++ b/src/pages/business/videoInfo/videoInfo.scss @@ -43,7 +43,7 @@ .image { width: 40rpx; height: 40rpx; - margin-top: 10rpx; + margin-top: 8rpx; } diff --git a/src/pages/business/videoInfo/videoInfo.tsx b/src/pages/business/videoInfo/videoInfo.tsx index 9e49c01..8e80487 100644 --- a/src/pages/business/videoInfo/videoInfo.tsx +++ b/src/pages/business/videoInfo/videoInfo.tsx @@ -8,13 +8,14 @@ import Taro from "@tarojs/taro"; import eventsIndex from "@/hooks/eventsIndex"; import {formatMinute} from "@/utils/time"; import unique_ident from "@/hooks/unique_ident"; +import videoEvents from "@/hooks/videoEvents"; const VideoInfo: FC = () => { const {id, depId} = Taro.getCurrentInstance()?.router?.params as any const [data, setData] = useState(null) const [playId, setPlayId] = useState(null) - const [preview, setPreview] = useState(false) - const [playing, setPlaying] = useState(false) + const [preview, setPreview] = useState(false) // 预览 + const [playing, setPlaying] = useState(false) // 学习中 const getData = useCallback(async (playing: boolean) => { const res = await curriculum.courseDep(id, depId) @@ -102,6 +103,7 @@ const VideoInfo: FC = () => { Taro.useUnload(() => { unique_ident.del() + videoEvents.videoOff() }) return ( <> @@ -123,7 +125,11 @@ const VideoInfo: FC = () => { 学习进度{((data?.learn_hour_records.length || 0) / (data?.course.class_hour || 1) * 100).toFixed(0)}% - + ) diff --git a/src/pages/manage/spotMeeting/spotMeeting.config.ts b/src/pages/manage/spotMeeting/spotMeeting.config.ts index 3f286c6..475c44d 100644 --- a/src/pages/manage/spotMeeting/spotMeeting.config.ts +++ b/src/pages/manage/spotMeeting/spotMeeting.config.ts @@ -1,4 +1,4 @@ export default definePageConfig({ - navigationBarTitleText: '见面会', + navigationBarTitleText: '现场会', enableShareAppMessage: true }) diff --git a/src/pages/my/components/header/service.tsx b/src/pages/my/components/header/service.tsx index 46a1d8f..cfd0097 100644 --- a/src/pages/my/components/header/service.tsx +++ b/src/pages/my/components/header/service.tsx @@ -27,7 +27,7 @@ const Service = () => { if ([1, 2].includes(user?.role_type || 0)) { oldList.unshift(...[ {title: '部门管理', src: dep, router: '/pages/manage/depAdmin/depAdmin'}, - {title: '课程市场', src: buy, router: '/pages/manage/curriculum/curriculum'}, + // {title: '课程市场', src: buy, router: '/pages/manage/curriculum/curriculum'}, {title: '现场会', src: buy, router: '/pages/manage/spotMeeting/spotMeeting'}, ]) setList(oldList) diff --git a/src/static/css/module.scss b/src/static/css/module.scss index b46b410..1df6bc3 100644 --- a/src/static/css/module.scss +++ b/src/static/css/module.scss @@ -5,7 +5,6 @@ page, -webkit-overflow-scrolling: touch; box-sizing: border-box; padding-bottom: env(safe-area-inset-bottom); - //min-height: 100vh; } body { @@ -13,7 +12,7 @@ body { } .weui-cells_checkbox .weui-check:checked + .weui-icon-checked:before, -.taro-checkbox_checked{ +.taro-checkbox_checked { color: #45D4A8 !important; } @@ -45,16 +44,14 @@ taro-button-core::after { .card { - height: 100px; background: #fff; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #F5F8F7; - padding: 0 20rpx; + padding: 10px 20rpx; font-size: 30rpx; - &-content { font-size: 27rpx; color: #8c8c8c;