From 178c227b1a6da5fa30c5ae249c748cfb908b322b Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Fri, 1 Sep 2023 17:00:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B=E6=9C=AA?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 4 +- src/app.tsx | 2 - src/components/image/image.tsx | 7 +- src/components/loginView/index.module.scss | 20 +++-- src/components/loginView/index.tsx | 75 ++++++++++--------- .../videoInfo/components/catalogue.tsx | 37 +++++---- src/pages/business/videoInfo/videoInfo.scss | 6 +- src/pages/home/home.tsx | 9 ++- 8 files changed, 91 insertions(+), 69 deletions(-) diff --git a/.env b/.env index 86e2b46..3852d45 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ -#TARO_APP_API=https://yjx.dev.yaojiankang.top -TARO_APP_API=https://mooc.yaojiankang.top +TARO_APP_API=https://yjx.dev.yaojiankang.top +#TARO_APP_API=https://mooc.yaojiankang.top #TARO_APP_API=https://shopfix.yaojiankang.top #TARO_APP_API=https://playedu.yaojiankang.top TARO_APP_LGOIN=true diff --git a/src/app.tsx b/src/app.tsx index b94c2a6..157f647 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -32,7 +32,6 @@ function updateApp() { function App(props) { - Taro.useLaunch(() => { updateApp() storageDep.remove() @@ -65,7 +64,6 @@ function App(props) { useDidHide(() => { }) - return ( diff --git a/src/components/image/image.tsx b/src/components/image/image.tsx index c7e54f4..72499be 100644 --- a/src/components/image/image.tsx +++ b/src/components/image/image.tsx @@ -57,14 +57,13 @@ const Img: FC = ({src, mode = 'aspectFill', width, height, fallback = sha isError && !loading && } diff --git a/src/components/loginView/index.module.scss b/src/components/loginView/index.module.scss index 53d8e13..a87a781 100644 --- a/src/components/loginView/index.module.scss +++ b/src/components/loginView/index.module.scss @@ -5,25 +5,28 @@ flex-direction: column; justify-content: center; align-items: center; - image{ + + image { width: 320rpx; height: 208rpx; } - .title{ + + .title { font-size: 28rpx; font-weight: bold; color: #323635; - line-height: 80rpx; } - .label{ + + .label { font-size: 24rpx; font-weight: 500; color: #909795; line-height: 24rpx; - margin-bottom: 40rpx; + margin: 20rpx 0 ; } - .button{ - width: 520rpx; + + .button { + padding: 0 60rpx; height: 76rpx; background: #45D4A8; border-radius: 38rpx 38rpx 38rpx 38rpx; @@ -33,7 +36,8 @@ font-size: 32rpx; font-weight: 500; } - .nextLabel{ + + .nextLabel { font-size: 24rpx; font-weight: 500; color: #909795; diff --git a/src/components/loginView/index.tsx b/src/components/loginView/index.tsx index ca1994e..2805f5b 100644 --- a/src/components/loginView/index.tsx +++ b/src/components/loginView/index.tsx @@ -1,5 +1,5 @@ import {CSSProperties, FC, useState} from "react"; -import {View,Image} from "@tarojs/components"; +import {View, Image} from "@tarojs/components"; import styles from './index.module.scss' import NoLogin from '@/static/img/noLogin.png' import {Profile} from "@/store"; @@ -9,55 +9,60 @@ import {userApi} from "@/api"; interface Props { tips?: string height?: number + paddingTop?: number + style?: CSSProperties + offImage?: boolean } -const LoginView: FC = (props) => { +const LoginView: FC = (props) => { const [isLoading, setLoading] = useState(false) - const {setUser,setToken,setCompany} = Profile.useContainer() - const text = props.tips ?? '登录后可查看更多内容' - const size: string = props.height? `${props.height}px`:'0rpx' + const {setUser, setToken, setCompany} = Profile.useContainer() const sizeStyle: CSSProperties = { - height:'1000rpx', - paddingTop:size, + height: `${props.height || 1000}rpx`, + paddingTop: `${props.paddingTop || 0}rpx`, + ...props.style, } function login() { if (isLoading) return; - Taro.showLoading({title:'微信授权中...'}) + Taro.showLoading({title: '微信授权中...'}) setLoading(true) - Taro.login({ - success: async (res) => { - try { - const {catch_key, user, token, company} = await userApi.login(res.code) - Taro.hideLoading() - if (token) { - Taro.showToast({title:'授权成功',duration:1500,icon:'success',mask:true}) - setTimeout(()=>{ - setUser(user) - setToken(token) - setCompany(company) - setLoading(false) - Taro.switchTab({url: '/pages/home/home'}) - },1500) - } else { - Taro.setStorageSync('openid', catch_key) - Taro.reLaunch({url: '/pages/check/check'}) - } - } catch (e) { - Taro.hideLoading() + Taro.login({ + success: async (res) => { + try { + const {catch_key, user, token, company} = await userApi.login(res.code) + Taro.hideLoading() + if (token) { + Taro.showToast({title: '授权成功', duration: 1500, icon: 'success', mask: true}) + setTimeout(() => { + setUser(user) + setToken(token) + setCompany(company) + setLoading(false) + Taro.switchTab({url: '/pages/home/home'}) + }, 1500) + } else { + Taro.setStorageSync('openid', catch_key) + Taro.reLaunch({url: '/pages/check/check'}) } - setLoading(false) + } catch (e) { + Taro.hideLoading() } - }) + setLoading(false) + } + }) } return ( - - 暂未登录 - {text} - {login()}} className={styles.button}>立即登录 - 点击立即登录完成微信授权以继续使用 + { + !props.offImage && <> + + 暂未登录 + + } + 点击按钮完成微信授权 + 立即登录 ) } diff --git a/src/pages/business/videoInfo/components/catalogue.tsx b/src/pages/business/videoInfo/components/catalogue.tsx index abf0d82..08f9fbb 100644 --- a/src/pages/business/videoInfo/components/catalogue.tsx +++ b/src/pages/business/videoInfo/components/catalogue.tsx @@ -11,6 +11,7 @@ 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"; +import LoginView from "@/components/loginView"; interface Props { data: CourseDepData | null @@ -30,7 +31,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() + const {token} = Profile.useContainer() videoEvents.onVideoState(({name}) => { @@ -154,6 +155,19 @@ const Catalogue: FC = ({data, setHors, id, playId}) => { {current === 0 && {data?.course.short_desc || data?.course.title}} {current === 1 && 课程目录 + {!token && } {data?.chapters.length ? Object.values(data?.chapters || {}).map((d, index) => @@ -175,18 +189,15 @@ const Catalogue: FC = ({data, setHors, id, playId}) => { - - { - token ? <> - { - playing ? 暂停 - : 立即学习 - } - setShow(true)}>... - - : empty()}>立即登录 - } - + { + token && + { + playing ? 暂停 + : 立即学习 + } + setShow(true)}>... + + } { Taro.navigateTo({url: '/pages/login/login'}) } - Taro.useLoad(() => { + useEffect(() => { HomeApi.home().then(res => { setData(res) }) setTimeout(() => { setEnable(false) }, 600) - }) + }, []) + return ( <> @@ -41,7 +42,7 @@ const Home: FC = () => { cancelBack/> - +