|
@@ -11,7 +11,6 @@ import CustomNav from "@/components/CustomNav";
|
11
|
11
|
import { setAmap } from '@/services/amap'
|
12
|
12
|
import withLayout from '@/layouts'
|
13
|
13
|
import { useModel } from "@/store";
|
14
|
|
-import LoginModel from "@/components/LoginModel";
|
15
|
14
|
import Order from './components/Order'
|
16
|
15
|
import Job from './components/Job'
|
17
|
16
|
import User from "./components/User";
|
|
@@ -19,37 +18,12 @@ import "./index.less";
|
19
|
18
|
|
20
|
19
|
|
21
|
20
|
export default withLayout((props) => {
|
22
|
|
- const { person } = useModel('person')
|
23
|
21
|
const { router } = props
|
24
|
22
|
let { tab } = router.params
|
25
|
23
|
const { location, setLocation } = useModel('location')
|
26
|
|
- const [currentTab, setCurrentTab] = useState(0);
|
27
|
|
- const [show, setShow] = useState(false)
|
28
|
|
- const [path, setPath] = useState()
|
29
|
24
|
const handleClick = (val) => {
|
30
|
|
- if (!person.phone && val != 0) {
|
31
|
|
- setPath(`/pages/index/index?tab=${val}`)
|
32
|
|
- setShow(true)
|
33
|
|
- return
|
34
|
|
- }
|
35
|
|
- setCurrentTab(val);
|
|
25
|
+ Taro.reLaunch({ url: `/pages/index/index?tab=${val}` });
|
36
|
26
|
};
|
37
|
|
- const handleMore = () => {
|
38
|
|
- if (!person.phone) {
|
39
|
|
- setPath(`/pages/moreOrder/index`)
|
40
|
|
- setShow(true)
|
41
|
|
- return
|
42
|
|
- }
|
43
|
|
- Taro.navigateTo({ url: '/pages/moreOrder/index' });
|
44
|
|
- }
|
45
|
|
- const handleDetail = () => {
|
46
|
|
- if (!person.phone) {
|
47
|
|
- setPath(`/pages/orderDetail/index`)
|
48
|
|
- setShow(true)
|
49
|
|
- return
|
50
|
|
- }
|
51
|
|
- Taro.navigateTo({ url: '/pages/orderDetail/index' });
|
52
|
|
- }
|
53
|
27
|
useEffect(() => {
|
54
|
28
|
if (!location) {
|
55
|
29
|
Taro.getLocation({
|
|
@@ -62,44 +36,37 @@ export default withLayout((props) => {
|
62
|
36
|
} else {
|
63
|
37
|
setAmap({ params: 'location=' + location, path: '/v3/geocode/regeo' })
|
64
|
38
|
}
|
65
|
|
-
|
66
|
|
- if (tab) {
|
67
|
|
- setCurrentTab(tab - 0)
|
68
|
|
- }
|
69
|
|
- }, [tab])
|
|
39
|
+ }, [])
|
70
|
40
|
return (
|
71
|
41
|
<View className='page-index'>
|
72
|
|
- {
|
73
|
|
- show && <LoginModel path={path} close={() => setShow(false)} />
|
74
|
|
- }
|
75
|
42
|
<View className='index-navbar'>
|
76
|
|
- <CustomNav home title={currentTab === 0 ? '首页' : currentTab === 1 ? '作业管理' : '我的'} />
|
|
43
|
+ <CustomNav home title={(!tab || tab == 0) ? '首页' : tab == 1 ? '作业管理' : '我的'} />
|
77
|
44
|
</View>
|
78
|
45
|
<View className='index-container'>
|
79
|
|
- {currentTab === 0 && <Order handleMore={handleMore} handleDetail={handleDetail} /> }
|
80
|
|
- {currentTab === 1 && <Job />}
|
81
|
|
- {currentTab === 2 && <User />}
|
|
46
|
+ {(!tab || tab == 0) && <Order />}
|
|
47
|
+ {tab == 1 && <Job />}
|
|
48
|
+ {tab == 2 && <User />}
|
82
|
49
|
</View>
|
83
|
50
|
<View className='index-tabbar'>
|
84
|
51
|
<View
|
85
|
|
- className={['tabberItem', currentTab === 0 ? "activeTabber" : '']}
|
|
52
|
+ className={['tabberItem', (!tab || tab == 0) ? "activeTabber" : '']}
|
86
|
53
|
onClick={() => handleClick(0)}
|
87
|
54
|
>
|
88
|
|
- <Image className='tabberImg' src={currentTab === 0 ? indexActive : indexImg}></Image>
|
|
55
|
+ <Image className='tabberImg' src={(!tab || tab == 0) ? indexActive : indexImg}></Image>
|
89
|
56
|
<View className='text'>首页</View>
|
90
|
57
|
</View>
|
91
|
58
|
<View
|
92
|
|
- className={['tabberItem', currentTab === 1 ? "activeTabber" : '']}
|
|
59
|
+ className={['tabberItem', tab === 1 ? "activeTabber" : '']}
|
93
|
60
|
onClick={() => handleClick(1)}
|
94
|
61
|
>
|
95
|
|
- <Image className='tabberImg' src={currentTab === 1 ? jobActive : job}></Image>
|
|
62
|
+ <Image className='tabberImg' src={tab == 1 ? jobActive : job}></Image>
|
96
|
63
|
<View className='text'>作业管理</View>
|
97
|
64
|
</View>
|
98
|
65
|
<View
|
99
|
|
- className={['tabberItem', currentTab === 2 ? "activeTabber" : '']}
|
|
66
|
+ className={['tabberItem', tab === 2 ? "activeTabber" : '']}
|
100
|
67
|
onClick={() => handleClick(2)}
|
101
|
68
|
>
|
102
|
|
- <Image className='tabberImg' src={currentTab === 2 ? userActive : user}></Image>
|
|
69
|
+ <Image className='tabberImg' src={tab == 2 ? userActive : user}></Image>
|
103
|
70
|
<View className='text'>个人中心</View>
|
104
|
71
|
</View>
|
105
|
72
|
</View>
|