[baozhangchao] 3 yıl önce
ebeveyn
işleme
b0efbc5086
1 değiştirilmiş dosya ile 47 ekleme ve 21 silme
  1. 47
    21
      src/pages/OrderConfirmation/index.jsx

+ 47
- 21
src/pages/OrderConfirmation/index.jsx Dosyayı Görüntüle

@@ -1,5 +1,5 @@
1 1
 import { View, Image, Form, Input, Picker } from "@tarojs/components"
2
-import Taro from "@tarojs/taro"
2
+import Taro, { useDidShow } from "@tarojs/taro"
3 3
 import { useEffect, useState } from "react"
4 4
 import withLayout from '@/layouts'
5 5
 import { useModel } from "@/store"
@@ -27,32 +27,55 @@ export default withLayout((props) => {
27 27
 
28 28
   const $instance = Taro.getCurrentInstance()
29 29
   const { id } = $instance.router.params
30
-  const { sserLocation, setUserLocation } = useModel('userData')
30
+  const { sserLocation, userOrderAddress } = useModel('userData')
31 31
 
32 32
   const [timeSel, setTimeSel] = useState('')
33 33
   const [carsInfo, setCarsInfo] = useState({})
34
+  const [userAddres, setUserAddres] = useState('')//在store拿到位置
34 35
 
35 36
 
37
+
38
+  useDidShow(() => {
39
+
40
+    if (userOrderAddress) {
41
+      setUserAddres(userOrderAddress)
42
+
43
+    }
44
+  }, [userOrderAddress])
45
+
36 46
   const formSubmit = (e) => {
37
-    console.log('表单输入', e?.detail?.value);
38 47
     const { amount, appontmentDate, address } = e?.detail?.value
39
-    // Taro.navigateTo({ url: `/pages/OrderInfo/index?goOrder=${id}` })
40
-    generateOrder({
41
-      charges: carsInfo?.price * amount,
42
-      price: carsInfo?.price,
43
-      amount: amount || '',
44
-      machineryId: carsInfo?.machineryId,
45
-      machineryName: carsInfo?.name,
46
-      machineryType: carsInfo?.typeId,
47
-      typeName: carsInfo?.typeName,
48
-      address: address || '',
49
-      orgId: carsInfo?.orgId,
50
-      // appontmentDate: appontmentDate || '',
51
-      appontmentDate: '2022-03-25 08:00:00',
52
-    }).then((es) => {
53
-      Taro.redirectTo({ url: `/pages/OrderInfo/index?orderId=${es.orderId}` })
54 48
 
55
-    })
49
+    if (amount && appontmentDate && address) {
50
+      generateOrder({
51
+        charges: carsInfo?.price * amount,
52
+        price: carsInfo?.price,
53
+        amount: amount || '',
54
+        machineryId: carsInfo?.machineryId,
55
+        machineryName: carsInfo?.name,
56
+        machineryType: carsInfo?.typeId,
57
+        typeName: carsInfo?.typeName,
58
+        address: address || '',
59
+        orgId: carsInfo?.orgId,
60
+        appointmentDate: `${appontmentDate} 08:00:00` || '',
61
+        // appointmentDate: '2022-03-25 08:00:00',
62
+      }).then((es) => {
63
+        Taro.showToast({
64
+          title: '农机预约成功',
65
+          icon: 'success',
66
+          duration: 2000
67
+        }).then(() => {
68
+          Taro.redirectTo({ url: `/pages/OrderInfo/index?orderId=${es.orderId}` })
69
+        })
70
+      })
71
+    } else {
72
+      Taro.showToast({
73
+        title: '请填写完整信息',
74
+        icon: 'error',
75
+        duration: 2000
76
+      })
77
+    }
78
+    // Taro.navigateTo({ url: `/pages/OrderInfo/index?goOrder=${id}` })
56 79
   }
57 80
   useEffect(() => {
58 81
     if (id) {
@@ -74,6 +97,9 @@ export default withLayout((props) => {
74 97
   }
75 98
 
76 99
 
100
+  const goAddress = () => {
101
+    Taro.navigateTo({ url: `/pages/MyAddressList/index?type=orderAddress` })
102
+  }
77 103
 
78 104
 
79 105
   return (
@@ -104,9 +130,9 @@ export default withLayout((props) => {
104 130
           </View>
105 131
           <View className='example-body-WorkingLocation'>
106 132
             <View>作业位置:</View>
107
-            <View className='example-body-WorkingLocation-info' onClick={() => { console.log('111111',); }}>
133
+            <View className='example-body-WorkingLocation-info' onClick={goAddress}>
108 134
               <Image src={addresss} />
109
-              <Input name='address' disabled className='aTextareaCentent' value='1111111' placeholder='请输入地址信息' />
135
+              <Input name='address' disabled className='aTextareaCentent' value={userAddres} placeholder={userAddres == '' ? '请输入地址信息' : ''} />
110 136
 
111 137
             </View>
112 138
           </View>