import {PageContainer, View, Image, ScrollView, Text} from "@tarojs/components"; import Taro from "@tarojs/taro"; import styles from './my.module.scss' 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 {Profile} from "@/store"; import Img from "@/components/image/image"; import GreenNike from "@/static/img/greenNike.png" import {curriculum, userApi} from "@/api"; import LearningRecord from "@/components/learningRecord/learningRecord"; import NavigationBar from "@/components/navigationBar/navigationBar"; import over from "@/static/img/over.png"; import incomplete from "@/static/img/incomplete.png"; import avatar from "@/static/img/avatar.png"; interface List { title: string time: string | number src: string, type?: number } const My: FC = () => { const globalData = Taro.getApp().globalData const {token, company, setCompany, user} = Profile.useContainer() const [companyShow, setCompanyShow] = useState(false) const [companyList, setCompanyList] = useState([]) const [navbarOpacity, setNavbarOpacity] = useState('0') const navbarHeight = globalData.statusBarHeight + globalData.textBarHeight; const pageHeight = globalData.windowHeight - globalData.textBarHeight - globalData.statusBarHeight Taro.useDidShow(() => { token && userApi.companyList().then(res => { setCompanyList(res as Company[]) }) }) function onScroll(e) { const v = (Math.min(e.detail.scrollTop / navbarHeight, 1) * 0.9).toFixed(6) if (v != navbarOpacity) { setNavbarOpacity(v) } } const [list, setList] = useState([ {title: '已完成', time: '0', src: over, type: 3}, {title: '未完成', time: '0', src: incomplete, type: 4}, ]) Taro.useDidShow(async () => { try { const res = await curriculum.course() const oldList: List[] = JSON.parse(JSON.stringify(list)) oldList[1].time = res.finished_count oldList[2].time = res.not_finished_count setList(oldList) } catch (e) { } }) return ( { .5 ? "0%" : '-300%'})`}}> {user?.name} }
companyList.length >= 2 && setCompanyShow(true)}/>