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