index.jsx 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React, { Suspense, useState, lazy } from 'react'
  2. import { View, Text } from '@tarojs/components'
  3. import CustomNav from '@/components/CustomNav'
  4. import logo from '@/assets/icons/comm/logo_small.png'
  5. import tabList from './tabbar'
  6. import './index.less'
  7. const Recommend = lazy(() => import('./tabs/Recommend'))
  8. const Guide = lazy(() => import('./tabs/Guide'))
  9. const Strategy = lazy(() => import('./tabs/Strategy'))
  10. const Mine = lazy(() => import('./tabs/Mine'))
  11. export default (props) => {
  12. const [currentTab, setCurrentTab] = useState(0)
  13. const handleTabChange = (e) => {
  14. const { index } = e.detail
  15. setCurrentTab(index)
  16. }
  17. return (
  18. <view className='page-index'>
  19. <view className='index-navbar'>
  20. <CustomNav logo={logo} title='十公里' />
  21. </view>
  22. <view className='index-container'>
  23. <Suspense fallback='loading...'>
  24. {currentTab === 0 && <Recommend />}
  25. {currentTab === 1 && <Guide />}
  26. {currentTab === 2 && <Strategy />}
  27. {currentTab === 3 && <Mine />}
  28. </Suspense>
  29. </view>
  30. <view className='index-tabbar'>
  31. <mp-tabbar extClass='custom-tabbar' current={currentTab} list={tabList} onChange={handleTabChange}></mp-tabbar>
  32. </view>
  33. </view>
  34. )
  35. }