index.jsx 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { useState, useEffect, useMemo, } from 'react'
  2. import { Taro, useRouter } from '@tarojs/taro'
  3. import { View } from '@tarojs/components'
  4. import withLayout from '@/layouts'
  5. import CustomNav from '@/components/CustomNav'
  6. import Complete from '@/components/CompoentsOrder/complete'
  7. import './style.less'
  8. const tabs = ['全部', '待支付', '待核销', '已使用', '已过期'].map(x => ({ title: x }))
  9. const TabBar = (props) => {
  10. const handleClick = (e) => {
  11. const { index } = e.detail
  12. props.onClick(index)
  13. }
  14. return (
  15. <mp-tabs
  16. tabClass='tabs-extend'
  17. activeClass='tabs-extend-active'
  18. swiperClass='tabs-extend-swiper'
  19. tabUnderlineColor='#000'
  20. tabs={tabs}
  21. activeTab={props.current}
  22. onTabclick={handleClick}
  23. >
  24. </mp-tabs>
  25. )
  26. }
  27. export default withLayout((props) => {
  28. const [activeTab, setActiveTab] = useState(0)
  29. const { router, person } = props
  30. const { params } = useRouter()
  31. const { tabJump } = params || {}
  32. useEffect(() => {
  33. if (tabJump) {
  34. setActiveTab(tabJump - 0)
  35. }
  36. }, [tabJump])
  37. const handleTabClick = (index) => {
  38. setActiveTab(index)
  39. }
  40. return (
  41. <view className='page-index box-content'>
  42. <view className='index-navbar' >
  43. <CustomNav title='我的订单' />
  44. </view>
  45. <View className='index-container' style={{ display: 'flex', flexDirection: 'column', boxSizing: 'border-box' }}>
  46. <view className='index-tabs'>
  47. <TabBar onClick={handleTabClick} current={activeTab} />
  48. </view>
  49. {activeTab === 0 && <Complete />}
  50. {activeTab === 1 && <Complete type={0} />}
  51. {activeTab === 2 && <Complete type={1} />}
  52. {activeTab === 3 && <Complete type={2} />}
  53. {activeTab === 4 && <Complete type={3} />}
  54. </View>
  55. </view>
  56. )
  57. })