张延森 2 年之前
父節點
當前提交
6dc2cf3a52

+ 1
- 1
config/dev.js 查看文件

@@ -4,7 +4,7 @@ module.exports = {
4 4
   },
5 5
   defineConstants: {
6 6
     // HOST: '"https://machine.njyunzhi.com"',
7
-    HOST: '"http://192.168.89.25:7080"',
7
+    HOST: '"http://127.0.0.1:7080"',
8 8
     OSS: '""',
9 9
     // VERSION: '"2.0.33"',
10 10
   },

+ 1
- 1
src/components/CarsListContent/index.jsx 查看文件

@@ -60,7 +60,7 @@ export default withLayout((props) => {
60 60
               <View className='carsListImga-bottom-box-flaxBox'>
61 61
                 <View className='carsListImga-bottom-box-flaxBox-liftText'>
62 62
                   <View className='carsListImga-bottom-box-flaxBox-liftText-Titles'>{item.name}</View>
63
-                  <View className='carsListImga-bottom-box-flaxBox-liftText-price'>{formatPrice(item.price)}/<Text>公顷</Text></View>
63
+                  <View className='carsListImga-bottom-box-flaxBox-liftText-price'>{formatPrice(item.price)}/<Text></Text></View>
64 64
                 </View>
65 65
                 <View className='carsListImga-bottom-box-flaxBox-rightBut'>
66 66
                   <ButtontWX onClick={() => startReserve(item.machineryId)} butText='预约' butWidth={80} butHeight={34} butFontSize={19} butBorderRadius={0} />

+ 1
- 1
src/pages/CheckDetails/index.jsx 查看文件

@@ -78,7 +78,7 @@ export default withLayout((props) => {
78 78
           <View className='CarsContent-TextBox'>
79 79
             <View className='CheckDetails-bottom-box-flaxBox-liftText'>
80 80
               <View className='CheckDetails-bottom-box-flaxBox-liftText-Titles'>{carsInfo?.name}</View>
81
-              <View className='CheckDetails-bottom-box-flaxBox-liftText-price'>{formatPrice(carsInfo.price)}/<Text>公顷</Text></View>
81
+              <View className='CheckDetails-bottom-box-flaxBox-liftText-price'>{formatPrice(carsInfo.price)}/<Text></Text></View>
82 82
             </View>
83 83
             <View className='content-header-box-map-Info' onClick={() => goMapInfo('222888')}>
84 84
               <View className='content-header-box-map-Info-liftCentent'>

+ 1
- 1
src/pages/CheckMap/index.jsx 查看文件

@@ -89,7 +89,7 @@ export default withLayout((props) => {
89 89
             <View className='CarsContent-TextBox'>
90 90
               <View className='CheckDetails-bottom-box-flaxBox-liftText'>
91 91
                 <View className='CheckDetails-bottom-box-flaxBox-liftText-Titles'>{carsInfo.name}</View>
92
-                <View className='CheckDetails-bottom-box-flaxBox-liftText-price'>{(carsInfo.price / 100).toFixed(2)}/<Text>公顷</Text></View>
92
+                <View className='CheckDetails-bottom-box-flaxBox-liftText-price'>{(carsInfo.price / 100).toFixed(2)}/<Text></Text></View>
93 93
               </View>
94 94
               <View className='content-header-box-map-Info'>
95 95
                 <View className='content-header-box-map-Info-liftCentent'>

+ 1
- 1
src/pages/MoreCars/CarTypeList.jsx 查看文件

@@ -53,7 +53,7 @@ export default withLayout((props) => {
53 53
               <View className='carsListImga-bottom-box-flaxBox'>
54 54
                 <View className='carsListImga-bottom-box-flaxBox-liftText'>
55 55
                   <View className='carsListImga-bottom-box-flaxBox-liftText-Titles'>{item.name}</View>
56
-                  <View className='carsListImga-bottom-box-flaxBox-liftText-price'>{formatPrice(item.price)}/<Text>公顷</Text></View>
56
+                  <View className='carsListImga-bottom-box-flaxBox-liftText-price'>{formatPrice(item.price)}/<Text></Text></View>
57 57
                 </View>
58 58
                 <View className='carsListImga-bottom-box-flaxBox-rightBut'>
59 59
                   <ButtontWX onClick={() => startReserve(item.machineryId)} butText='预约' butWidth={80} butHeight={34} butFontSize={19} butBorderRadius={0} />

+ 2
- 2
src/pages/OrderConfirmation/index.jsx 查看文件

@@ -136,8 +136,8 @@ export default withLayout((props) => {
136 136
       <View className='pagesBox'>
137 137
         <Form onSubmit={formSubmit} >
138 138
           <View className='example-body-WorkingArea'>
139
-            <View>作业面积/公顷</View>
140
-            <Input name='amount' type='number' maxlength={6} className='aTextareaCentent' placeholder='请输入作业面积/公顷' />
139
+            <View>作业面积/</View>
140
+            <Input name='amount' type='number' maxlength={6} className='aTextareaCentent' placeholder='请输入作业面积/' />
141 141
           </View>
142 142
           <View className='example-body-WorkingTime'>
143 143
             <View>作业时间:</View>

+ 33
- 37
src/pages/OrderInfo/index.jsx 查看文件

@@ -1,5 +1,5 @@
1 1
 import { View, Text } from "@tarojs/components"
2
-import { useEffect, useState } from "react"
2
+import { useEffect, useState, useMemo } from "react"
3 3
 import Taro, { useDidShow } from "@tarojs/taro"
4 4
 import CustomNav from '@/components/CustomNav'
5 5
 import ButtontWX from '@/components/ButtontWX'
@@ -7,27 +7,24 @@ import formatTimes from "@/utils/codeSegment"
7 7
 import withLayout from '@/layouts'
8 8
 import formatPrice from "@/utils/formatPrice"
9 9
 import AssessModel from "@/components/AssessModel"
10
-
10
+import useProcessStatus, { getProcessSignBy } from "@/utils/hooks/useProcessStatus"
11 11
 import { orderPrepay, orderDelete, orderInfo, orderRefund } from "@/services/order"
12 12
 // import BottomMoadl from '@/components/BottomMoadl/index'
13 13
 
14 14
 
15
-
16
-
17
-
18
-
19 15
 import './style.less'
20 16
 
21 17
 export default withLayout((props) => {
22 18
   // const { stateType } = props
23 19
 
24 20
   const $instance = Taro.getCurrentInstance()
25
-  const { orderId, stateType, stateStyle } = $instance.router.params
21
+  const { orderId } = $instance.router.params
26 22
 
27 23
   const [orderInfos, setOrderInfos] = useState()
28
-  console.log("🚀 ~ file: index.jsx ~ line 27 ~ stateType ~ stateType", stateType)
24
+
29 25
   const [isAssessVisible, setIsAssessVisible] = useState(false)
30 26
 
27
+  const { processStatus } = useProcessStatus(orderInfos)
31 28
 
32 29
   //底部弹窗
33 30
   // const [showFrame, setShowFrame] = useState(false)
@@ -117,10 +114,6 @@ export default withLayout((props) => {
117 114
     })
118 115
   }
119 116
 
120
-
121
-
122
-
123
-
124 117
   const pay = () => {
125 118
 
126 119
     orderPrepay(orderId, {
@@ -179,6 +172,32 @@ export default withLayout((props) => {
179 172
 
180 173
   }
181 174
 
175
+  const { processLabel, stateStyle, action : Actions } = useMemo(() => {
176
+    const { label, color } = getProcessSignBy(processStatus)
177
+    let action = <></>;
178
+
179
+    switch (processStatus) {
180
+      case 1:
181
+      case 2:
182
+        action = <ButtontWX butText='取消' styleType onClick={cancelPay} butWidth={150} butHeight={39} butFontSize={16} butBorderRadius={49} />;
183
+        break;
184
+      case 4:
185
+        action = <ButtontWX butText='支付' onClick={pay} butWidth={150} butHeight={39} butFontSize={16} butBorderRadius={49} />;
186
+        break;
187
+      case 5:
188
+        action = <ButtontWX butText='评价' onClick={startModle} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />;
189
+        break;
190
+      case 3:
191
+      case 6:
192
+      default:
193
+        break;
194
+    }
195
+    return  {
196
+      processLabel: label,
197
+      stateStyle: color,
198
+      action
199
+    }
200
+  }, [processStatus])
182 201
 
183 202
   return (
184 203
     <View className='page-index'>
@@ -193,37 +212,14 @@ export default withLayout((props) => {
193 212
         <View>作业面积:<Text>{orderInfos?.amount}</Text></View>
194 213
         <View>需求时间:<Text>{formatTimes(orderInfos?.appointmentDate, 'yyyy-MM-dd')}</Text></View>
195 214
         <View>下单时间:<Text>{formatTimes(orderInfos?.createDate, 'yyyy-MM-dd')}</Text></View>
196
-        <View>订单状态:<Text style={{ color: `${stateStyle}` }}  >{stateType === '已付款' ? '已付款,待调度' : stateType}</Text></View>
215
+        <View>订单状态:<Text style={{ color: `${stateStyle}` }}  >{processLabel}</Text></View>
197 216
         <View className='View-LiftTextBotton'>
198 217
           <View className='feiyongStyle'>费用:<Text className='feiyongStyle-charges' >{formatPrice(orderInfos?.charges)}</Text></View>
199 218
           <View className='feiyongStyle'>状态:<Text style={{ color: `${stateStyle}` }} className='feiyongStyle-stateStyle' >{orderInfos?.payStatus === 1 ? '已付款' : '待付款'}</Text></View>
200 219
         </View>
201 220
       </View>
202 221
       <View className='BottomtBut' >
203
-        <>
204
-          {
205
-            stateType == '已完成' ? <></>
206
-              : stateType == '进行中' ? <></>
207
-                : stateType == '待评价' ? <ButtontWX butText='评价' onClick={startModle} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />
208
-                  : stateType == '待作业' ? <ButtontWX butText='退单' onClick={orderRefunds} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />
209
-                    : stateType == '待付款' ? <>
210
-                      <ButtontWX butText='取消' styleType onClick={cancelPay} butWidth={150} butHeight={39} butFontSize={16} butBorderRadius={49} />
211
-                      <ButtontWX butText='支付' onClick={pay} butWidth={150} butHeight={39} butFontSize={16} butBorderRadius={49} />
212
-                    </> : stateType == '已付款' ?
213
-                      <ButtontWX butText='退单' onClick={orderRefunds} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />
214
-                      // <ButtontWX butText={`${orderInfos?.payStatus == 3 ? '退单申请中' : '退单'}`} disabled={orderInfos?.payStatus == 3 ? true : false} onClick={orderInfos?.payStatus == 3 ? '' : orderRefunds} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />
215
-                      : stateType == '待作业' ? <ButtontWX butText={`${orderInfos?.payStatus == 3 ? '退单申请中' : '退单'}`} disabled={orderInfos?.payStatus == 3 ? true : false} onClick={orderInfos?.payStatus == 3 ? '' : orderRefunds} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />
216
-
217
-                        : stateType == '已退单' ? <></>
218
-                          : stateType == '退单申请中' ? <ButtontWX butText={`${orderInfos?.payStatus == 3 ? '退单申请中' : '退单'}`} disabled={orderInfos?.payStatus == 3 ? true : false} onClick={orderInfos?.payStatus == 3 ? '' : orderRefunds} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />
219
-
220
-                            : <></>
221
-          }
222
-        </>
223
-
224
-
225
-
226
-
222
+        {Actions}
227 223
       </View>
228 224
     </View>
229 225
   )

+ 5
- 48
src/pages/index/tabs/Orders.jsx 查看文件

@@ -11,6 +11,7 @@ import { getOrder } from "@/services/order"
11 11
 import formatTimes from "@/utils/codeSegment"
12 12
 import { useModel } from "@/store"
13 13
 import formatPrice from "@/utils/formatPrice"
14
+import { getProcessStatus, getProcessSignBy } from "@/utils/hooks/useProcessStatus"
14 15
 
15 16
 import './OrdersCss/style.less'
16 17
 
@@ -60,53 +61,9 @@ export default withLayout((props) => {
60 61
   console.log(ourderList, 'ourderList');
61 62
 
62 63
   const orderStates = (item) => {
63
-    if (item.payStatus === 0) {
64
-      return {
65
-        title: '待付款',
66
-        styleColor: '#51D4FF'
67
-      }
68
-    } else if (item.payStatus === 1 && item.workStatus === 0 && item.dispatchStatus === 0) {
69
-      return {
70
-        title: '已付款',
71
-        styleColor: '#FF703B'
72
-      }
73
-    } else if (item.payStatus == 1 && item.dispatchStatus === 1 && item.workStatus === 0) {
74
-      return {
75
-        title: '待作业',
76
-        styleColor: '#FF703B'
77
-      }
78
-
79
-    } else if (item.payStatus === 1 && (item.workStatus === 1 || item.workStatus === 2)) {
80
-      return {
81
-        title: '进行中',
82
-        styleColor: '#44F68B'
83
-      }
84
-    } else if (item.workStatus === 3 && item.isEvaluated === 0) {
85
-      return {
86
-        title: '待评价',
87
-        styleColor: '#51D4FF'
88
-      }
89
-    } if (item.workStatus === 3 && item.isEvaluated === 1 && item.dispatchStatus == 1) {
90
-      return {
91
-        title: '已完成',
92
-        styleColor: '#FF703B'
93
-      }
94
-    } else if (item.payStatus === -1 && item.workStatus === 0 && item.isRefund === 1) {
95
-      return {
96
-        title: '已退单',
97
-        styleColor: '#FF703B'
98
-      }
99
-    } else if (item.payStatus === 3 && (item.dispatchStatus == 1 || item.dispatchStatus == 0)) {
100
-      return {
101
-        title: '退单申请中',
102
-        styleColor: '#FF703B'
103
-      }
104
-    } else {
105
-      return {
106
-        title: '异常',
107
-        styleColor: '#FF0000'
108
-      }
109
-    }
64
+    const processStatus = getProcessStatus(item)
65
+    const { label: title, color: styleColor } = getProcessSignBy(processStatus)
66
+    return { title, styleColor }
110 67
   }
111 68
 
112 69
   const handleTobePaid = (id, stateType, stateStyle) => {
@@ -135,7 +92,7 @@ export default withLayout((props) => {
135 92
               <Image src={ordersLeft} />
136 93
               <View className='orders-listBox-RihtboxBoxOrderViewText'>
137 94
                 <View className='View-LiftTextTop' onClick={() => handleTobePaid(item.orderId, orderStates(item)?.title, orderStates(item)?.styleColor)} >
138
-                  订单编号:<Text>{item.orderNo}</Text><Text className='View-LiftTextTop-nextText'>详情&gt;&gt;</Text></View>
95
+                  编号:<Text>{item.orderNo}</Text><Text className='View-LiftTextTop-nextText'>详情&gt;&gt;</Text></View>
139 96
                 <View>农机名称:<Text>{item.machineryName}</Text></View>
140 97
                 <View>作业面积:<Text>{item.amount}</Text></View>
141 98
                 <View>需求时间:<Text>{formatTimes(item.appointmentDate, 'yyyy-MM-dd')}</Text></View>

+ 102
- 0
src/utils/hooks/useProcessStatus.js 查看文件

@@ -0,0 +1,102 @@
1
+import { useState, useEffect } from "react";
2
+
3
+export default function useProcessStatus(orderInfo) {
4
+/**
5
+ * 业务流程如下:
6
+ * 1、农户下单 - 未支付 (管理端待分配订单)
7
+ * 2、农机手待接单
8
+ * 3、农机手接单干活
9
+ * 4、农机手结单 - 确定亩数 (农户待支付)
10
+ * 5、农户待评价
11
+ * 6、结单(订单完成)
12
+ */
13
+
14
+  const [processStatus, setProcessStatus] = useState()
15
+
16
+  useEffect(() => {
17
+    if (!orderInfo || !orderInfo.orderId) return;
18
+
19
+    setProcessStatus(getProcessStatus(orderInfo));
20
+  }, [orderInfo])
21
+
22
+  return { processStatus }
23
+}
24
+
25
+export function getProcessStatus(orderInfo) {
26
+  
27
+  if (!orderInfo || !orderInfo.orderId) return;
28
+
29
+  // 订单完成
30
+  if (orderInfo.isEvaluated) {
31
+    return 6
32
+  }
33
+  
34
+  // 待支付
35
+  if (orderInfo.workStatus === 3 && orderInfo.charges > 0 && orderInfo.payStatus !== 1) {
36
+    return 4
37
+  }
38
+
39
+  // 待评价
40
+  if (orderInfo.workStatus === 3 && !orderInfo.isEvaluated) {
41
+    return 5
42
+  }
43
+
44
+  // 工作中
45
+  if (orderInfo.workStatus !== 3 && orderInfo.dispatchStatus) {
46
+    return 3
47
+  }
48
+
49
+  // 待接单
50
+  if (!orderInfo.workStatus && orderInfo.dispatchStatus) {
51
+    return 2
52
+  }
53
+
54
+  // 待分配
55
+  if (orderInfo.status === 1 && !orderInfo.dispatchStatus) {
56
+    return 1
57
+  }
58
+  
59
+  return -1
60
+}
61
+
62
+export function getProcessSignBy(status) {
63
+  if (status === undefined || status === null) return {}
64
+  
65
+  switch (status) {
66
+    case 1:
67
+      return {
68
+        label: '待分配',
69
+        color: '#FF703B'
70
+      }
71
+    case 2:
72
+      return {
73
+        label: '待作业',
74
+        color: '#FF703B'
75
+      }
76
+    case 3:
77
+      return {
78
+        label: '进行中',
79
+        color: '#44F68B'
80
+      }
81
+    case 4:
82
+      return {
83
+        label: '待付款',
84
+        color: '#51D4FF'
85
+      }
86
+    case 5:
87
+      return {
88
+        label: '待评价',
89
+        color: '#51D4FF'
90
+      }
91
+    case 6:
92
+      return {
93
+        label: '已完成',
94
+        color: '#FF703B'
95
+      }
96
+    default:
97
+      return {
98
+        label: '异常',
99
+        color: '#FF0000'
100
+      }
101
+  }
102
+}

+ 4260
- 109
yarn.lock
文件差異過大導致無法顯示
查看文件