index.jsx 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { useState, useEffect, useMemo, } from 'react'
  2. import { Current, 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. console.log('-----------------handleTabChange----------------', e)
  12. const { index } = e.detail
  13. props.onClick(index)
  14. }
  15. return (
  16. <mp-tabs
  17. tabClass='tabs-extend'
  18. activeClass='tabs-extend-active'
  19. swiperClass='tabs-extend-swiper'
  20. tabUnderlineColor='#000'
  21. tabs={tabs}
  22. activeTab={props.current}
  23. onTabclick={handleClick}
  24. >
  25. </mp-tabs>
  26. )
  27. }
  28. export default withLayout((props) => {
  29. const [activeTab, setActiveTab] = useState(0)
  30. const { router, person } = props
  31. const { params } = useRouter()
  32. const { tabJump } = params || {}
  33. useEffect(() => {
  34. if (tabJump) {
  35. setActiveTab(tabJump - 0)
  36. }
  37. }, [tabJump])
  38. const handleTabClick = (index) => {
  39. console.log('------tab-----event--------', index)
  40. setActiveTab(index)
  41. }
  42. console.log('------setActiveTab--------', activeTab)
  43. return (
  44. <view className='page-index box-content'>
  45. <view className='index-navbar'>
  46. <CustomNav title='我的订单' />
  47. </view>
  48. <View className='index-container' style={{display:'flex',flexDirection:'column',boxSizing:'border-box'}}>
  49. <view className='index-tabs'>
  50. <TabBar onClick={handleTabClick} current={activeTab} />
  51. </view>
  52. {activeTab === 0 && <Complete />}
  53. {activeTab === 1 && <Complete type={0} />}
  54. {activeTab === 2 && <Complete type={1} />}
  55. {activeTab === 3 && <Complete type={2} />}
  56. {activeTab === 4 && <Complete type={3} />}
  57. </View>
  58. </view>
  59. )
  60. })