李志伟 3 years ago
parent
commit
7c2dd10fd9

+ 7
- 8
src/components/MyCard/index.jsx View File

1
 import Taro from "@tarojs/taro"
1
 import Taro from "@tarojs/taro"
2
-import { View, Text } from '@tarojs/components'
2
+import { View } from '@tarojs/components'
3
 import Jianbian from "@/components/Jianbian"
3
 import Jianbian from "@/components/Jianbian"
4
 import MyCell from "../MyCell"
4
 import MyCell from "../MyCell"
5
 import MyButton from "../MyButton"
5
 import MyButton from "../MyButton"
7
 
7
 
8
 export default (props) => {
8
 export default (props) => {
9
   const { detail, order, job, value, onClick,goDetail } = props
9
   const { detail, order, job, value, onClick,goDetail } = props
10
-  
11
   return (
10
   return (
12
     <View className='card'>
11
     <View className='card'>
13
       <Jianbian status={job?value?.status:value?.workStatus} />
12
       <Jianbian status={job?value?.status:value?.workStatus} />
14
       <View className='cardHead'>
13
       <View className='cardHead'>
15
         {
14
         {
16
-          job && <MyCell header='需求时间' job action='详情>>' handleAction={goDetail}>2022-06-02</MyCell>
15
+          job && <MyCell header='需求时间' job action='详情>>' handleAction={goDetail}>{value?.appointmentDate?.substr(0,10)}</MyCell>
17
         }
16
         }
18
         {
17
         {
19
-          !job && <MyCell header='需求时间'>2022-06-02</MyCell>
18
+          !job && <MyCell header='需求时间'>{value?.appointmentDate?.substr(0,10)}</MyCell>
20
         }
19
         }
21
       </View>
20
       </View>
22
       <View className='line' />
21
       <View className='line' />
23
-      <MyCell header='农机名称'>{value?.machineryName||'收割机001'}</MyCell>
22
+      <MyCell header='农机名称'>{value?.machineryName}</MyCell>
24
       <MyCell header='下单人'>{value?.personName}</MyCell>
23
       <MyCell header='下单人'>{value?.personName}</MyCell>
25
       <MyCell header='手机号'>{value?.phone}</MyCell>
24
       <MyCell header='手机号'>{value?.phone}</MyCell>
26
-      <MyCell header='订单时间'>{value?.createDate.substr(0,10)||'2022-03-08'}</MyCell>
25
+      <MyCell header='订单时间'>{value?.createDate.substr(0,10)}</MyCell>
27
       {
26
       {
28
-        detail && <MyCell header='服务地址'>{value?.address||'河南省南阳市邓州市孟楼镇'}</MyCell>
27
+        detail && <MyCell header='服务地址'>{value?.address}</MyCell>
29
       }
28
       }
30
-      <MyCell header='作业时间'>上午06:00--晚上21:00</MyCell>
29
+      <MyCell header='作业时间'><View>{value?.startDate}</View><View>{value?.endDate}</View></MyCell>
31
       <MyCell header='订单费用'>{(value?.charges&&value.charges/100)||600}元</MyCell>
30
       <MyCell header='订单费用'>{(value?.charges&&value.charges/100)||600}元</MyCell>
32
       {
31
       {
33
         job &&value.status!=3&& <MyButton value={value.status==0?'开始作业':'完成作业'} onClick={onClick} />
32
         job &&value.status!=3&& <MyButton value={value.status==0?'开始作业':'完成作业'} onClick={onClick} />

+ 0
- 3
src/pages/index/components/Job/index.jsx View File

1
 import Taro from "@tarojs/taro";
1
 import Taro from "@tarojs/taro";
2
 import { useState, useEffect } from "react";
2
 import { useState, useEffect } from "react";
3
 import { View, Input, Image, Text, ScrollView } from "@tarojs/components"
3
 import { View, Input, Image, Text, ScrollView } from "@tarojs/components"
4
-import CustomNav from "@/components/CustomNav";
5
 import searchImg from '@/assets/comm/search.png'
4
 import searchImg from '@/assets/comm/search.png'
6
-import withLayout from '@/layouts'
7
 import NullCard from "@/components/NullCard";
5
 import NullCard from "@/components/NullCard";
8
 import MyCard from "@/components/MyCard";
6
 import MyCard from "@/components/MyCard";
9
 import Footer from "@/components/Footer";
7
 import Footer from "@/components/Footer";
21
 
19
 
22
   const handleSearch = (e) => {
20
   const handleSearch = (e) => {
23
     if (e.detail.value) {
21
     if (e.detail.value) {
24
-      console.log(e.detail.value)
25
       setImageShow(false)
22
       setImageShow(false)
26
     } else {
23
     } else {
27
       setImageShow(true)
24
       setImageShow(true)

+ 28
- 22
src/pages/index/components/order/index.jsx View File

1
 import React, { useState, useEffect } from "react"
1
 import React, { useState, useEffect } from "react"
2
 import Taro from "@tarojs/taro";
2
 import Taro from "@tarojs/taro";
3
-import { View, Input, Swiper, Image, SwiperItem, Text, ScrollView,Button } from "@tarojs/components"
3
+import { View, Input, Swiper, Image, SwiperItem, Text, ScrollView, Button } from "@tarojs/components"
4
 import { Popup } from "@antmjs/vantui";
4
 import { Popup } from "@antmjs/vantui";
5
 import positionImg from '@/assets/comm/position.png'
5
 import positionImg from '@/assets/comm/position.png'
6
 import searchImg from '@/assets/comm/search.png'
6
 import searchImg from '@/assets/comm/search.png'
7
 import orderImg from '@/assets/comm/orderList.png'
7
 import orderImg from '@/assets/comm/orderList.png'
8
 import PositionImg from '@/assets/job/positionImg.png'
8
 import PositionImg from '@/assets/job/positionImg.png'
9
 import Footer from "@/components/Footer";
9
 import Footer from "@/components/Footer";
10
+import { useModel } from "@/store";
10
 import MyCard from "@/components/MyCard";
11
 import MyCard from "@/components/MyCard";
11
 import NullCard from "@/components/NullCard";
12
 import NullCard from "@/components/NullCard";
12
 import { getBannerList } from "@/services/banner";
13
 import { getBannerList } from "@/services/banner";
13
-import { getJobList } from '@/services/job'
14
+import { getJobList, toggleJob, overJob } from '@/services/job'
14
 import './style.less'
15
 import './style.less'
15
 
16
 
16
 
17
 
19
   const [jobList, setJobList] = useState([])
20
   const [jobList, setJobList] = useState([])
20
   const [currentPage, setCurrentPage] = useState(1)
21
   const [currentPage, setCurrentPage] = useState(1)
21
   const [isMore, setIsMore] = useState(false)
22
   const [isMore, setIsMore] = useState(false)
22
-  const [q, setQ] = useState()
23
-  
23
+  const { address } = useModel('location')
24
   const [show, setShow] = useState(false)
24
   const [show, setShow] = useState(false)
25
-  const [area,setArea]=useState()
25
+  const [area, setArea] = useState()
26
   const [showOver, setShowOver] = useState(false)
26
   const [showOver, setShowOver] = useState(false)
27
+  const [job, setJob] = useState()
27
 
28
 
28
   const handleSearch = (e) => {
29
   const handleSearch = (e) => {
29
-    setIsMore(false)
30
-    setCurrentPage(1)
31
-    setQ(e.detail.value)
30
+    Taro.navigateTo({ url: `/pages/index/index?tab=1` });
32
   }
31
   }
33
   const handleDetail = (val) => {
32
   const handleDetail = (val) => {
34
-    Taro.navigateTo({ url: `/pages/orderDetail/index?id=${val}` });
33
+    Taro.navigateTo({ url: `/pages/orderDetail/index?id=${val}&job=1` });
35
   }
34
   }
36
   // 上拉加载
35
   // 上拉加载
37
   const handleScrollToLower = () => {
36
   const handleScrollToLower = () => {
38
     setCurrentPage(currentPage + 1)
37
     setCurrentPage(currentPage + 1)
39
   }
38
   }
40
-  const handleChange = () => {
41
-    setShow(true)
42
-    // setShowOver(true)
39
+  const handleWork = (val) => {
40
+    setJob(val)
41
+    if (val.status == 0) {
42
+      setShow(true)
43
+    } else {
44
+      setShowOver(true)
45
+    }
43
   }
46
   }
44
   const onClose = () => {
47
   const onClose = () => {
45
     setShow(false)
48
     setShow(false)
49
+    setJob()
46
   }
50
   }
47
   const handleOk = () => {
51
   const handleOk = () => {
48
     console.log('开始作业')
52
     console.log('开始作业')
49
-    setShow(false)
53
+    toggleJob(job.jobId, { mode: false }).then(() => {
54
+      setShow(false)
55
+    })
50
   }
56
   }
51
-  const handleArea=(e)=>{
57
+  const handleArea = (e) => {
52
     setArea(e.detail.value)
58
     setArea(e.detail.value)
53
   }
59
   }
54
-  const onOverClose=()=>{
60
+  const onOverClose = () => {
55
     setArea()
61
     setArea()
56
     setShowOver(false)
62
     setShowOver(false)
57
   }
63
   }
58
-  const handleOverOk=()=>{
64
+  const handleOverOk = () => {
59
     if (area) {
65
     if (area) {
60
       console.log(666)
66
       console.log(666)
61
     }
67
     }
62
   }
68
   }
63
   useEffect(() => {
69
   useEffect(() => {
64
-    getJobList({ pageNum: currentPage, q: q }).then(res => {
70
+    getJobList({ pageNum: currentPage }).then(res => {
65
       const lst = currentPage === 1 ? res.records || [] : jobList.concat(res.records || [])
71
       const lst = currentPage === 1 ? res.records || [] : jobList.concat(res.records || [])
66
       //长列表加载当下一页没有数据时
72
       //长列表加载当下一页没有数据时
67
       if (res.records.length == 0 && currentPage != 1) {
73
       if (res.records.length == 0 && currentPage != 1) {
70
       }
76
       }
71
       setJobList(lst)
77
       setJobList(lst)
72
     })
78
     })
73
-  }, [currentPage, q])
79
+  }, [currentPage])
74
   useEffect(() => {
80
   useEffect(() => {
75
     getBannerList({ position: 'bannerWorker' })
81
     getBannerList({ position: 'bannerWorker' })
76
       .then(res => {
82
       .then(res => {
90
           <Text>邓州市</Text>
96
           <Text>邓州市</Text>
91
           <View className='icon' />
97
           <View className='icon' />
92
         </View>
98
         </View>
93
-        <View className='searchClass'>
94
-          <Input type='text' className='searchInput' onBlur={handleSearch} placeholder='搜索关键字查询订单' />
99
+        <View className='searchClass' onClick={handleSearch}>
100
+          <Input type='text' disabled className='searchInput' placeholder='搜索关键字查询订单' />
95
           <Image src={searchImg} className='searchImg' />
101
           <Image src={searchImg} className='searchImg' />
96
         </View>
102
         </View>
97
       </View>
103
       </View>
120
           {
126
           {
121
             jobList.length === 0 ? <NullCard value='您还没有新的作业订单!' /> :
127
             jobList.length === 0 ? <NullCard value='您还没有新的作业订单!' /> :
122
               jobList.map((item) => {
128
               jobList.map((item) => {
123
-                return <MyCard job value={item} key={item.JobId} onClick={handleChange} goDetail={handleDetail} />
129
+                return <MyCard job value={item} key={item.JobId} onClick={() => handleWork(item)} goDetail={() => handleDetail(item.jobId)} />
124
               })
130
               })
125
           }
131
           }
126
           {
132
           {
134
         >
140
         >
135
           <Image src={PositionImg} className='pImg' />
141
           <Image src={PositionImg} className='pImg' />
136
           <View>当前位置在</View>
142
           <View>当前位置在</View>
137
-          <View>河南省南阳市邓州市孟楼镇</View>
143
+          <View>{address}</View>
138
           <Button className='btn' onClick={handleOk}>确认</Button>
144
           <Button className='btn' onClick={handleOk}>确认</Button>
139
         </Popup>
145
         </Popup>
140
         <Popup
146
         <Popup

+ 79
- 78
src/pages/index/components/order/style.less View File

90
         color: #666666;
90
         color: #666666;
91
       }
91
       }
92
     }
92
     }
93
-    .tanchuang{
94
-      text-align: center;
95
-      font-size: 34px;
96
-      font-weight: 800;
97
-      color: #323232;
98
-      width: calc(100vw - 60px);
99
-      padding: 142px 130px;
100
-      box-shadow: 0px 0px 44px 0px rgba(0, 0, 0, 0.08);
93
+    
94
+  }
95
+  .tanchuang{
96
+    text-align: center;
97
+    font-size: 34px;
98
+    font-weight: 800;
99
+    color: #323232;
100
+    width: calc(100vw - 60px);
101
+    padding: 142px 130px;
102
+    box-shadow: 0px 0px 44px 0px rgba(0, 0, 0, 0.08);
103
+    border-radius: 40px;
104
+    .bankInput{
105
+      background: #FFF;
106
+      border: 2px solid #F2F2F2;
101
       border-radius: 40px;
107
       border-radius: 40px;
102
-      .bankInput{
103
-        background: #FFF;
104
-        border: 2px solid #F2F2F2;
105
-        border-radius: 40px;
106
-        display: flex;
107
-        align-items: center;
108
-        padding: 36px 30px;
109
-        margin-top: 30px;
110
-        height: 108px;
111
-        box-sizing: border-box;
112
-        .header{
113
-          font-size: 48px;
114
-          font-weight: 500;
115
-          color: #333;
116
-          flex: none;
117
-          margin-right: 20px;
118
-        }
119
-        .body{
120
-          flex: 1;
121
-          font-size: 32px;
122
-          font-weight: 400;
123
-        }
124
-      }
125
-      .pImg{
126
-        width: 80px;
127
-        height: 77px;
128
-        margin-bottom: 52px;
129
-      }
130
-      view{
131
-        text-align: left;
132
-        line-height: 46px;
108
+      display: flex;
109
+      align-items: center;
110
+      padding: 36px 30px;
111
+      margin-top: 30px;
112
+      height: 108px;
113
+      box-sizing: border-box;
114
+      .header{
115
+        font-size: 48px;
116
+        font-weight: 500;
117
+        color: #333;
118
+        flex: none;
119
+        margin-right: 20px;
133
       }
120
       }
134
-      .btn{
135
-        width: 200px;
136
-        height: 88px;
137
-        background: linear-gradient(0deg, #00AE39, #A0E067);
138
-        border-radius: 34px;
121
+      .body{
122
+        flex: 1;
139
         font-size: 32px;
123
         font-size: 32px;
140
-        color: #FFFFFF;  
141
-        margin-top: 100px;  
124
+        font-weight: 400;
142
       }
125
       }
143
     }
126
     }
144
-    .tanchuang2{
145
-      text-align: center;
146
-      font-size: 34px;
147
-      font-weight: 800;
148
-      color: #323232;
149
-      width: calc(100vw - 60px);
150
-      padding: 80px 30px;
151
-      box-shadow: 0px 0px 44px 0px rgba(0, 0, 0, 0.08);
127
+    .pImg{
128
+      width: 80px;
129
+      height: 77px;
130
+      margin-bottom: 52px;
131
+    }
132
+    view{
133
+      text-align: left;
134
+      line-height: 46px;
135
+    }
136
+    .btn{
137
+      width: 200px;
138
+      height: 88px;
139
+      background: linear-gradient(0deg, #00AE39, #A0E067);
140
+      border-radius: 34px;
141
+      font-size: 32px;
142
+      color: #FFFFFF;  
143
+      margin-top: 100px;  
144
+    }
145
+  }
146
+  .tanchuang2{
147
+    text-align: center;
148
+    font-size: 34px;
149
+    font-weight: 800;
150
+    color: #323232;
151
+    width: calc(100vw - 60px);
152
+    padding: 80px 30px;
153
+    box-shadow: 0px 0px 44px 0px rgba(0, 0, 0, 0.08);
154
+    border-radius: 40px;
155
+    .bankInput{
156
+      border: 2px solid #F2F2F2;
152
       border-radius: 40px;
157
       border-radius: 40px;
153
-      .bankInput{
154
-        border: 2px solid #F2F2F2;
155
-        border-radius: 40px;
156
-        display: flex;
157
-        align-items: center;
158
-        padding: 36px 30px;
159
-        box-sizing: border-box;
160
-        .header{
161
-          font-weight: 500;
162
-          color: #333;
163
-          flex: none;
164
-        }
165
-        .body{
166
-          flex: 1;
167
-          font-size: 32px;
168
-          font-weight: 400;
169
-        }
158
+      display: flex;
159
+      align-items: center;
160
+      padding: 36px 30px;
161
+      box-sizing: border-box;
162
+      .header{
163
+        font-weight: 500;
164
+        color: #333;
165
+        flex: none;
170
       }
166
       }
171
-      .btn{
172
-        width: 200px;
173
-        height: 88px;
174
-        background: linear-gradient(0deg, #00AE39, #A0E067);
175
-        border-radius: 34px;
167
+      .body{
168
+        flex: 1;
176
         font-size: 32px;
169
         font-size: 32px;
177
-        color: #FFFFFF;  
178
-        margin-top: 50px;  
170
+        font-weight: 400;
179
       }
171
       }
180
     }
172
     }
173
+    .btn{
174
+      width: 200px;
175
+      height: 88px;
176
+      background: linear-gradient(0deg, #00AE39, #A0E067);
177
+      border-radius: 34px;
178
+      font-size: 32px;
179
+      color: #FFFFFF;  
180
+      margin-top: 50px;  
181
+    }
181
   }
182
   }
182
 }
183
 }
183
 
184
 

+ 9
- 3
src/pages/index/index.jsx View File

22
 export default withLayout((props) => {
22
 export default withLayout((props) => {
23
   const { router } = props
23
   const { router } = props
24
   let { tab } = router.params
24
   let { tab } = router.params
25
-  const { location, setLocation } = useModel('location')
25
+  const { location, setLocation, setAddress } = useModel('location')
26
   const { person } = useModel('person')
26
   const { person } = useModel('person')
27
   const [currentTab, setCurrentTab] = useState(0)
27
   const [currentTab, setCurrentTab] = useState(0)
28
   const [show, setShow] = useState(false)
28
   const [show, setShow] = useState(false)
41
         type: 'gcj02',
41
         type: 'gcj02',
42
         success: function (res) {
42
         success: function (res) {
43
           setLocation(res.longitude + ',' + res.latitude)
43
           setLocation(res.longitude + ',' + res.latitude)
44
-          setAmap({ params: 'location=' + res.longitude + ',' + res.latitude, path: '/v3/geocode/regeo' })
44
+          setAmap({ params: 'location=' + res.longitude + ',' + res.latitude, path: '/v3/geocode/regeo' }).then(res2 => {
45
+            //josn对象取值
46
+            setAddress(JSON.parse(res2)['regeocode'].formatted_address)
47
+          })
45
         }
48
         }
46
       })
49
       })
47
     } else {
50
     } else {
48
-      setAmap({ params: 'location=' + location, path: '/v3/geocode/regeo' })
51
+      setAmap({ params: 'location=' + location, path: '/v3/geocode/regeo' }).then(res2 => {
52
+        //josn对象取值
53
+        setAddress(JSON.parse(res2)['regeocode'].formatted_address)
54
+      })
49
     }
55
     }
50
   }, [])
56
   }, [])
51
   useEffect(() => {
57
   useEffect(() => {

+ 15
- 8
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"
5
+import { useEffect, useState } from "react"
6
 import { getOrderDetail } from "@/services/order"
6
 import { getOrderDetail } from "@/services/order"
7
+import { getJobDetail } from '@/services/job'
7
 
8
 
8
 
9
 
9
 export default withLayout((props) => {
10
 export default withLayout((props) => {
10
   const { router } = props
11
   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])
12
+  let { id, job } = router.params
13
+  const [value, setValue] = useState()
14
+  useEffect(() => {
15
+    if (job) {
16
+      getJobDetail(id).then(res => {
17
+        setValue(res)
18
+      })
19
+    } else {
20
+      getOrderDetail(id).then((res) => {
21
+        setValue(res)
22
+      })
23
+    }
24
+  }, [id])
18
   return (
25
   return (
19
     <View className='page-index'>
26
     <View className='page-index'>
20
       <View className='index-navbar'>
27
       <View className='index-navbar'>

+ 1
- 1
src/services/job.js View File

19
  * @param {*} data
19
  * @param {*} data
20
  * @returns
20
  * @returns
21
  */
21
  */
22
-export const toggleJob = (id, data) => request(`/worker/work-job/${id}/pause`, { method: 'put', data });
22
+export const toggleJob = (id, data) => request(`/work-job/${id}/pause`, { method: 'put', data });
23
 
23
 
24
 /**
24
 /**
25
  * 完成作业
25
  * 完成作业

+ 3
- 1
src/store/models/location.js View File

2
 
2
 
3
 export default function useLocation() {
3
 export default function useLocation() {
4
   const [location, setLocation] = useState()
4
   const [location, setLocation] = useState()
5
-
5
+  const [address,setAddress]=useState()
6
   return {
6
   return {
7
     location,
7
     location,
8
     setLocation,
8
     setLocation,
9
+    address,
10
+    setAddress
9
   }
11
   }
10
 }
12
 }