diff --git a/src/pages/my/components/header/header.tsx b/src/pages/my/components/header/header.tsx index b2b8712..b02cd0e 100644 --- a/src/pages/my/components/header/header.tsx +++ b/src/pages/my/components/header/header.tsx @@ -5,25 +5,37 @@ import avatar from "@/static/img/avatar.png" import blacktriang from "@/static/img/blacktriangle.png" const Header = ({showCompany}:{showCompany:()=> void}) => { - const {user,company} = Profile.useContainer() + const {token,user,company,empty} = Profile.useContainer() return ( - - - {user?.name} + { + token ? + : + + } + { token ? + + {user?.name} - { - showCompany() - }}> - {company?.name} - + { + showCompany() + }}> + {company?.name} + + + : + + { + empty() + }}>注册/登录 + } + {/**/} {/* 手机号:{user?.phone_number}*/} {/**/} - ) diff --git a/src/pages/my/components/header/service.tsx b/src/pages/my/components/header/service.tsx index c8ab9b6..d652b8f 100644 --- a/src/pages/my/components/header/service.tsx +++ b/src/pages/my/components/header/service.tsx @@ -22,7 +22,7 @@ const Service = () => { {title: '个人中心', src: userInfo, router: '/pages/business/userInfo/userInfo'}, ]) - const {user, setUser} = Profile.useContainer() + const {token,user, setUser} = Profile.useContainer() Taro.useDidShow(async () => { if (user?.id) { @@ -33,18 +33,24 @@ const Service = () => { useEffect(() => { const oldList: List[] = JSON.parse(JSON.stringify(list)) - 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: spotMeeting, router: '/pages/manage/spotMeeting/spotMeeting'}, - {title: '课程管理', src: course, router: '/pages/manage/courseAdmin/courseAdmin'}, - ]) - setList(oldList) + if(token){ + 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: spotMeeting, router: '/pages/manage/spotMeeting/spotMeeting'}, + {title: '课程管理', src: course, router: '/pages/manage/courseAdmin/courseAdmin'}, + ]) + setList(oldList) + } } }, []) function jump(url: string) { + if(!token){ + Taro.navigateTo({url:'/pages/login/login'}) + return + } Taro.navigateTo({url}) } diff --git a/src/pages/my/components/header/time.tsx b/src/pages/my/components/header/time.tsx index a2aeeda..28f5664 100644 --- a/src/pages/my/components/header/time.tsx +++ b/src/pages/my/components/header/time.tsx @@ -10,6 +10,7 @@ import time1 from "@/static/img/time1.png"; import time2 from "@/static/img/time2.png"; import over from '@/static/img/over.png' import incomplete from '@/static/img/incomplete.png' +import {Profile} from "@/store"; interface List { title: string @@ -19,6 +20,7 @@ interface List { } const Time: FC = () => { + const {token} = Profile.useContainer() const [list, setList] = useState([ {title: '今日时长', time: '00:00', src: time1}, {title: '累计时长', time: '00:00', src: time2}, @@ -59,7 +61,7 @@ const Time: FC = () => { {d.title} - {d.time} + { token && {d.time}} diff --git a/src/pages/my/my.tsx b/src/pages/my/my.tsx index 54bdf8d..9561e3c 100644 --- a/src/pages/my/my.tsx +++ b/src/pages/my/my.tsx @@ -5,7 +5,6 @@ import Header from "./components/header/header"; import {FC, useState} from "react"; import Time from "@/pages/my/components/header/time"; import Service from "@/pages/my/components/header/service"; -import LoginView from "@/components/loginView"; import {Profile} from "@/store"; import Img from "@/components/image/image"; import GreenNike from "@/static/img/greenNike.png" @@ -30,16 +29,13 @@ const My: FC = () => { return ( - { !token ? - - : - <> -
{setCompanyShow(true)}}/> + +
{ + companyList.length >= 2 && setCompanyShow(true) + }}/>