李志伟 пре 3 година
родитељ
комит
7c2dd10fd9

+ 7
- 8
src/components/MyCard/index.jsx Прегледај датотеку

@@ -1,5 +1,5 @@
1 1
 import Taro from "@tarojs/taro"
2
-import { View, Text } from '@tarojs/components'
2
+import { View } from '@tarojs/components'
3 3
 import Jianbian from "@/components/Jianbian"
4 4
 import MyCell from "../MyCell"
5 5
 import MyButton from "../MyButton"
@@ -7,27 +7,26 @@ import './style.less'
7 7
 
8 8
 export default (props) => {
9 9
   const { detail, order, job, value, onClick,goDetail } = props
10
-  
11 10
   return (
12 11
     <View className='card'>
13 12
       <Jianbian status={job?value?.status:value?.workStatus} />
14 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 20
       </View>
22 21
       <View className='line' />
23
-      <MyCell header='农机名称'>{value?.machineryName||'收割机001'}</MyCell>
22
+      <MyCell header='农机名称'>{value?.machineryName}</MyCell>
24 23
       <MyCell header='下单人'>{value?.personName}</MyCell>
25 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 30
       <MyCell header='订单费用'>{(value?.charges&&value.charges/100)||600}元</MyCell>
32 31
       {
33 32
         job &&value.status!=3&& <MyButton value={value.status==0?'开始作业':'完成作业'} onClick={onClick} />

+ 0
- 3
src/pages/index/components/Job/index.jsx Прегледај датотеку

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

+ 28
- 22
src/pages/index/components/order/index.jsx Прегледај датотеку

@@ -1,16 +1,17 @@
1 1
 import React, { useState, useEffect } from "react"
2 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 4
 import { Popup } from "@antmjs/vantui";
5 5
 import positionImg from '@/assets/comm/position.png'
6 6
 import searchImg from '@/assets/comm/search.png'
7 7
 import orderImg from '@/assets/comm/orderList.png'
8 8
 import PositionImg from '@/assets/job/positionImg.png'
9 9
 import Footer from "@/components/Footer";
10
+import { useModel } from "@/store";
10 11
 import MyCard from "@/components/MyCard";
11 12
 import NullCard from "@/components/NullCard";
12 13
 import { getBannerList } from "@/services/banner";
13
-import { getJobList } from '@/services/job'
14
+import { getJobList, toggleJob, overJob } from '@/services/job'
14 15
 import './style.less'
15 16
 
16 17
 
@@ -19,49 +20,54 @@ export default (props) => {
19 20
   const [jobList, setJobList] = useState([])
20 21
   const [currentPage, setCurrentPage] = useState(1)
21 22
   const [isMore, setIsMore] = useState(false)
22
-  const [q, setQ] = useState()
23
-  
23
+  const { address } = useModel('location')
24 24
   const [show, setShow] = useState(false)
25
-  const [area,setArea]=useState()
25
+  const [area, setArea] = useState()
26 26
   const [showOver, setShowOver] = useState(false)
27
+  const [job, setJob] = useState()
27 28
 
28 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 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 36
   const handleScrollToLower = () => {
38 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 47
   const onClose = () => {
45 48
     setShow(false)
49
+    setJob()
46 50
   }
47 51
   const handleOk = () => {
48 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 58
     setArea(e.detail.value)
53 59
   }
54
-  const onOverClose=()=>{
60
+  const onOverClose = () => {
55 61
     setArea()
56 62
     setShowOver(false)
57 63
   }
58
-  const handleOverOk=()=>{
64
+  const handleOverOk = () => {
59 65
     if (area) {
60 66
       console.log(666)
61 67
     }
62 68
   }
63 69
   useEffect(() => {
64
-    getJobList({ pageNum: currentPage, q: q }).then(res => {
70
+    getJobList({ pageNum: currentPage }).then(res => {
65 71
       const lst = currentPage === 1 ? res.records || [] : jobList.concat(res.records || [])
66 72
       //长列表加载当下一页没有数据时
67 73
       if (res.records.length == 0 && currentPage != 1) {
@@ -70,7 +76,7 @@ export default (props) => {
70 76
       }
71 77
       setJobList(lst)
72 78
     })
73
-  }, [currentPage, q])
79
+  }, [currentPage])
74 80
   useEffect(() => {
75 81
     getBannerList({ position: 'bannerWorker' })
76 82
       .then(res => {
@@ -90,8 +96,8 @@ export default (props) => {
90 96
           <Text>邓州市</Text>
91 97
           <View className='icon' />
92 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 101
           <Image src={searchImg} className='searchImg' />
96 102
         </View>
97 103
       </View>
@@ -120,7 +126,7 @@ export default (props) => {
120 126
           {
121 127
             jobList.length === 0 ? <NullCard value='您还没有新的作业订单!' /> :
122 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,7 +140,7 @@ export default (props) => {
134 140
         >
135 141
           <Image src={PositionImg} className='pImg' />
136 142
           <View>当前位置在</View>
137
-          <View>河南省南阳市邓州市孟楼镇</View>
143
+          <View>{address}</View>
138 144
           <Button className='btn' onClick={handleOk}>确认</Button>
139 145
         </Popup>
140 146
         <Popup

+ 79
- 78
src/pages/index/components/order/style.less Прегледај датотеку

@@ -90,94 +90,95 @@
90 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 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 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 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 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 Прегледај датотеку

@@ -22,7 +22,7 @@ import "./index.less";
22 22
 export default withLayout((props) => {
23 23
   const { router } = props
24 24
   let { tab } = router.params
25
-  const { location, setLocation } = useModel('location')
25
+  const { location, setLocation, setAddress } = useModel('location')
26 26
   const { person } = useModel('person')
27 27
   const [currentTab, setCurrentTab] = useState(0)
28 28
   const [show, setShow] = useState(false)
@@ -41,11 +41,17 @@ export default withLayout((props) => {
41 41
         type: 'gcj02',
42 42
         success: function (res) {
43 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 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 57
   useEffect(() => {

+ 15
- 8
src/pages/orderDetail/index.jsx Прегледај датотеку

@@ -2,19 +2,26 @@ import { View } from "@tarojs/components"
2 2
 import CustomNav from "@/components/CustomNav"
3 3
 import MyCard from "@/components/MyCard"
4 4
 import withLayout from '@/layouts'
5
-import { useEffect , useState } from "react"
5
+import { useEffect, useState } from "react"
6 6
 import { getOrderDetail } from "@/services/order"
7
+import { getJobDetail } from '@/services/job'
7 8
 
8 9
 
9 10
 export default withLayout((props) => {
10 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 25
   return (
19 26
     <View className='page-index'>
20 27
       <View className='index-navbar'>

+ 1
- 1
src/services/job.js Прегледај датотеку

@@ -19,7 +19,7 @@ import request from '@/utils/request'
19 19
  * @param {*} data
20 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 Прегледај датотеку

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