|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
import {PageContainer, View, Image, ScrollView, Text} from "@tarojs/components"; |
|
|
|
|
import {PageContainer, View, Image, Text} from "@tarojs/components"; |
|
|
|
|
import Taro from "@tarojs/taro"; |
|
|
|
|
import styles from './my.module.scss' |
|
|
|
|
import Header from "./components/header/header"; |
|
|
|
@ -22,6 +22,15 @@ interface List { |
|
|
|
|
type?: number |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function jump(token: string | null, type?: number) { |
|
|
|
|
if (!token) { |
|
|
|
|
Taro.navigateTo({url: '/pages/login/login'}) |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (!type) return; |
|
|
|
|
Taro.navigateTo({url: "/pages/business/courType/courType?type=" + type}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const My: FC = () => { |
|
|
|
|
const globalData = Taro.getApp().globalData |
|
|
|
|
const {token, company, setCompany, user} = Profile.useContainer() |
|
|
|
@ -29,8 +38,6 @@ const My: FC = () => { |
|
|
|
|
const [companyList, setCompanyList] = useState<Company[]>([]) |
|
|
|
|
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 => { |
|
|
|
@ -38,19 +45,18 @@ const My: FC = () => { |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
function onScroll(e) { |
|
|
|
|
const v = (Math.min(e.detail.scrollTop / navbarHeight, 1) * 0.9).toFixed(6) |
|
|
|
|
Taro.usePageScroll((e) => { |
|
|
|
|
const v = (Math.min(e.scrollTop / navbarHeight, 1) * 0.9).toFixed(6) |
|
|
|
|
if (v != navbarOpacity) { |
|
|
|
|
setNavbarOpacity(v) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const [list, setList] = useState<List[]>([ |
|
|
|
|
{title: '已完成', time: '0', src: over, type: 3}, |
|
|
|
|
{title: '未完成', time: '0', src: incomplete, type: 4}, |
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Taro.useDidShow(async () => { |
|
|
|
|
try { |
|
|
|
|
const res = await curriculum.course() |
|
|
|
@ -62,33 +68,57 @@ const My: FC = () => { |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<View className={styles.page}> |
|
|
|
|
<View> |
|
|
|
|
<NavigationBar |
|
|
|
|
className={styles.navbar} |
|
|
|
|
backgroundColor={`rgba(255,255,255,${navbarOpacity})`} |
|
|
|
|
cancelBack> |
|
|
|
|
{ |
|
|
|
|
cancelBack |
|
|
|
|
leftNode={ |
|
|
|
|
<View className={styles.navigation} |
|
|
|
|
style={{transform: `translate(0,${Number(navbarOpacity) > .5 ? "0%" : '-300%'})`}}> |
|
|
|
|
<Img src={user?.avatar || avatar} mode='heightFix' width={50} height={50} errorType='avatar'/> |
|
|
|
|
<Text className='pl-2'>{user?.name}</Text> |
|
|
|
|
style={{transform: `translate(0,${Number(navbarOpacity) > .5 ? "0%" : '-350%'})`}}> |
|
|
|
|
<Img className="rounded-50" src={user?.avatar || avatar} mode='heightFix' width={50} height={50} |
|
|
|
|
errorType='avatar'/> |
|
|
|
|
<Text className='pl-2'>{token ? user?.name : '请登录'}</Text> |
|
|
|
|
</View> |
|
|
|
|
} |
|
|
|
|
</NavigationBar> |
|
|
|
|
/> |
|
|
|
|
|
|
|
|
|
<View className={styles.bg}/> |
|
|
|
|
|
|
|
|
|
<ScrollView scrollY enhanced showScrollbar={false} style={{height: pageHeight}} onScroll={onScroll}> |
|
|
|
|
<View className={styles.content}> |
|
|
|
|
<View style={{opacity: 1 - Number(navbarOpacity)}}> |
|
|
|
|
<View className='mb-4' style={{opacity: 1 - Number(navbarOpacity)}}> |
|
|
|
|
<Header companyList={companyList} showCompany={() => companyList.length >= 2 && setCompanyShow(true)}/> |
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
<Time/> |
|
|
|
|
|
|
|
|
|
<View className="bg-white rounded-20 mb-2 clip"> |
|
|
|
|
<View className="flex p-2"> |
|
|
|
|
{list.map((d) => ( |
|
|
|
|
<View className={styles.timeBox} style={{marginBottom: '0 !important'}} key={d.title} |
|
|
|
|
onClick={() => jump(token, d.type)}> |
|
|
|
|
<View className={styles.timeBoxFlex} |
|
|
|
|
style={{backgroundColor: 'rgba(0,0,0,0.02)', borderRadius: '16rpx'}}> |
|
|
|
|
<View> |
|
|
|
|
<LearningRecord userId={user?.id}/> |
|
|
|
|
<Service/> |
|
|
|
|
<View className='mb-2 font-28 font-weight'>{d.title}</View> |
|
|
|
|
<View className='text-muted font-26 mt-1'>{d.time}</View> |
|
|
|
|
</View> |
|
|
|
|
<Image src={d.src} mode='aspectFit' className={styles.timeImag}/> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
))} |
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
token && (<View className="p-2"> |
|
|
|
|
<LearningRecord style={{paddingTop: '0 !important'}} userId={user?.id}/> |
|
|
|
|
</View>) |
|
|
|
|
} |
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
<Service/> |
|
|
|
|
|
|
|
|
|
<PageContainer |
|
|
|
|
overlayStyle={'background:rgba(0,0,0,0.3)'} |
|
|
|
|
position='bottom' |
|
|
|
@ -96,12 +126,12 @@ const My: FC = () => { |
|
|
|
|
show={companyShow} |
|
|
|
|
onClickOverlay={() => setCompanyShow(false)}> |
|
|
|
|
<View className="px-3 py-5"> |
|
|
|
|
<View className="font-32 pb-3" |
|
|
|
|
style={{ |
|
|
|
|
<View className="font-32 pb-3" style={{ |
|
|
|
|
display: 'flex', |
|
|
|
|
justifyContent: 'center', |
|
|
|
|
borderBottom: '2rpx solid #f5f8f7' |
|
|
|
|
}}>选择公司</View> |
|
|
|
|
}}> |
|
|
|
|
选择公司</View> |
|
|
|
|
{ |
|
|
|
|
companyList.length >= 1 && |
|
|
|
|
companyList.map((d, idx) => |
|
|
|
@ -138,7 +168,6 @@ const My: FC = () => { |
|
|
|
|
</View> |
|
|
|
|
</PageContainer> |
|
|
|
|
</View> |
|
|
|
|
</ScrollView> |
|
|
|
|
</View> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|