李志伟 3 years ago
parent
commit
1d20e65993

+ 2
- 9
project.private.config.json View File

1
 {
1
 {
2
+  "setting": {},
2
   "condition": {
3
   "condition": {
3
     "plugin": {
4
     "plugin": {
4
       "list": []
5
       "list": []
10
       "list": []
11
       "list": []
11
     },
12
     },
12
     "miniprogram": {
13
     "miniprogram": {
13
-      "list": [
14
-        {
15
-          "name": "",
16
-          "pathName": "pages/machineryList/index",
17
-          "query": "",
18
-          "scene": null,
19
-          "launchMode": "default"
20
-        }
21
-      ]
14
+      "list": []
22
     }
15
     }
23
   }
16
   }
24
 }
17
 }

BIN
src/assets/noData.png View File


+ 4
- 1
src/components/LoginModel/index.jsx View File

13
 import './style.less'
13
 import './style.less'
14
 
14
 
15
 export default (props) => {
15
 export default (props) => {
16
+  const {path}=props
16
   const { person,setPerson } = useModel('person')
17
   const { person,setPerson } = useModel('person')
17
-
18
   const [agreement,setAgreement]=useState(false)
18
   const [agreement,setAgreement]=useState(false)
19
   const [phone,setPhone]=useState()
19
   const [phone,setPhone]=useState()
20
   const [qCode,setqCode]=useState()
20
   const [qCode,setqCode]=useState()
89
           icon: 'none',
89
           icon: 'none',
90
           duration: 1000
90
           duration: 1000
91
         })
91
         })
