index.jsx 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import React, { useState, useEffect, useRef } from 'react'
  2. import Taro from '@tarojs/taro'
  3. import CustomNav from '@/components/CustomNav'
  4. import logo from '@/assets/icons/comm/logo_small.png'
  5. import withLayout from '@/layouts'
  6. import tabList from './tabbar'
  7. import Guide from './tabs/Guide'
  8. import Mine from './tabs/Mine'
  9. import Recommend from './tabs/Recommend'
  10. import './index.less'
  11. import { getLocation } from '@/utils/location'
  12. import { getIndexType, getResourceList } from '@/services/home'
  13. export default withLayout((props) => {
  14. const { router, person, location } = props
  15. const { params, path } = router
  16. const { tab } = params || {}
  17. const [currentTab, setCurrentTab] = useState(0)
  18. const handleTabChange = (e) => {
  19. const { index } = e.detail
  20. setCurrentTab(index)
  21. }
  22. useEffect(() => {
  23. if (tab) {
  24. setCurrentTab(tab - 0)
  25. }
  26. }, [tab])
  27. return (
  28. <view className='page-index'>
  29. <view className='index-navbar'>
  30. <CustomNav logo={logo} title='十公里' />
  31. </view>
  32. <view className='index-container'>
  33. {currentTab === 0 && <Recommend location={location} />}
  34. {currentTab === 1 && <Guide person={person} router={router} />}
  35. {/* {currentTab === 2 && <Strategy />} */}
  36. {currentTab === 2 && <Mine person={person} />}
  37. </view>
  38. <view className='index-tabbar'>
  39. <mp-tabbar extClass='custom-tabbar' current={currentTab} list={tabList} onChange={handleTabChange}></mp-tabbar>
  40. </view>
  41. </view>
  42. )
  43. })