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