From f8703c075460119d97d42e761f3a997716cecd5b Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Thu, 31 Aug 2023 17:44:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AF=A6=E6=83=85=E9=A2=84?= =?UTF-8?q?=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/curriculum.ts | 2 +- src/components/image/image.tsx | 12 +++++++---- .../navigationBar/navigationBar.module.scss | 4 ++-- src/components/videoCover/videoCover.tsx | 5 +++-- .../videoInfo/components/catalogue.tsx | 13 +++++++++--- .../business/videoInfo/components/hours.tsx | 8 ++++++- src/pages/business/videoInfo/videoInfo.tsx | 18 +--------------- src/pages/home/components/search.tsx | 20 ++++++++---------- src/pages/home/home.module.scss | 21 +++++++++++-------- src/pages/home/home.tsx | 6 +++++- src/static/css/module.scss | 5 +++++ 11 files changed, 63 insertions(+), 51 deletions(-) diff --git a/src/api/curriculum.ts b/src/api/curriculum.ts index ad3d7c7..8a0532c 100644 --- a/src/api/curriculum.ts +++ b/src/api/curriculum.ts @@ -81,7 +81,7 @@ export const curriculum = { }, /** 查看课程课时数据 */ courseDep(id: number, depId: number | null) { - return request(`/api/v1/course/${id}${depId ? `/dep/${depId}` : ''}`, "GET") + return request(`/api/v1/course/dep`, "GET", {id, depId}) }, /** 播放 */ hourPlay(courseId: number, id: number) { diff --git a/src/components/image/image.tsx b/src/components/image/image.tsx index 2071e52..c7e54f4 100644 --- a/src/components/image/image.tsx +++ b/src/components/image/image.tsx @@ -5,8 +5,8 @@ import styles from './image.module.scss' import Taro from "@tarojs/taro"; interface Props extends ImageProps { - width: number - height: number + width?: number + height?: number fallback?: string } @@ -48,7 +48,7 @@ const Img: FC = ({src, mode = 'aspectFill', width, height, fallback = sha lazyLoad fadeIn defaultSource={fallback} - style={{width: `${width}rpx`, height: `${height}rpx`}} + style={{width: width ? `${width}rpx` : "100%", height: height ? `${height}rpx` : "100%"}} onError={onErrorHandler} onLoad={onLoadHandler}/> @@ -61,7 +61,11 @@ const Img: FC = ({src, mode = 'aspectFill', width, height, fallback = sha src={fallback} lazyLoad fadeIn - style={{width: `${width * .7}rpx`, height: `${height * .7}rpx`, margin: 'auto'}}/> + style={{ + width: width ? `${width * .7}rpx` : "70%", + height: height ? `${height * .7}rpx` : "70%", + margin: 'auto' + }}/> } ) diff --git a/src/components/navigationBar/navigationBar.module.scss b/src/components/navigationBar/navigationBar.module.scss index b651df6..19430d7 100644 --- a/src/components/navigationBar/navigationBar.module.scss +++ b/src/components/navigationBar/navigationBar.module.scss @@ -2,9 +2,9 @@ position: sticky; top: 0; left: 0; - width: 750rpx; + width: 730rpx; padding-left: 20rpx; - z-index: 99999999999; + z-index: 10; overflow: hidden; background: #fff; } diff --git a/src/components/videoCover/videoCover.tsx b/src/components/videoCover/videoCover.tsx index 6eb2589..c88d827 100644 --- a/src/components/videoCover/videoCover.tsx +++ b/src/components/videoCover/videoCover.tsx @@ -1,7 +1,8 @@ -import {Image, View} from "@tarojs/components"; +import {View} from "@tarojs/components"; import {FC} from "react"; import './videoCover.scss' import Taro from "@tarojs/taro"; +import Img from "@/components/image/image"; interface VideoCoverProps { thumb: string @@ -28,7 +29,7 @@ const VideoCover: FC = (opt: VideoCoverProps) => { - + {opt.content && {opt.content}} {opt.marker && {opt.marker}} diff --git a/src/pages/business/videoInfo/components/catalogue.tsx b/src/pages/business/videoInfo/components/catalogue.tsx index 55bbddd..abf0d82 100644 --- a/src/pages/business/videoInfo/components/catalogue.tsx +++ b/src/pages/business/videoInfo/components/catalogue.tsx @@ -10,6 +10,7 @@ import videoEvents from "@/hooks/videoEvents"; import curRecord from '@/static/img/curRecord.png' import hourRecord from "@/static/img/hourRecord.png" import CustomPageContainer from "@/components/custom-page-container/custom-page-container"; +import {Profile} from "@/store"; interface Props { data: CourseDepData | null @@ -29,6 +30,7 @@ const Catalogue: FC = ({data, setHors, id, playId}) => { const [current, setCurrent] = useState(1) const [show, setShow] = useState(false) const [playing, setPlaying] = useState(false) + const {token, empty} = Profile.useContainer() videoEvents.onVideoState(({name}) => { @@ -175,10 +177,15 @@ const Catalogue: FC = ({data, setHors, id, playId}) => { { - playing ? 暂停 - : 立即学习 + token ? <> + { + playing ? 暂停 + : 立即学习 + } + setShow(true)}>... + + : empty()}>立即登录 } - setShow(true)}>... = ({data, click, learn_hour_records, playId}) => { + const {token, empty} = Profile.useContainer() const complete = (id: number): number | undefined => { const find = learn_hour_records?.find(d => d.id === id) if (find) { @@ -32,7 +34,11 @@ const Hours: FC = ({data, click, learn_hour_records, playId}) => { } } - function onClick(id: number, is_complete: number | undefined, hour: Hour, upId?: number,) { + function onClick(id: number, is_complete: number | undefined, hour: Hour, upId?: number) { + if (!token) { + empty() + return; + } if (is_complete === 0) { Taro.showModal({ title: '考卷未完成,是否前往', diff --git a/src/pages/business/videoInfo/videoInfo.tsx b/src/pages/business/videoInfo/videoInfo.tsx index 6a4a236..4bc8d59 100644 --- a/src/pages/business/videoInfo/videoInfo.tsx +++ b/src/pages/business/videoInfo/videoInfo.tsx @@ -10,8 +10,6 @@ import {formatMinute} from "@/utils/time"; import videoEvents from "@/hooks/videoEvents"; import unique_ident from "@/hooks/unique_ident"; import Img from "@/components/image/image"; -import {Profile} from "@/store"; -import LoginView from "@/components/loginView"; const VideoInfo: FC = () => { const {id, depId} = Taro.getCurrentInstance()?.router?.params as any @@ -101,7 +99,6 @@ const VideoInfo: FC = () => { data && getData(playing) }) - Taro.useUnload(() => { videoEvents.videoOff() }) @@ -131,18 +128,5 @@ const VideoInfo: FC = () => { ) } -const VerifyToken: FC = () => { - const {token} = Profile.useContainer() - const globalData = Taro.getApp().globalData - - return ( - <> - { - !token ? - : - } - - ) -} -export default VerifyToken +export default VideoInfo diff --git a/src/pages/home/components/search.tsx b/src/pages/home/components/search.tsx index aec1dce..eef3ff5 100644 --- a/src/pages/home/components/search.tsx +++ b/src/pages/home/components/search.tsx @@ -1,21 +1,19 @@ import {FC} from "react"; -import {Input, View} from "@tarojs/components"; +import {View} from "@tarojs/components"; import styles from "../home.module.scss"; import Icon from "@/components/icon"; +import Taro from "@tarojs/taro"; -interface Props { - onConfirm: (value: string) => void -} -export const Search: FC = (props) => { +export const Search: FC = () => { + + function jump(){ + Taro.navigateTo({url:'/pages/preview/search/search/index'}) + } return ( - + - props.onConfirm((e.target as any).value!)} - className='flex-1 pl-1'/> + 搜索课程 ) } diff --git a/src/pages/home/home.module.scss b/src/pages/home/home.module.scss index df38b0a..e10d896 100644 --- a/src/pages/home/home.module.scss +++ b/src/pages/home/home.module.scss @@ -16,14 +16,16 @@ } .header { + width: 100%; + overflow: hidden; margin-bottom: 20rpx; &:after { min-height: 100vh; position: absolute; top: 0; - left: -10%; - width: 120%; + left: 0; + width: 100%; content: ''; display: block; background: linear-gradient(to right, #DBF3F5, #B9ECD7, #C1EEDA) no-repeat; @@ -37,13 +39,14 @@ padding: 0 20px; min-height: 90vh; box-sizing: border-box; - width: 750rpx; + width: 100%; + overflow: hidden; &:after { position: absolute; top: 0; - left: -10%; - width: 120%; + left: 0; + width: 100%; height: 400rpx; content: ''; display: block; @@ -54,16 +57,16 @@ } .search { - width: 710rpx; background: #fff; border-radius: 100px; font-size: 28rpx; display: flex; - padding-left: 20rpx; align-items: center; box-sizing: border-box; - margin: 20rpx; - height: 76rpx; + justify-content: center; + height: 68rpx; + margin-bottom: 40rpx; + color: #909795; } .adware { diff --git a/src/pages/home/home.tsx b/src/pages/home/home.tsx index b05c818..b17e134 100644 --- a/src/pages/home/home.tsx +++ b/src/pages/home/home.tsx @@ -12,6 +12,7 @@ import {HomeApi, HomeData} from "@/api"; import logo from '@/static/img/logo.png' import Spin from "@/components/spinner"; import NavigationBar from "@/components/navigationBar/navigationBar"; +import {Search} from "@/pages/home/components/search"; const Home: FC = () => { @@ -35,9 +36,12 @@ const Home: FC = () => { return ( <> - } cancelBack/> + } + cancelBack/> +