[baozhangchao] 3 vuotta sitten
vanhempi
commit
f1f05dabff
4 muutettua tiedostoa jossa 126 lisäystä ja 29 poistoa
  1. 0
    1
      src/pages/index/index.jsx
  2. 1
    1
      src/pages/payPage/index.jsx
  3. 113
    27
      src/pages/setDogLicense/index.jsx
  4. 12
    0
      src/services/dogAPI.js

+ 0
- 1
src/pages/index/index.jsx Näytä tiedosto

@@ -28,7 +28,6 @@ const IndexPage = (props) => {
28 28
 
29 29
   useEffect(() => {
30 30
     getNoticeList({ pageSize: 5 }).then((res) => {
31
-      console.log('res', res);
32 31
       setNoticeList(res.records)
33 32
     })
34 33
 

+ 1
- 1
src/pages/payPage/index.jsx Näytä tiedosto

@@ -32,7 +32,7 @@ export default (props) => {
32 32
         }).then(() => {
33 33
           setTimeout(() => {
34 34
             Taro.reLaunch({
35
-              url: `/pages/index/index?tab=2`
35
+              // url: `/pages/index/index?tab=2`
36 36
             })
37 37
           }, 400)
38 38
         })

+ 113
- 27
src/pages/setDogLicense/index.jsx Näytä tiedosto

@@ -1,6 +1,6 @@
1 1
 import { View, Button, Text, RadioGroup, Picker, Image, Input, Radio, Label, ScrollView, Slot } from '@tarojs/components'
2 2
 import Taro, { useDidShow, useRouter } from '@tarojs/taro';
3
-import { useState } from 'react';
3
+import { useEffect, useState } from 'react';
4 4
 import Form from '@/components/Form';
5 5
 import FormItem from '@/components/Form/FormItem';
6 6
 import AuthProfile from '@/components/Authorize/AuthProfile';
@@ -9,26 +9,47 @@ import { handleFile } from '@/utils/request';
9 9
 import { useModel } from '@/store';
10 10
 
11 11
 import './style.less'
12
+import { getCardLicenseInfo } from '../../services/dogAPI';
12 13
 
13 14
 export default (props) => {
14 15
   const { dogs, person } = useModel('userData')
15 16
   const [formData, setFormData] = useState()
16 17
 
17
-  const [dogDate, setDogDate] = useState({ immunizationDate: null, petBirthday: '请选择生日', petSex: [], petType: [] })
18
+  const [dogDate, setDogDate] = useState({ immunizationDate: null, petBirthday: null, petSex: [], petType: [] })
18 19
   const [mainDog, setMainDog] = useState([])
20
+  const [dogStatus, setDogStatus] = useState(true)
21
+  const [renewalAndReissue, setRenewalAndReissue] = useState()
19 22
 
20 23
   const router = useRouter()
21 24
   const applyType = router.params.type || 'first'
25
+  useEffect(() => {
26
+    switch (applyType) {
27
+      // case 'first':
28
+      // break;
29
+      case 'renewal':
30
+        Taro.setNavigationBarTitle({
31
+          title: '证件续期'
32
+        })
33
+        break;
34
+      case 'reissue':
35
+        Taro.setNavigationBarTitle({
36
+          title: '证件补办'
37
+        })
38
+        break;
39
+
22 40
 
41
+      default:
42
+        break;
43
+    }
44
+
45
+  }, [applyType])
23 46
   useDidShow(() => {
24 47
     addDogList().then((res) => {
25 48
       setMainDog(res.records)
26 49
     })
27 50
   }, [])
28 51
 
29
-  const getMainDogChange = (value) => {
30
-    console.log("🚀 ~ file: index.jsx ~ line 34 ~ getMainDogChange ~ value", value)
31
-    const { petId } = value.detail.data
52
+  const getDogInfoFunction = (petId) => {
32 53
 
33 54
     getDogInfo(petId).then((e) => {
34 55
       setFormData(e)
@@ -40,6 +61,34 @@ export default (props) => {
40 61
 
41 62
     })
42 63
   }
64
+  const getMainDogChange = (value) => {
65
+    console.log("🚀 ~ file: index.jsx ~ line 34 ~ getMainDogChange ~ value", value)
66
+    const { petId } = value.detail.data
67
+    if (applyType == 'renewal' || (applyType == 'reissue')) {
68
+      setDogStatus(false)
69
+      getDogInfoFunction(petId)
70
+      getCardLicenseInfo(petId).then((res) => {
71
+        console.log('狗子证件有效期', res);
72
+      })
73
+    }
74
+    if (applyType == 'first') {
75
+      getCardLicenseInfo(petId).then((res) => {
76
+        if (!res) {
77
+          setDogStatus(false)
78
+          getDogInfoFunction(petId)
79
+        } else {
80
+          setDogStatus(true)
81
+          Taro.showToast({
82
+            title: '当前狗狗已有证件!',
83
+            icon: 'error',
84
+            duration: 2000,
85
+          })
86
+
87
+        }
88
+      })
89
+    }
90
+
91
+  }
43 92
 
44 93
   const onDateChange = (type, value) => {
45 94
     console.log('dogDate', dogDate);
@@ -78,28 +127,54 @@ export default (props) => {
78 127
     addlication({ ...value, applyType }).then((res) => {
79 128
       console.log('dogInfo xinwe', res);
80 129
       Taro.showToast({
81
-        title: '保存成功',
130
+        title: '申请成功,等待审核',
82 131
         icon: 'none',
83 132
         duration: 1000
84 133
       })
85
-      Taro.reLaunch({
86
-        url: `/pages/payPage/index?id=${res.applyId}`
87
-      })
134
+      if (applyType == 'renewal') {
135
+        Taro.navigateBack({
136
+          delta: 1
137
+        })
138
+        return;
139
+      } else {
140
+        Taro.reLaunch({
141
+          url: `/pages/payPage/index?id=${res.applyId}`
142
+        })
143
+      }
144
+
88 145
     })
89 146
   }
90 147
 
148
+  const rules = {
149
+    petName: [{ required: true, message: '请填写狗狗名称' }],
150
+    petSex: [{ type: 'number', required: true, message: '请填写狗狗性别' }],
151
+    petBirthday: [{ required: true, message: '请选择狗狗生日' }],
152
+    petColor: [{ required: true, message: '请选择狗狗毛色' }],
153
+    petType: [{ required: true, message: '请选择犬种类别' }],
154
+    dogImg1: [{ required: true, message: '请上传狗狗照片' }],
155
+    immunizationDate: [{ required: true, message: '请上输入最近免疫时间' }],
156
+    immunizationCode: [{ required: true, message: '请输入免疫证号' }],
157
+    immunizationImg: [{ required: true, message: '请上传免疫图片' }],
158
+    address: [{ required: true, message: '请输入详细地址' }],
91 159
 
160
+  }
92 161
 
93 162
   return (
94 163
     <ScrollView scrollY style={{ height: '100vh' }} >
95 164
       <AuthProfile />
96 165
       <View class='page' >
97
-        <Form onSubmit={formSubmit} >
166
+        <Form onSubmit={formSubmit} rules={rules} >
98 167
           <mp-form  >
99 168
             <mp-cells >
100 169
               <FormItem title='犬主姓名' required>
101 170
                 <View >{person?.nickName}</View>
102 171
               </FormItem>
172
+              <FormItem title='证件号' required>
173
+                <View >{person?.nickName}</View>
174
+              </FormItem>
175
+              <FormItem title='有效期' required>
176
+                <View >{person?.nickName}</View>
177
+              </FormItem>
103 178
               <FormItem title='狗狗名称' required>
104 179
                 <s-picker name='petName' rangeKey='name' rangeValue='value' range={mainDog} value={formData?.name} onChange={getMainDogChange} />
105 180
               </FormItem>
@@ -110,10 +185,16 @@ export default (props) => {
110 185
                 <s-picker name='petType' rangeKey='name' rangeValue='name' range={dogDate.petType} value={formData?.petType} />
111 186
               </FormItem>
112 187
               <FormItem title='生日' required>
113
-                <Picker name='petBirthday' mode='date' onChange={(e) => { onDateChange('petBirthday', e.detail.value) }}>
114
-                  <View className='picker' style={!formData ? { "color": '#858585' } : {}}>
188
+                <Picker name='petBirthday' mode='date' value={dogDate.petBirthday} onChange={(e) => { onDateChange('petBirthday', e.detail.value) }}>
189
+                  {dogDate?.petBirthday ? (
190
+                    <View className='picker' >
191
+                      {dogDate.petBirthday}
192
+                    </View>
193
+                  ) : <View style={{ color: '#858585' }}>请选择...</View>
194
+                  }
195
+                  {/* <View className='picker' style={!formData ? { "color": '#858585' } : {}}>
115 196
                     {dogDate.petBirthday}
116
-                  </View>
197
+                  </View> */}
117 198
                 </Picker>
118 199
               </FormItem>
119 200
               <FormItem title='毛色' required>
@@ -142,24 +223,29 @@ export default (props) => {
142 223
               <FormItem title='详细地址' required>
143 224
                 <Input name='address' placeholder='请输入详细地址' />
144 225
               </FormItem>
145
-              <FormItem title='申领方式' extClass=''>
146
-                <View className='radio-list'>
147
-                  <RadioGroup name='applyMethod'>
148
-                    {modeList.map((item, i) => {
149
-                      return (
150
-                        <Label className='radio-list__label' for={i} key={i}>
151
-                          <Radio color='#FCD905' className='radio-list__radio' value={item.value} >{item.text}</Radio>
152
-                        </Label>
153
-                      )
154
-                    })}
155
-                  </RadioGroup>
156
-                </View>
157
-              </FormItem>
226
+              {
227
+                applyType == 'renewal' ? <></>
228
+                  :
229
+                  <FormItem title='申领方式' extClass=''>
230
+                    <View className='radio-list'>
231
+                      <RadioGroup name='applyMethod'>
232
+                        {modeList.map((item, i) => {
233
+                          return (
234
+                            <Label className='radio-list__label' for={i} key={i}>
235
+                              <Radio color='#FCD905' className='radio-list__radio' value={item.value} >{item.text}</Radio>
236
+                            </Label>
237
+                          )
238
+                        })}
239
+                      </RadioGroup>
240
+                    </View>
241
+                  </FormItem>
242
+              }
243
+
158 244
 
159 245
             </mp-cells>
160 246
           </mp-form>
161 247
           <View slot='button' style={{ margin: '4em 0 2em 0' }}>
162
-            <Button style={{ backgroundColor: '#fbd804', borderRadius: '40px', color: '#000', border: '0px' }} class='weui-btn' type='primary' loading={false} formType='submit'>确定</Button>
248
+            <Button disabled={dogStatus} style={{ backgroundColor: !dogStatus ? '#fbd804' : '#858585', borderRadius: '40px', color: '#000', border: '0px' }} class='weui-btn' type='primary' loading={false} formType='submit'>确定</Button>
163 249
           </View>
164 250
         </Form>
165 251
       </View>

+ 12
- 0
src/services/dogAPI.js Näytä tiedosto

@@ -146,3 +146,15 @@ export const getOrder = (id, data) => request(`/order?applyId=${id}`, { data, me
146 146
 
147 147
 
148 148
 
149
+
150
+/**
151
+* 获取狗子证件详情 (挂失补办/续期)
152
+* @param {*} data
153
+* @returns
154
+*/
155
+export const getCardLicenseInfo = (id, data) => request(`/pet/${id}/card`, { data, method: 'GET' })
156
+
157
+
158
+
159
+
160
+