|
@@ -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
|
)
|