[baozhangchao] 3 лет назад
Родитель
Сommit
6fc8d483bc

+ 3
- 0
src/pages/MyAddressList/AddressInfos/index.jsx Просмотреть файл

@@ -10,6 +10,7 @@ import './style.less'
10 10
 
11 11
 
12 12
 
13
+
13 14
 export default withLayout((props) => {
14 15
   console.log("🚀 ~ file: index.jsx ~ line 14 ~ props", props)
15 16
 
@@ -20,7 +21,9 @@ export default withLayout((props) => {
20 21
 
21 22
     const value = e?.detail?.value
22 23
     console.log(value)
24
+
23 25
     if (addressId) {
26
+
24 27
       addressUpdate(addressId, { address: value.address }).then((res) => {
25 28
         console.log('地址修改成功', res);
26 29
         Taro.showToast({

+ 91
- 6
src/pages/OrderInfo/index.jsx Просмотреть файл

@@ -8,7 +8,7 @@ import withLayout from '@/layouts'
8 8
 import formatPrice from "@/utils/formatPrice"
9 9
 import AssessModel from "@/components/AssessModel"
10 10
 
11
-import { generateOrder, orderDelete, orderInfo } from "@/services/order"
11
+import { orderPrepay, orderDelete, orderInfo, orderRefund } from "@/services/order"
12 12
 // import BottomMoadl from '@/components/BottomMoadl/index'
13 13
 
14 14
 
@@ -84,10 +84,88 @@ export default withLayout((props) => {
84 84
 
85 85
   }, [orderId])
86 86
 
87
+  const requestPayment = (params) => {
88
+    Taro.hideLoading()
89
+    console.log("🚀 ~ file: index.jsx ~ line 92 ~ requestPayment ~ params", params)
90
+    Taro.requestPayment({
91
+      ...params,
92
+
93
+      package: params.packageValue,
94
+      success: () => {
95
+        Taro.showToast({
96
+          title: "支付成功",
97
+          icon: "success",
98
+          duration: 1000,
99
+        }).then(() => {
100
+          setTimeout(() => {
101
+            Taro.reLaunch({
102
+              url: `/pages/index/index?tab=1`
103
+            })
104
+          }, 400)
105
+        })
106
+      },
107
+      fail: (e) => {
108
+        Taro.showToast({
109
+          title: "支付失败",
110
+          icon: "none",
111
+          duration: 2000,
112
+        });
113
+        Taro.reLaunch({
114
+          // url: `/pages/MineUserAll/AllOrder/index?tabJump=1`
115
+        })
116
+      },
117
+    })
118
+  }
119
+
120
+
121
+
122
+
123
+
87 124
   const pay = () => {
125
+    orderPrepay(orderId, {
126
+      payType: 'wx',
127
+
128
+    }).then((e) => {
129
+      console.log('订单返回', e);
130
+      Taro.showLoading({
131
+        title: '支付中',
132
+      })
133
+      requestPayment(e)
134
+
135
+    })
88 136
     //支付逻辑
89 137
   }
90 138
 
139
+  //退单
140
+  const orderRefunds = () => {
141
+    Taro.showLoading({
142
+      title: '退单申请中',
143
+    })
144
+    orderRefund(orderId).then(() => {
145
+      Taro.showLoading()
146
+
147
+      Taro.showToast({
148
+        title: "退单成功",
149
+        icon: "none",
150
+        duration: 2000,
151
+      }).then(() => {
152
+        setTimeout(() => {
153
+          Taro.navigateBack({
154
+            delta: 1
155
+          })
156
+        }, 400)
157
+
158
+
159
+      })
160
+    }).catch(() => {
161
+      Taro.showLoading()
162
+      Taro.showToast({
163
+        title: "请重试",
164
+        icon: "error",
165
+        duration: 2000,
166
+      });
167
+    })
168
+  }
91 169
   const startModle = () => {
92 170
     setIsAssessVisible(true)
93 171
 
@@ -114,10 +192,10 @@ export default withLayout((props) => {
114 192
         <View>作业面积:<Text>{orderInfos?.amount}</Text></View>
115 193
         <View>需求时间:<Text>{formatTimes(orderInfos?.appointmentDate, 'yyyy-MM-dd')}</Text></View>
116 194
         <View>下单时间:<Text>{formatTimes(orderInfos?.createDate, 'yyyy-MM-dd')}</Text></View>
117
-        <View>订单状态:<Text  >{orderInfos?.payStatus}</Text></View>
195
+        <View>订单状态:<Text style={{ color: `${stateStyle}` }}  >{stateType}</Text></View>
118 196
         <View className='View-LiftTextBotton'>
119 197
           <View className='feiyongStyle'>费用:<Text className='feiyongStyle-charges' >{formatPrice(orderInfos?.charges)}</Text></View>
120
-          <View className='feiyongStyle'>状态:<Text style={{ color: `${stateStyle}` }} className='feiyongStyle-stateStyle' >{stateType}</Text></View>
198
+          <View className='feiyongStyle'>状态:<Text style={{ color: `${stateStyle}` }} className='feiyongStyle-stateStyle' >{orderInfos?.payStatus === 1 ? '已付款' : '待付款'}</Text></View>
121 199
         </View>
122 200
       </View>
123 201
       <View className='BottomtBut' >
@@ -126,13 +204,20 @@ export default withLayout((props) => {
126 204
             stateType == '已完成' ? <></>
127 205
               : stateType == '进行中' ? <></>
128 206
                 : stateType == '待评价' ? <ButtontWX butText='评价' onClick={startModle} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />
129
-                  : stateType == '待作业' ? <ButtontWX butText='退单' onClick={cancelPay} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />
207
+                  : stateType == '待作业' ? <ButtontWX butText='退单' onClick={orderRefunds} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />
130 208
                     : stateType == '待付款' ? <>
131 209
                       <ButtontWX butText='取消' styleType onClick={cancelPay} butWidth={150} butHeight={39} butFontSize={16} butBorderRadius={49} />
132 210
                       <ButtontWX butText='支付' onClick={pay} butWidth={150} butHeight={39} butFontSize={16} butBorderRadius={49} />
133 211
                     </> : stateType == '已付款' ?
134
-                      <ButtontWX butText='退单' onClick={cancelPay} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />
135
-                      : stateType == '已退单' ? <></> : <></>
212
+                      <ButtontWX butText='退单' onClick={orderRefunds} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />
213
+
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
+                            : <></>
136 221
           }
137 222
         </>
138 223
 

+ 1
- 1
src/pages/index/tabs/Mine.jsx Просмотреть файл

@@ -40,7 +40,7 @@ export default withLayout((props) => {
40 40
   useDidShow(() => {
41 41
     getAddress().then((e) => {
42 42
       let abccList = e.records.sort((a, b) => b.isDefault - a.isDefault)
43
-      if (abccList.length!=0) {        
43
+      if (abccList.length != 0) {
44 44
         setAddresInfo(abccList[0].address)
45 45
       }
46 46
     })

+ 36
- 6
src/pages/index/tabs/Orders.jsx Просмотреть файл

@@ -20,22 +20,43 @@ export default withLayout((props) => {
20 20
 
21 21
   const [ourderList, setOrderList] = useState([])
22 22
 
23
+  const [currentPage, setCurrentPage] = useState(1)
24
+
25
+  const [isMore, setIsMore] = useState(false)
23 26
 
24 27
   const { person, setPerson } = useModel('userData')
25 28
 
26 29
 
27 30
   useDidShow(() => {
28
-    getOrder({ pageSize: 30 }).then((e) => {
31
+    getOrder({ pageNum: currentPage || 1, mine: true }).then((e) => {
29 32
       const { records } = e
30 33
       setOrderList(records)
31 34
     })
32 35
   })
36
+
37
+  const handleScrollToLower = () => {
38
+    if (ourderList.length < 9) {
39
+      return;
40
+    } else {
41
+      setCurrentPage(currentPage + 1)
42
+
43
+    }
44
+  }
33 45
   useEffect(() => {
34
-    getOrder({ pageSize: 31 }).then((e) => {
35
-      const { records } = e
46
+    getOrder({ pageNum: currentPage, mine: true }).then((e) => {
47
+      const records = currentPage === 1 ? e.records || [] : ourderList.concat(e.records || [])
48
+      console.log("🚀 ~ file: Orders.jsx ~ line 41 ~ getOrder ~ records", records)
49
+      if (e.records.length == 0 && currentPage != 1) {
50
+        setIsMore(true)
51
+        return
52
+      }
53
+      // setJobList(lst)
36 54
       setOrderList(records)
55
+
56
+
57
+
37 58
     })
38
-  }, [])
59
+  }, [currentPage])
39 60
   console.log(ourderList, 'ourderList');
40 61
 
41 62
   const orderStates = (item) => {
@@ -70,11 +91,16 @@ export default withLayout((props) => {
70 91
         title: '已完成',
71 92
         styleColor: '#FF703B'
72 93
       }
73
-    } else if (item.payStatus === 1 && item.workStatus === 0 && item.isRefund === 1) {
94
+    } else if (item.payStatus === -1 && item.workStatus === 0 && item.isRefund === 1) {
74 95
       return {
75 96
         title: '已退单',
76 97
         styleColor: '#FF703B'
77 98
       }
99
+    } else if (item.payStatus === 3) {
100
+      return {
101
+        title: '退单申请中',
102
+        styleColor: '#FF703B'
103
+      }
78 104
     } else {
79 105
       return {
80 106
         title: '异常',
@@ -89,7 +115,11 @@ export default withLayout((props) => {
89 115
 
90 116
 
91 117
   return (
92
-    <scroll-view scrollY style='height: 100%;' >
118
+    <scroll-view
119
+      scrollY
120
+      style='height: 100%;'
121
+      onScrollToLower={isMore ? '' : handleScrollToLower}
122
+    >
93 123
 
94 124
       <View className='content-header-box-orders'>
95 125
         <View className='content-header-box-orders-liftCentent'>

+ 20
- 0
src/services/order.js Просмотреть файл

@@ -38,3 +38,23 @@ export const orderDelete = (id, data) => request(`/order/${id}`, { data, method:
38 38
  */
39 39
 export const orderEvaluation = (data) => request(`/evaluation`, { data, method: 'POST' })
40 40
 
41
+
42
+
43
+
44
+/**
45
+ * --------------订单支付-----------------
46
+ * @param {*} data 
47
+ * @returns 
48
+ */
49
+export const orderPrepay = (id, data) => request(`/order/${id}/prepay`, { data, method: 'POST' })
50
+
51
+
52
+
53
+/**
54
+ * --------------订单退款-----------------
55
+ * @param {*} data 
56
+ * @returns 
57
+ */
58
+export const orderRefund = (id, data) => request(`/order/${id}/refund`, { data, method: 'PUT' })
59
+
60
+