92
+        if (path) {
93
+          Taro.reLaunch({ url: path });
94
+        }
92
       }).catch((e) => {
95
       }).catch((e) => {
93
         Taro.showToast({
96
         Taro.showToast({
94
           title: '手机号或者验证码不正确',
97
           title: '手机号或者验证码不正确',

+ 11
- 15
src/components/MyCard/index.jsx View File

6
 import './style.less'
6
 import './style.less'
7
 
7
 
8
 export default (props) => {
8
 export default (props) => {
9
-  const { detail, order, job, onClick } = props
10
-  const handleDetail = () => {
11
-    Taro.navigateTo({ url: '/pages/orderDetail/index' });
12
-  }
9
+  const { detail, order, job, value, onClick,goDetail } = props
10
+  
13
   return (
11
   return (
14
     <View className='card'>
12
     <View className='card'>
15
       <Jianbian status='1' />
13
       <Jianbian status='1' />
16
       <View className='cardHead'>
14
       <View className='cardHead'>
17
         {
15
         {
18
-          job && <MyCell header='需求时间' job action='详情>>' handleAction={handleDetail}>2022-06-02</MyCell>
16
+          job && <MyCell header='需求时间' job action='详情>>' handleAction={goDetail}>2022-06-02</MyCell>
19
         }
17
         }
20
         {
18
         {
21
-          !job && <>
22
-            <MyCell header='需求时间'>2022-06-02</MyCell>
23
-            <Text className='price'><Text style={{ fontSize: '44rpx' }}>600</Text>元</Text>
24
-          </>
19
+          !job && <MyCell header='需求时间'>2022-06-02</MyCell>
25
         }
20
         }
26
       </View>
21
       </View>
27
       <View className='line' />
22
       <View className='line' />
28
-      <MyCell header='农机名称'>收割机001</MyCell>
29
-      <MyCell header='下单人'>张三</MyCell>
23
+      <MyCell header='农机名称'>{value?.machineryName||'收割机001'}</MyCell>
24
+      <MyCell header='下单人'>{value?.personName}</MyCell>
30
       {
25
       {
31
-        detail && <MyCell header='手机号'>13613949434</MyCell>
26
+        detail && <MyCell header='手机号'>{value?.phone||'13613949434'}</MyCell>
32
       }
27
       }
33
-      <MyCell header='订单时间'>2022-03-08</MyCell>
28
+      <MyCell header='订单时间'>{value?.createDate.substr(0,10)||'2022-03-08'}</MyCell>
34
       {
29
       {
35
-        detail && <MyCell header='服务地址'>河南省南阳市邓州市孟楼镇</MyCell>
30
+        detail && <MyCell header='服务地址'>{value?.address||'河南省南阳市邓州市孟楼镇'}</MyCell>
36
       }
31
       }
37
       <MyCell header='作业时间'>上午06:00--晚上21:00</MyCell>
32
       <MyCell header='作业时间'>上午06:00--晚上21:00</MyCell>
33
+      <MyCell header='订单费用'>{(value?.charges&&value.charges/100)||600}元</MyCell>
38
       {
34
       {
39
         job && <MyButton value='开始作业' onClick={onClick} />
35
         job && <MyButton value='开始作业' onClick={onClick} />
40
       }
36
       }
42
         order && <View className='line' />
38
         order && <View className='line' />
43
       }
39
       }
44
       {
40
       {
45
-        order && <View className='footer' onClick={handleDetail}>详情{">"}{">"}</View>
41
+        order && <View className='footer' onClick={goDetail}>详情{">"}{">"}</View>
46
       }
42
       }
47
     </View>
43
     </View>
48
   )
44
   )

+ 0
- 8
src/components/MyCard/style.less View File

9
     width: 100%;
9
     width: 100%;
10
     padding: 5px 0 0 38px;
10
     padding: 5px 0 0 38px;
11
     position: relative;
11
     position: relative;
12
-    .price{
13
-      position: absolute;
14
-      right: 40px;
15
-      top: 14px;
16
-      font-size: 30px;
17
-      font-weight: bold;
18
-      color: #FF2525;
19
-    }
20
   }
12
   }
21
   .line{
13
   .line{
22
     width: 100%;
14
     width: 100%;

+ 13
- 0
src/components/NullCard/index.jsx View File

1
+import { View,Image } from "@tarojs/components"
2
+import NoDataImg from '@/assets/noData.png'
3
+import './style.less'
4
+
5
+export default (props)=>{
6
+  const {value}=props
7
+  return (
8
+    <View className='noDataCard'>
9
+      <Image className='NullImg' src={NoDataImg} />
10
+      <View>{value}</View>
11
+    </View>
12
+  )
13
+}

+ 17
- 0
src/components/NullCard/style.less View File

1
+.noDataCard{
2
+  margin: 30px;
3
+  box-shadow: 0px 0px 44px 0px rgba(0, 0, 0, 0.08);
4
+  border-radius: 40px;
5
+  position: relative;
6
+  overflow: hidden;
7
+  padding: 78px;
8
+  font-size: 34px;
9
+  font-weight: bold;
10
+  color: #B4B4B4;
11
+  text-align: center;
12
+  .NullImg{
13
+    width: 220px;
14
+    height: 264px;
15
+    margin-bottom: 44px;
16
+  }
17
+}

+ 17
- 15
src/pages/index/components/order/index.jsx View File

4
 import positionImg from '@/assets/comm/position.png'
4
 import positionImg from '@/assets/comm/position.png'
5
 import searchImg from '@/assets/comm/search.png'
5
 import searchImg from '@/assets/comm/search.png'
6
 import orderImg from '@/assets/comm/orderList.png'
6
 import orderImg from '@/assets/comm/orderList.png'
7
-import LoginModel from "@/components/LoginModel";
8
 import Footer from "@/components/Footer";
7
 import Footer from "@/components/Footer";
9
 import MyCard from "@/components/MyCard";
8
 import MyCard from "@/components/MyCard";
10
-import { useModel } from "@/store";
11
-
12
-
9
+import NullCard from "@/components/NullCard";
13
 import { getBannerList } from "@/services/banner";
10
 import { getBannerList } from "@/services/banner";
11
+import { getOrderList } from "@/services/order";
14
 import './style.less'
12
 import './style.less'
15
 
13
 
16
 
14
 
17
 export default (props) => {
15
 export default (props) => {
18
-  const [imgList, setImgList] = useState([])  
19
-  const [show, setShow] = useState(false)
20
-  const [path, setPath] = useState()
21
-  const { person } = useModel('person')
16
+  const [imgList, setImgList] = useState([])
17
+  const [orderList, setOrderList] = useState([])
22
 
18
 
23
   const handleSearch = (e) => {
19
   const handleSearch = (e) => {
24
     console.log(e.detail.value)
20
     console.log(e.detail.value)
26
   const handleMore = () => {
22
   const handleMore = () => {
27
     Taro.navigateTo({ url: '/pages/moreOrder/index' });
23
     Taro.navigateTo({ url: '/pages/moreOrder/index' });
28
   }
24
   }
25
+  const handleDetail = (val) => {
26
+    Taro.navigateTo({ url: `/pages/orderDetail/index?id=${val}` });
27
+  }
29
   useEffect(() => {
28
   useEffect(() => {
30
     getBannerList({ position: 'bannerWorker' })
29
     getBannerList({ position: 'bannerWorker' })
31
       .then(res => {
30
       .then(res => {
36
           icon: 'none',
35
           icon: 'none',
37
         })
36
         })
38
       })
37
       })
38
+    getOrderList().then((res) => {
39
+      setOrderList(res.records)
40
+    })
39
   }, [])
41
   }, [])
40
   return (
42
   return (
41
     <View className='orderIndex'>
43
     <View className='orderIndex'>
42
-      {
43
-        show && <LoginModel path={path} close={() => setShow(false)} />
44
-      }
45
       <View className='top'>
44
       <View className='top'>
46
         <View className='left'>
45
         <View className='left'>
47
           <Image src={positionImg} className='pImg' />
46
           <Image src={positionImg} className='pImg' />
73
             <Text className='title'>订单列表</Text>
72
             <Text className='title'>订单列表</Text>
74
             <Text className='more' onClick={handleMore}>更多{">"}{">"}</Text>
73
             <Text className='more' onClick={handleMore}>更多{">"}{">"}</Text>
75
           </View>
74
           </View>
76
-
77
-          <MyCard order />
78
-          <MyCard order />
79
-          <Footer />
75
+          {
76
+            orderList.length===0?<NullCard value='您还没有新的订单!' />:
77
+            orderList.map((item)=>{
78
+              return <MyCard order value={item} key={item.orderId} goDetail={()=>handleDetail(item.orderId)} />
79
+            })
80
+          }
81
+          {/* <Footer /> */}
80
         </View>
82
         </View>
81
       </ScrollView>
83
       </ScrollView>
82
     </View>
84
     </View>

+ 36
- 17
src/pages/index/index.jsx View File

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

+ 21
- 5
src/pages/moreOrder/index.jsx View File

1
-import { useState } from "react";
1
+import Taro from "@tarojs/taro";
2
+import { useState, useEffect } from "react";
2
 import { View, Input, Image, Text, ScrollView } from "@tarojs/components"
3
 import { View, Input, Image, Text, ScrollView } from "@tarojs/components"
3
 import CustomNav from "@/components/CustomNav";
4
 import CustomNav from "@/components/CustomNav";
4
 import searchImg from '@/assets/comm/search.png'
5
 import searchImg from '@/assets/comm/search.png'
5
 import withLayout from '@/layouts'
6
 import withLayout from '@/layouts'
7
+import NullCard from "@/components/NullCard";
6
 import MyCard from "@/components/MyCard";
8
 import MyCard from "@/components/MyCard";
7
 import Footer from "@/components/Footer";
9
 import Footer from "@/components/Footer";
10
+import { getOrderList } from "@/services/order";
8
 import './style.less'
11
 import './style.less'
9
 
12
 
10
 export default withLayout(() => {
13
 export default withLayout(() => {
11
   const [imageShow, setImageShow] = useState(true)
14
   const [imageShow, setImageShow] = useState(true)
12
   const [currentTab, setCurrentTab] = useState(0);
15
   const [currentTab, setCurrentTab] = useState(0);
16
+  const [orderList, setOrderList] = useState([])
13
   const handleSearch = (e) => {
17
   const handleSearch = (e) => {
14
     if (e.detail.value) {
18
     if (e.detail.value) {
15
       console.log(e.detail.value)
19
       console.log(e.detail.value)
24
   const handleChange = (val) => {
28
   const handleChange = (val) => {
25
     setCurrentTab(val)
29
     setCurrentTab(val)
26
   }
30
   }
31
+  const handleDetail = (val) => {
32
+    Taro.navigateTo({ url: `/pages/orderDetail/index?id=${val}` });
33
+  }
34
+  useEffect(() => {
35
+    getOrderList().then((res) => {
36
+      console.log(res.records)
37
+      setOrderList(res.records)
38
+    })
39
+  }, [])
27
   return (
40
   return (
28
     <View className='page-index'>
41
     <View className='page-index'>
29
       <View className='index-navbar'>
42
       <View className='index-navbar'>
75
       <View className='index-container'>
88
       <View className='index-container'>
76
         <ScrollView scrollY style={{ height: '100%' }}>
89
         <ScrollView scrollY style={{ height: '100%' }}>
77
           {/* {currentTab} */}
90
           {/* {currentTab} */}
78
-          <MyCard />
79
-          <MyCard />
80
-          <MyCard />
81
-          <Footer />
91
+          {
92
+            orderList.length===0?<NullCard value='您还没有新的订单!' />:
93
+            orderList.map((item)=>{
94
+              return <MyCard order value={item} key={item.orderId} goDetail={()=>handleDetail(item.orderId)} />
95
+            })
96
+          }
97
+          {/* <Footer /> */}
82
         </ScrollView>
98
         </ScrollView>
83
         {/* {currentTab === 0 && <View>777</View>}
99
         {/* {currentTab === 0 && <View>777</View>}
84
         {currentTab === 1 && <View>888</View>}
100
         {currentTab === 1 && <View>888</View>}

+ 13
- 2
src/pages/orderDetail/index.jsx View File

2
 import CustomNav from "@/components/CustomNav"
2
 import CustomNav from "@/components/CustomNav"
3
 import MyCard from "@/components/MyCard"
3
 import MyCard from "@/components/MyCard"
4
 import withLayout from '@/layouts'
4
 import withLayout from '@/layouts'
5
+import { useEffect , useState } from "react"
6
+import { getOrderDetail } from "@/services/order"
5
 
7
 
6
-export default withLayout(() => {
8
+
9
+export default withLayout((props) => {
10
+  const { router } = props
11
+  let { id } = router.params
12
+  const [value,setValue]=useState()
13
+  useEffect(()=>{
14
+    getOrderDetail(id).then((res)=>{
15
+      setValue(res)
16
+    })
17
+  },[id])
7
   return (
18
   return (
8
     <View className='page-index'>
19
     <View className='page-index'>
9
       <View className='index-navbar'>
20
       <View className='index-navbar'>
10
         <CustomNav title='更多' />
21
         <CustomNav title='更多' />
11
       </View>
22
       </View>
12
       <View className='index-container'>
23
       <View className='index-container'>
13
-        <MyCard detail />
24
+        <MyCard detail value={value} />
14
       </View>
25
       </View>
15
     </View>
26
     </View>
16
   )
27
   )

+ 15
- 0
src/services/order.js View File

1
+import request from '@/utils/request'
2
+
3
+/**
4
+  * 订单列表
5
+  * @returns 
6
+  * params 搜索条件放这里
7
+  */
8
+ export const getOrderList = (params) => request('/order', { params })
9
+
10
+/**
11
+  * 订单详情
12
+  * @returns 
13
+  * params 搜索条件放这里
14
+  */
15
+ export const getOrderDetail = (id,params) => request(`/order/${id}`, { params })

+ 1
- 1
src/store/models/person.js View File

8
   const login = (params) => {
8
   const login = (params) => {
9
     signIn(params).then((res) => {
9
     signIn(params).then((res) => {
10
       const { person: taPerson,  sessionKey: skey } = res;
10
       const { person: taPerson,  sessionKey: skey } = res;
11
-      taPerson.phone=null
11
+      // taPerson.phone=null
12
       setPerson(taPerson);
12
       setPerson(taPerson);
13
       setSessionKey(skey);
13
       setSessionKey(skey);
14
     })
14
     })

+ 1
- 2
src/utils/hooks/useLogin.js View File

10
   const router = useRouter()
10
   const router = useRouter()
11
   const { person } = useModel('person')
11
   const { person } = useModel('person')
12
   const [loginVisible, setLoginVisible] = useState(false)
12
   const [loginVisible, setLoginVisible] = useState(false)
13
-  let { tab } = router.params
14
 
13
 
15
-  const isInWhiteList = useMemo(() => whiteList.includes(router.path)&&(!tab||tab==0), [router.path, tab])
14
+  const isInWhiteList = useMemo(() => whiteList.includes(router.path), [router.path])
16
   const hasPhone = useMemo(() => !!person?.phone, [person?.phone])
15
   const hasPhone = useMemo(() => !!person?.phone, [person?.phone])
17
   
16
   
18
   useEffect(() => {
17
   useEffect(() => {