Your Name 3 лет назад
Родитель
Сommit
9b71da79c5

+ 2
- 2
config/dev.js Просмотреть файл

@@ -3,8 +3,8 @@ module.exports = {
3 3
     NODE_ENV: '"development"'
4 4
   },
5 5
   defineConstants: {
6
-    HOST: '"https://xlk.njyz.tech"',
7
-    // HOST: '"http://127.0.0.1:8081"',
6
+    // HOST: '"https://xlk.njyz.tech"',
7
+    HOST: '"http://127.0.0.1:8081"',
8 8
     WSS_HOST: '"wss://xlk.njyz.tech"',
9 9
     OSS_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
10 10
     OSS_FAST_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',

+ 105
- 0
src/components/AreaPickerView/index.jsx Просмотреть файл

@@ -0,0 +1,105 @@
1
+import { useState, useEffect } from 'react'
2
+import { PickerView, PickerViewColumn } from '@tarojs/components'
3
+import { fetch } from '@/utils/request'
4
+import { API_AREA_LIST } from '@/constants/api'
5
+import './style.scss'
6
+
7
+export default (props) => {
8
+
9
+  const { show = false, Change = () => {}, Cancel = () => {} } = props
10
+  const [Value, setValue] = useState([0, 0, 0])
11
+  const [StateList, setStateList] = useState([])
12
+  const [CurrentState, setCurrentState] = useState({})
13
+  const [CityList, setCityList] = useState([])
14
+  const [CurrentCity, setCurrentCity] = useState({})
15
+  const [IntentAreaList, setIntentAreaList] = useState([])
16
+  const [CurrentIntentArea, setCurrentIntentArea] = useState({})
17
+
18
+  useEffect(() => {
19
+    GetAreaList()
20
+  }, [])
21
+
22
+  useEffect(() => {
23
+    if (StateList.length) {
24
+      if (StateList[Value[0]].id !== CurrentState.id) { // 省份更新
25
+        setCurrentState(StateList[Value[0]])
26
+      } else if (CityList[Value[1]].id !== CurrentCity.id) { // 城市更新
27
+        setCurrentCity(CityList[Value[1]])
28
+      } else if (IntentAreaList[Value[2]].id !== CurrentIntentArea.id) { // 区县更新
29
+        setCurrentIntentArea(IntentAreaList[Value[2]])
30
+      }
31
+    }
32
+  }, [Value])
33
+
34
+  useEffect(() => {
35
+    if (CurrentState.id) {
36
+      GetAreaList(CurrentState.id, 2)
37
+    }
38
+  }, [CurrentState])
39
+
40
+  useEffect(() => {
41
+    if (CurrentCity.id) {
42
+      GetAreaList(CurrentCity.id, 3)
43
+    }
44
+  }, [CurrentCity])
45
+
46
+  const Sure = () => {
47
+    Change([CurrentState, CurrentCity, CurrentIntentArea])
48
+  }
49
+
50
+  const PickerChange = (e) => {
51
+    setValue(e.detail.value)
52
+  }
53
+
54
+  const GetAreaList = (parentCity = 100000, levelType = 1) => {
55
+    fetch({ url: API_AREA_LIST, method: 'get', payload: { parentCity, levelType } }).then((res) => {
56
+      if (levelType === 1) { // 省份
57
+        setStateList(res || [])
58
+        setValue([0, 0, 0])
59
+      } else if (levelType === 2) { // 城市
60
+        setCityList(res || [])
61
+        setValue([Value[0], 0, 0])
62
+      } else { // 区县
63
+        setIntentAreaList(res || [])
64
+        setValue([Value[0], Value[1], 0])
65
+      }
66
+    })
67
+  }
68
+
69
+  return (
70
+    <view className='components AreaPickerView' style={{ display: show ? 'block' : 'none' }}>
71
+      <view className='flex-v'>
72
+        <view className='flex-h'>
73
+          <text onClick={Cancel}>取消</text>
74
+          <view className='flex-item'></view>
75
+          <text onClick={Sure}>确认</text>
76
+        </view>
77
+        <view className='flex-item'>
78
+          <PickerView value={Value} indicator-style='height: 50px;' style='width: 100%; height: 300px;' onChange={PickerChange}>
79
+            <PickerViewColumn>
80
+              {
81
+                StateList.map((item, index) => (
82
+                  <view key={index} style='line-height: 50px; text-align: center;'>{item.name}</view>
83
+                ))
84
+              }
85
+            </PickerViewColumn>
86
+            <PickerViewColumn>
87
+              {
88
+                CityList.map((item, index) => (
89
+                  <view key={index} style='line-height: 50px; text-align: center;'>{item.name}</view>
90
+                ))
91
+              }
92
+            </PickerViewColumn>
93
+            <PickerViewColumn>
94
+              {
95
+                IntentAreaList.map((item, index) => (
96
+                  <view key={index} style='line-height: 50px; text-align: center;'>{item.name}</view>
97
+                ))
98
+              }
99
+            </PickerViewColumn>
100
+          </PickerView>
101
+        </view>
102
+      </view>
103
+    </view>
104
+  )
105
+}

+ 30
- 0
src/components/AreaPickerView/style.scss Просмотреть файл

@@ -0,0 +1,30 @@
1
+.components.AreaPickerView {
2
+  width: 100%;
3
+  position: fixed;
4
+  left: 0;
5
+  top: 0;
6
+  bottom: 0;
7
+  z-index: 100;
8
+  background: rgba(0, 0, 0, 0.6);
9
+  > view {
10
+    width: 100%;
11
+    position: absolute;
12
+    left: 0;
13
+    bottom: 0;
14
+    height: 600px;
15
+    background: #fff;
16
+    >.flex-h {
17
+      align-items: center;
18
+      padding: 0 30px;
19
+      border-bottom: 2px solid rgba(0, 0, 0, 0.08);
20
+      >text {
21
+        font-size: 28px;
22
+        line-height: 80px;
23
+        color: #193C83;
24
+        &:first-child {
25
+          color: #ccc;
26
+        }
27
+      }
28
+    }
29
+  }
30
+}

+ 1
- 0
src/constants/api.js Просмотреть файл

@@ -33,6 +33,7 @@ export const API_PRELOAD = resolvePath('preload')
33 33
 export const API_QRCODE = resolvePath('qrcode')
34 34
 export const API_BANNER_LIST = resolvePath('extendContent')
35 35
 export const API_QUERY_CODE_SCENE = resolvePath('qrcode/scene')
36
+export const API_AREA_LIST = resolvePath('city/cascade')
36 37
 
37 38
 // user
38 39
 export const API_USER_LOGIN = resolvePath('login')

+ 144
- 73
src/pages/index/activityDetail/index.jsx Просмотреть файл

@@ -1,9 +1,17 @@
1 1
 import { useState, useEffect } from "react";
2 2
 import Taro from "@tarojs/taro";
3 3
 import withLayout from "@/layout";
4
-import { ScrollView, Image, RichText, Button } from "@tarojs/components";
4
+import {
5
+  ScrollView,
6
+  Image,
7
+  RichText,
8
+  View,
9
+  Text,
10
+  Input,
11
+  Picker,
12
+} from "@tarojs/components";
5 13
 import Disclaimer from "@/components/Disclaimer";
6
-
14
+import { useSelector } from "react-redux";
7 15
 import {
8 16
   // addActivityShareNum,
9 17
   signupActivity,
@@ -16,12 +24,21 @@ import useShare from "@/utils/hooks/useShare";
16 24
 import useFavor from "@/utils/hooks/useFavor";
17 25
 import useStatus from './useStatus'
18 26
 
27
+import { getDownloadURL, times, transferImage } from "@/utils/tools";
19 28
 import "./index.scss";
20 29
 
21 30
 export default withLayout((props) => {
22 31
   const { router, shareContent, trackData, person, page } = props;
23 32
   const { id } = router.params;
33
+
34
+  const user = useSelector((state) => state.user);
35
+
24 36
   const [detail, setDetail] = useState();
37
+  const [canChoose, setCanChoose] = useState("none");
38
+  const [inputName, setInputName] = useState("");
39
+  const [selectorChecked, setSelectorChecked] = useState("1");
40
+  const [selector, setSelector] = useState("");
41
+
25 42
   const buildingId = detail?.buildingId;
26 43
 
27 44
   const [btnText, btnDisabled] = useStatus(detail)
@@ -30,9 +47,14 @@ export default withLayout((props) => {
30 47
     Taro.showLoading();
31 48
 
32 49
     queryActivityDetail(params).then((res) => {
33
-      console.log(res, "queryActivityDetail");
34
-      setDetail(res);
50
+      // const maxperson =
51
+      //   res.maxEnlistByPerson < 100 ? res.maxEnlistByPerson : 100;
52
+
53
+      const maxperson = 10
35 54
 
55
+      setSelector(times(maxperson).map((_, i) => `${i + 1}`));
56
+
57
+      setDetail(res);
36 58
       Taro.hideLoading();
37 59
     });
38 60
   };
@@ -69,38 +91,58 @@ export default withLayout((props) => {
69 91
   }, [id]);
70 92
 
71 93
   const handleSignup = () => {
72
-    const {
73
-      detail: { buildingId, dynamicId, isSign },
74
-    } = this.state;
75
-    const {
76
-      userInfo: {
77
-        person: { phone, name, nickname },
78
-      },
79
-    } = this.props;
94
+    setCanChoose("block");
95
+  };
80 96
 
81
-    if (isSign) {
97
+  const comfire = (e) => {
98
+    const { dynamicId } =detail;
99
+    // console.log(user, "user");
100
+    const { userInfo: { person: { phone,  tel } } } = user
101
+    if (inputName == "") {
82 102
       Taro.showToast({
103
+        title: "请输入姓名",
83 104
         icon: "none",
84
-        title: "你已报名成功",
85 105
       });
86 106
       return;
87 107
     }
88 108
 
89
-    this.setState({
90
-      canChoose: "block",
109
+    const payload = {
110
+      buildingId,
111
+      dynamicId,
112
+      name: inputName,
113
+      phone: phone ? phone : tel,
114
+      attendNum: selectorChecked,
115
+    };
116
+
117
+    signupActivity(payload).then((res) => {
118
+      Taro.showToast({
119
+        title: "报名成功",
120
+      });
121
+      setCanChoose('none')
122
+      setTimeout(() => {
123
+        getDetail(id);
124
+      }, 500);
91 125
     });
92 126
   };
93 127
 
128
+  function hideModal() {
129
+    setCanChoose("none");
130
+  }
131
+
132
+  const onInputText = (e) => {
133
+    setInputName(e.detail.value);
134
+  };
135
+
94 136
   const dymic = () => (
95
-    <view className="Info">
137
+    <view className='Info'>
96 138
       <view>
97
-        <view className="Title flex-h">
98
-          <view className="flex-item">
139
+        <view className='Title flex-h'>
140
+          <view className='flex-item'>
99 141
             <text>{detail.halfTitle}</text>
100 142
           </view>
101
-          <text className="Tips">{detail.enlisted || 0}人已报名</text>
143
+          <text className='Tips'>{detail.enlisted || 0}人已报名</text>
102 144
         </view>
103
-        <text className="Time">
145
+        <text className='Time'>
104 146
           报名截止时间:
105 147
           {getDateFormat(
106 148
             new Date(detail.enlistEnd).valueOf(),
@@ -108,16 +150,16 @@ export default withLayout((props) => {
108 150
             "yyyy/M/d"
109 151
           )}
110 152
         </text>
111
-        <text className="Name">{detail.title}</text>
112
-        <view className="flex-h Address">
153
+        <text className='Name'>{detail.title}</text>
154
+        <view className='flex-h Address'>
113 155
           <text>地址:</text>
114
-          <view className="flex-item">
156
+          <view className='flex-item'>
115 157
             <text>{detail.address}</text>
116 158
           </view>
117 159
         </view>
118
-        <view className="flex-h Date">
160
+        <view className='flex-h Date'>
119 161
           <text>时间:</text>
120
-          <view className="flex-item">
162
+          <view className='flex-item'>
121 163
             <text>
122 164
               {getDateFormat(
123 165
                 new Date(detail.startDate).valueOf(),
@@ -133,8 +175,8 @@ export default withLayout((props) => {
133 175
             </text>
134 176
           </view>
135 177
         </view>
136
-        <view className="Btn">
137
-          <button open-type="share">
178
+        <view className='Btn'>
179
+          <button open-type='share'>
138 180
             <text>分享好友</text>
139 181
           </button>
140 182
         </view>
@@ -143,23 +185,23 @@ export default withLayout((props) => {
143 185
   );
144 186
 
145 187
   const house = () => (
146
-    <view className="houseInfo">
188
+    <view className='houseInfo'>
147 189
       {/* <view> */}
148
-      <view className="flex-h">
149
-        <view className="left">
150
-          <view className="Title">
151
-            <view className="flex-item">
190
+      <view className='flex-h'>
191
+        <view className='left'>
192
+          <view className='Title'>
193
+            <view className='flex-item'>
152 194
               <text>{detail.title}</text>
153 195
             </view>
154 196
           </view>
155
-          <view className="flex-h Address">
156
-            <text className="iconfont icon-dingwei"></text>
157
-            <view className="flex-item">
197
+          <view className='flex-h Address'>
198
+            <text className='iconfont icon-dingwei'></text>
199
+            <view className='flex-item'>
158 200
               <text>{detail.address}</text>
159 201
             </view>
160
-            <text className="price">价格待定</text>
202
+            <text className='price'>价格待定</text>
161 203
           </view>
162
-          <text className="flex-h Time">
204
+          <text className='flex-h Time'>
163 205
             时间:
164 206
             {getDateFormat(
165 207
               new Date(detail.startDate).valueOf(),
@@ -174,50 +216,50 @@ export default withLayout((props) => {
174 216
             )}
175 217
           </text>
176 218
         </view>
177
-        <view className="right">
219
+        <view className='right'>
178 220
           <view>
179
-            <button  open-type="share">
180
-              <text className="iconfont icon-fenxiang"></text>
221
+            <button open-type='share'>
222
+              <text className='iconfont icon-fenxiang'></text>
181 223
               <text>分享</text>
182 224
             </button>
183 225
             {/* <text className="iconfont icon-dingwei"></text>
184 226
             <text>分享</text> */}
185 227
           </view>
186 228
           <view>
187
-            <text className="iconfont icon-dingwei"></text>
229
+            <text className='iconfont icon-dingwei'></text>
188 230
             <text>海报</text>
189 231
           </view>
190 232
         </view>
191 233
       </view>
192 234
 
193
-      <view className="lastdate">
194
-        <text className="text">距离结束还有</text>
195
-        <text className="text day">7</text>
196
-        <text className="text">天</text>
197
-        <text className="text time">2</text>
198
-        <text className="text">时</text>
199
-        <text className="text time">4</text>
200
-        <text className="text">分</text>
201
-        <text className="text time">5</text>
202
-        <text className="text">秒</text>
235
+      <view className='lastdate'>
236
+        <text className='text'>距离结束还有</text>
237
+        <text className='text day'>7</text>
238
+        <text className='text'>天</text>
239
+        <text className='text time'>2</text>
240
+        <text className='text'>时</text>
241
+        <text className='text time'>4</text>
242
+        <text className='text'>分</text>
243
+        <text className='text time'>5</text>
244
+        <text className='text'>秒</text>
203 245
         {/* <view>距离结束还有</view> */}
204 246
       </view>
205 247
 
206
-      <view className="flex-h join">
207
-        <view className="Collect" onClick={handleFavor}>
248
+      <view className='flex-h join'>
249
+        <view className='Collect' onClick={handleFavor}>
208 250
           <text
209
-            className="iconfont icon-shoucang"
251
+            className='iconfont icon-shoucang'
210 252
             style={isSaved ? { color: "red" } : undefined}
211 253
           ></text>
212 254
           <text>{isSaved ? "已收藏" : "收藏"}</text>
213 255
         </view>
214
-        <view className="enlisted">
256
+        <view className='enlisted'>
215 257
           <view>
216
-            <text className="iconfont icon-shoucang"></text>
258
+            <text className='iconfont icon-shoucang'></text>
217 259
             <text>{detail.enlisted || 0}人已报名</text>
218 260
           </view>
219 261
         </view>
220
-        <button className="btn" disabled={btnDisabled} onClick={handleSignup}>
262
+        <button className='btn' disabled={btnDisabled} onClick={handleSignup}>
221 263
           <text>{btnText}</text>
222 264
         </button>
223 265
       </view>
@@ -228,23 +270,23 @@ export default withLayout((props) => {
228 270
   return (
229 271
     <>
230 272
       {detail && (
231
-        <view className="Page activityDetail flex-v">
232
-          <view className="flex-item">
273
+        <view className='Page activityDetail flex-v'>
274
+          <view className='flex-item'>
233 275
             <view>
234 276
               <ScrollView scroll-y>
235
-                <view className="PageContent">
236
-                  <view className="Top">
277
+                <view className='PageContent'>
278
+                  <view className='Top'>
237 279
                     <Image
238
-                      mode="aspectFill"
280
+                      mode='aspectFill'
239 281
                       src={getImgURL(detail.bannerListImg)}
240
-                      className="centerLabel"
282
+                      className='centerLabel'
241 283
                     ></Image>
242 284
                   </view>
243 285
 
244 286
                   {detail.type == "dymic" && dymic()}
245 287
                   {detail.type == "house" && house()}
246
-                  <view className="ActivityIntro">
247
-                    <view className="Title">
288
+                  <view className='ActivityIntro'>
289
+                    <view className='Title'>
248 290
                       <text>活动介绍</text>
249 291
                     </view>
250 292
                     <RichText nodes={detail.desc} />
@@ -256,27 +298,56 @@ export default withLayout((props) => {
256 298
             </view>
257 299
           </view>
258 300
           {detail.type == "dymic" && (
259
-            <view className="PageBottom flex-h">
260
-              <button className="Share" open-type="share">
261
-                <text className="iconfont icon-fenxiang"></text>
301
+            <view className='PageBottom flex-h'>
302
+              <button className='Share' open-type='share'>
303
+                <text className='iconfont icon-fenxiang'></text>
262 304
                 <text>分享</text>
263 305
               </button>
264
-              <view className="Collect" onClick={handleFavor}>
306
+              <view className='Collect' onClick={handleFavor}>
265 307
                 <text
266
-                  className="iconfont icon-shoucang"
308
+                  className='iconfont icon-shoucang'
267 309
                   style={isSaved ? { color: "red" } : undefined}
268 310
                 ></text>
269 311
                 <text>{isSaved ? "已收藏" : "收藏"}</text>
270 312
               </view>
271
-              <view className="flex-item"></view>
313
+              <view className='flex-item'></view>
272 314
 
273
-              <button disabled={btnDisabled} className="Post" onClick={handleSignup}>
315
+              <button disabled={btnDisabled} className='Post' onClick={handleSignup}>
274 316
                 {btnText}
275 317
               </button>
276 318
             </view>
277 319
           )}
278 320
         </view>
279 321
       )}
322
+
323
+      <View className='page-body' style={{ display: canChoose }}>
324
+        <View className='mask' onClick={() => hideModal()}></View>
325
+        <View className='page-section'>
326
+          <Text className='page-section__title'>报名信息</Text>
327
+          <View className='page-content'>
328
+            <Input
329
+              className='inputName'
330
+              onInput={onInputText}
331
+              type='text'
332
+              placeholder='请输入姓名'
333
+            />
334
+            <Picker
335
+              mode='selector'
336
+              range={selector}
337
+              onChange={(e) => setSelectorChecked(selector[e.detail.value])}
338
+            >
339
+              <View className='picker'>
340
+                <Text>参加人数</Text>
341
+                <Text className='content'>{selectorChecked}</Text>
342
+                <Text>人</Text>
343
+              </View>
344
+            </Picker>
345
+            <View onClick={comfire} className='comfire'>
346
+              确认
347
+            </View>
348
+          </View>
349
+        </View>
350
+      </View>
280 351
     </>
281 352
   );
282 353
 });

+ 85
- 0
src/pages/index/activityDetail/index.scss Просмотреть файл

@@ -223,3 +223,88 @@
223 223
     }
224 224
   }
225 225
 }
226
+
227
+.page-body {
228
+  z-index: 99;
229
+  position: fixed;
230
+  top: 0;
231
+  left: 0;
232
+  width: 100vw;
233
+  height: 100vh;
234
+
235
+  .mask {
236
+    background: rgba(0, 0, 0, 0.7);
237
+    width: 100%;
238
+    height: 100%;
239
+    left: 0;
240
+    top: 0;
241
+  }
242
+
243
+  .page-section {
244
+    position: absolute;
245
+    width: 600px;
246
+    top: 24%;
247
+    left: 75px;
248
+    border-radius: 10px;
249
+    background: white;
250
+    height: 500px;
251
+
252
+    &__title {
253
+      font-size: 36px;
254
+      text-align: center;
255
+      width: 100%;
256
+      line-height: 120px;
257
+      display: block;
258
+      color: black;
259
+    }
260
+
261
+    .page-content {
262
+      width: 490px;
263
+      margin: 0 auto;
264
+
265
+      .inputName {
266
+        width: 100%;
267
+        height: 80px;
268
+        line-height: 80px;
269
+        border: 1px solid #CCCCCC;
270
+        border-radius: 10px;
271
+        text-align: center;
272
+      }
273
+
274
+      .picker {
275
+        width: 100%;
276
+        margin-top: 30px;
277
+        display: flex;
278
+        justify-content: center;
279
+        border: 1px solid #CCCCCC;
280
+
281
+        Text {
282
+          display: block;
283
+          color: black;
284
+          height: 80px;
285
+          line-height: 80px;
286
+          width: auto;
287
+        }
288
+
289
+        .content {
290
+          text-align: center;
291
+          margin-right: 20px;
292
+          margin-left: 20px;
293
+        }
294
+      }
295
+
296
+      .comfire {
297
+        width: 490px;
298
+        height: 96px;
299
+        background: #BB9C79;;
300
+        border-radius: 7px;
301
+        line-height: 96px;
302
+        color: white;
303
+        text-align: center;
304
+        margin-top: 60px;
305
+        font-size: 36px;
306
+      }
307
+    }
308
+  }
309
+
310
+}

+ 18
- 2
src/pages/index/activityDetail/useStatus.js Просмотреть файл

@@ -5,7 +5,7 @@ const ACT_ENLIST_FULL = 2
5 5
 const ACT_SIGNED = 1
6 6
 
7 7
 export default function useStatus(info) {
8
-  const { dynamicId, isSign, activityStatus, isEnlist } = info || {}
8
+  const { dynamicId, isSign, activityStatus, isEnlist, enlistStart, enlistEnd } = info || {}
9 9
 
10 10
   const [disabled, setDisabled] = useState(false)
11 11
   const [btnText, setBtnText] = useState('立即报名')
@@ -15,7 +15,7 @@ export default function useStatus(info) {
15 15
 
16 16
     // 活动结束
17 17
     if (activityStatus === ACT_GAMEOVER) {
18
-      setBtnText('已结束')
18
+      setBtnText('活动已结束')
19 19
       setDisabled(true)
20 20
       return;
21 21
     }
@@ -34,6 +34,22 @@ export default function useStatus(info) {
34 34
       return;
35 35
     }
36 36
 
37
+    // 报名时间
38
+    const now = new Date()
39
+    const start = new Date(enlistStart)
40
+    const end = new Date(enlistEnd)
41
+    if (now < start) {
42
+      setBtnText('报名未开始')
43
+      setDisabled(true)
44
+      return;
45
+    }
46
+
47
+    if (now > end) {
48
+      setBtnText('报名已结束')
49
+      setDisabled(true)
50
+      return;
51
+    }
52
+
37 53
     setBtnText('立即报名')
38 54
     setDisabled(false)
39 55
   },[dynamicId])

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

@@ -44,7 +44,11 @@ export default function AddedValueService () {
44 44
       }
45 45
     })
46 46
     params.push({question: '创建人小程序人员', result: user?.userInfo?.person?.personId, key: 'personId' })
47
-    fetch({ url: API_HELP_FIND_HOUSE_SUBMIT, method: 'post', payload: params }).then((res) => {
47
+    let payload = {}
48
+    params.map((item) => {
49
+      payload[item.key] = item.result || item.resultId
50
+    })
51
+    fetch({ url: API_HELP_FIND_HOUSE_SUBMIT, method: 'post', payload: { ...payload, questionnaire: JSON.stringify(params), type: 4 } }).then((res) => {
48 52
       setResultList(res.taBuildingList || [])
49 53
       setShowPopup(true)
50 54
     })

+ 6
- 18
src/pages/index/helpToFindHouse/components/BuyHouse/index.jsx Просмотреть файл

@@ -1,20 +1,17 @@
1 1
 import { useState, useEffect } from 'react'
2 2
 import '@/assets/css/iconfont.css'
3
-import { Image, Slider, Textarea, Picker } from '@tarojs/components'
3
+import { Image, Slider, Textarea } from '@tarojs/components'
4 4
 import './index.scss'
5 5
 import questions from './formData'
6 6
 
7 7
 export default function BuyHouse (props) {
8
-  const { change = () => { }, toSubmit = () => { }, CityList = [] } = props
8
+  const { change = () => { }, toSubmit = () => { }, AreaInfo = {}, selectArea = () => {} } = props
9 9
 
10 10
   const [FormData, setFormData] = useState(questions)
11 11
 
12 12
   const [StepId, setStepId] = useState(1)
13 13
   const [StepRange, setStepRange] = useState([0, 4])
14 14
 
15
-  const [CityName, setCityName] = useState(null)
16
-  const [CityId, setCityId] = useState(null)
17
-
18 15
   useEffect(() => {
19 16
     if (StepId === 1) {
20 17
       setStepRange([0, 4])
@@ -59,7 +56,7 @@ export default function BuyHouse (props) {
59 56
     if (StepId < 4) {
60 57
       setStepId(StepId + 1)
61 58
     } else {
62
-      toSubmit(FormData.concat([{result: CityId, key: 'intentArea', question: '意向区域'}]))
59
+      toSubmit(FormData)
63 60
     }
64 61
   }
65 62
 
@@ -69,11 +66,6 @@ export default function BuyHouse (props) {
69 66
     }
70 67
   }
71 68
 
72
-  const PickerChange = (e) => {
73
-    setCityName(CityList[e.detail.value - 0].name)
74
-    setCityId(CityList[e.detail.value - 0].id)
75
-  }
76
-
77 69
   return (
78 70
     <view className='components BuyHouse'>
79 71
       {
@@ -114,17 +106,13 @@ export default function BuyHouse (props) {
114 106
                 {
115 107
                   item.type === 'select' &&
116 108
                   <view className='Area'>
117
-                    <view className='flex-h'>
109
+                    <view className='flex-h' onClick={selectArea}>
118 110
                       {
119 111
                         item.key === 'intentArea' &&
120 112
                         <text className='iconfont icon-dingwei'></text>
121 113
                       }
122
-                      {/* <text>不限</text> */}
123
-                      <view className='flex-item'>
124
-                        <Picker range-key='name' onChange={PickerChange} value={0} range={CityList}>
125
-                          <text>{CityName || '请选择'}</text>
126
-                        </Picker>
127
-                      </view>
114
+                      <text>{AreaInfo.name || '不限'}</text>
115
+                      <view className='flex-item'></view>
128 116
                       <text className='iconfont icon-jiantoudown'></text>
129 117
                     </view>
130 118
                   </view>

+ 6
- 18
src/pages/index/helpToFindHouse/components/HousePurchasing/index.jsx Просмотреть файл

@@ -1,20 +1,17 @@
1 1
 import { useState, useEffect } from 'react'
2 2
 import '@/assets/css/iconfont.css'
3
-import { Image, Slider, Textarea, Picker } from '@tarojs/components'
3
+import { Image, Slider, Textarea } from '@tarojs/components'
4 4
 import './index.scss'
5 5
 import questions from './formData'
6 6
 
7 7
 export default function HousePurchasing (props) {
8
-  const { change = () => { }, toSubmit = () => {}, CityList = [] } = props
8
+  const { change = () => { }, toSubmit = () => {}, AreaInfo = {}, selectArea = () => {} } = props
9 9
 
10 10
   const [FormData, setFormData] = useState(questions)
11 11
 
12 12
   const [StepId, setStepId] = useState(1)
13 13
   const [StepRange, setStepRange] = useState([0, 5])
14 14
 
15
-  const [CityName, setCityName] = useState(null)
16
-  const [CityId, setCityId] = useState(null)
17
-
18 15
   useEffect(() => {
19 16
     if(StepId === 1) {
20 17
       setStepRange([0, 5])
@@ -53,7 +50,7 @@ export default function HousePurchasing (props) {
53 50
     if (StepId < 1) {
54 51
       setStepId(StepId + 1)
55 52
     } else {
56
-      toSubmit(FormData.concat([{result: CityId, key: 'intentArea', question: '意向区域'}]))
53
+      toSubmit(FormData)
57 54
     }
58 55
   }
59 56
 
@@ -63,11 +60,6 @@ export default function HousePurchasing (props) {
63 60
     }
64 61
   }
65 62
 
66
-  const PickerChange = (e) => {
67
-    setCityName(CityList[e.detail.value - 0].name)
68
-    setCityId(CityList[e.detail.value - 0].id)
69
-  }
70
-
71 63
   return (
72 64
     <view className='components BuyHouse'>
73 65
       {
@@ -108,17 +100,13 @@ export default function HousePurchasing (props) {
108 100
                 {
109 101
                   item.type === 'select' &&
110 102
                   <view className='Area'>
111
-                    <view className='flex-h'>
103
+                    <view className='flex-h' onClick={selectArea}>
112 104
                       {
113 105
                         item.key === 'district' &&
114 106
                         <text className='iconfont icon-dingwei'></text>
115 107
                       }
116
-                      {/* <text>不限</text> */}
117
-                      <view className='flex-item'>
118
-                        <Picker range-key='name' onChange={PickerChange} value={0} range={CityList}>
119
-                          <text>{CityName || '请选择'}</text>
120
-                        </Picker>
121
-                      </view>
108
+                      <text>{AreaInfo.name || '不限'}</text>
109
+                      <view className='flex-item'></view>
122 110
                       <text className='iconfont icon-jiantoudown'></text>
123 111
                     </view>
124 112
                   </view>

+ 6
- 18
src/pages/index/helpToFindHouse/components/RentingHouse/index.jsx Просмотреть файл

@@ -1,20 +1,17 @@
1 1
 import { useState, useEffect } from 'react'
2 2
 import '@/assets/css/iconfont.css'
3
-import { Image, Slider, Textarea, Picker } from '@tarojs/components'
3
+import { Image, Slider, Textarea } from '@tarojs/components'
4 4
 import './index.scss'
5 5
 import questions from './formData'
6 6
 
7 7
 export default function RentingHouse (props) {
8
-  const { change = () => { }, toSubmit = () => {}, CityList = [] } = props
8
+  const { change = () => { }, toSubmit = () => {}, AreaInfo = {}, selectArea = () => {} } = props
9 9
 
10 10
   const [FormData, setFormData] = useState(questions)
11 11
 
12 12
   const [StepId, setStepId] = useState(1)
13 13
   const [StepRange, setStepRange] = useState([0, 4])
14 14
 
15
-  const [CityName, setCityName] = useState(null)
16
-  const [CityId, setCityId] = useState(null)
17
-
18 15
   useEffect(() => {
19 16
     if(StepId === 1) {
20 17
       setStepRange([0, 4])
@@ -55,7 +52,7 @@ export default function RentingHouse (props) {
55 52
     if (StepId < 2) {
56 53
       setStepId(StepId + 1)
57 54
     } else {
58
-      toSubmit(FormData.concat([{result: CityId, key: 'intentArea', question: '意向区域'}]))
55
+      toSubmit(FormData)
59 56
     }
60 57
   }
61 58
 
@@ -65,11 +62,6 @@ export default function RentingHouse (props) {
65 62
     }
66 63
   }
67 64
 
68
-  const PickerChange = (e) => {
69
-    setCityName(CityList[e.detail.value - 0].name)
70
-    setCityId(CityList[e.detail.value - 0].id)
71
-  }
72
-
73 65
   return (
74 66
     <view className='components BuyHouse'>
75 67
       {
@@ -110,17 +102,13 @@ export default function RentingHouse (props) {
110 102
                 {
111 103
                   item.type === 'select' &&
112 104
                   <view className='Area'>
113
-                    <view className='flex-h'>
105
+                    <view className='flex-h' onClick={selectArea}>
114 106
                       {
115 107
                         item.key === 'district' &&
116 108
                         <text className='iconfont icon-dingwei'></text>
117 109
                       }
118
-                      {/* <text>不限</text> */}
119
-                      <view className='flex-item'>
120
-                        <Picker range-key='name' onChange={PickerChange} value={0} range={CityList}>
121
-                          <text>{CityName || '请选择'}</text>
122
-                        </Picker>
123
-                      </view>
110
+                      <text>{AreaInfo.name || '不限'}</text>
111
+                      <view className='flex-item'></view>
124 112
                       <text className='iconfont icon-jiantoudown'></text>
125 113
                     </view>
126 114
                   </view>

+ 2
- 1
src/pages/index/helpToFindHouse/components/SubmitBuyHouseResult/index.jsx Просмотреть файл

@@ -1,6 +1,7 @@
1 1
 
2 2
 import '@/assets/css/iconfont.css'
3 3
 import { Image, Block } from '@tarojs/components'
4
+import { getImgURL } from '@/utils/image'
4 5
 import Taro from '@tarojs/taro'
5 6
 import './index.scss'
6 7
 
@@ -44,7 +45,7 @@ export default function SubmitBuyHouseResult (props) {
44 45
                       <view className='RecommendBuildingItem' onClick={() => {Taro.navigateTo({ url: `/pages/index/buildingDetail/index?id=${item.buildingId}` })}}>
45 46
                         <view>
46 47
                           <view className='Img'>
47
-                            <Image mode='aspectFill' src={item.poster} className='centerLabel'></Image>
48
+                            <Image mode='aspectFill' src={getImgURL(item.poster || item.preSalePermit)} className='centerLabel'></Image>
48 49
                           </view>
49 50
                           <view className='Title flex-h'>
50 51
                             <view className='flex-item'>

+ 27
- 23
src/pages/index/helpToFindHouse/index.jsx Просмотреть файл

@@ -1,10 +1,11 @@
1
-import { useState, useEffect } from 'react'
1
+import { useState } from 'react'
2 2
 import withLayout from '@/layout'
3 3
 import { ScrollView, Image } from '@tarojs/components'
4 4
 import { fetch } from '@/utils/request'
5
-import { API_HELP_FIND_HOUSE_SUBMIT, API_CITY_AREA } from '@/constants/api'
5
+import { API_HELP_FIND_HOUSE_SUBMIT } from '@/constants/api'
6 6
 import '@/assets/css/iconfont.css'
7 7
 import { useSelector } from 'react-redux'
8
+import AreaPickerView from '@/components/AreaPickerView/index'
8 9
 import './index.scss'
9 10
 import BuyHouse from './components/BuyHouse/index'
10 11
 import RentingHouse from './components/RentingHouse/index'
@@ -14,7 +15,6 @@ import SubmitBuyHouseResult from './components/SubmitBuyHouseResult/index'
14 15
 export default withLayout(() => {
15 16
 
16 17
   const user = useSelector(state => state.user)
17
-  const city = useSelector(state => state.city)
18 18
   const [DemandList] = useState([
19 19
     { name: '我要买房', id: 1, icon: '', spell: 'MAI FANG' },
20 20
     { name: '我要租房', id: 2, icon: '', spell: 'ZU FANG' },
@@ -22,19 +22,10 @@ export default withLayout(() => {
22 22
   ])
23 23
   const [CurrentDemandId, setCurrentDemandId] = useState(1)
24 24
   const [ShowDemand, setShowDemand] = useState(true)
25
-  const [CityAreaList, setCityAreaList] = useState([])
26 25
   const [ResultList, setResultList] = useState([])
27 26
   const [ShowPopup, setShowPopup] = useState(false)
28
-
29
-  useEffect(() => {
30
-    CityArea()
31
-  }, [])
32
-
33
-  const CityArea = () => {
34
-    fetch({ url: API_CITY_AREA, method: 'get', payload: { cityId: city.curCity.id, leveltype: 3 } }).then((res) => {
35
-      setCityAreaList(res || [])
36
-    })
37
-  }
27
+  const [ShowCitysPopup, setShowCitysPopup] = useState(false)
28
+  const [AreaInfo, setAreaInfo] = useState({})
38 29
 
39 30
   const CutDemandId = (id) => {
40 31
     return () => {
@@ -46,21 +37,31 @@ export default withLayout(() => {
46 37
     setShowDemand(id === 1)
47 38
   }
48 39
 
40
+  const AreaChange = (e) => {
41
+    setAreaInfo(e[2])
42
+    setShowCitysPopup(false)
43
+  }
44
+
49 45
   const submitForm = (data) => {
50 46
     data = data || []
51 47
     let params = []
52 48
     data.map((item) => {
53
-      if(item.key === 'budget') {
54
-        params.push({...item, key: 'minPrice', result: CurrentDemandId === 2 ? item.options[0] : item.options[0] * 10000})
55
-        params.push({...item, key: 'maxPrice', result: CurrentDemandId === 2 ? item.result : item.result * 10000})
49
+      if (item.key === 'budget') {
50
+        params.push({ ...item, key: 'minPrice', result: CurrentDemandId === 2 ? item.options[0] : item.options[0] * 10000 })
51
+        params.push({ ...item, key: 'maxPrice', result: CurrentDemandId === 2 ? item.result : item.result * 10000 })
56 52
       } else {
57
-        if(item.result !== '' || item.resultId !== null) {
53
+        if (item.result !== '' || item.resultId !== null) {
58 54
           params.push(item)
59 55
         }
60 56
       }
61 57
     })
62
-    params.push({question: '创建人小程序人员', result: user?.userInfo?.person?.personId, key: 'personId' })
63
-    fetch({ url: API_HELP_FIND_HOUSE_SUBMIT, method: 'post', payload: params }).then((res) => {
58
+    params.push({ question: '创建人小程序人员', result: user?.userInfo?.person?.personId, key: 'personId' })
59
+    params.push({ question: '意向区域', result: AreaInfo.id, key: 'intentArea' })
60
+    let payload = {}
61
+    params.map((item) => {
62
+      payload[item.key] = item.result || item.resultId
63
+    })
64
+    fetch({ url: API_HELP_FIND_HOUSE_SUBMIT, method: 'post', payload: { ...payload, questionnaire: JSON.stringify(params), type: CurrentDemandId } }).then((res) => {
64 65
       setResultList(res.taBuildingList || [])
65 66
       setShowPopup(true)
66 67
     })
@@ -68,6 +69,9 @@ export default withLayout(() => {
68 69
 
69 70
   return (
70 71
     <view className='Page helpToFindHouse'>
72
+
73
+      <AreaPickerView show={ShowCitysPopup} Change={AreaChange} Cancel={() => { setShowCitysPopup(false) }}></AreaPickerView>
74
+
71 75
       {
72 76
         ShowPopup &&
73 77
         <SubmitBuyHouseResult List={ResultList}></SubmitBuyHouseResult>
@@ -97,19 +101,19 @@ export default withLayout(() => {
97 101
           {/* 买房 */}
98 102
           {
99 103
             CurrentDemandId === 1 &&
100
-            <BuyHouse change={StepChange} toSubmit={submitForm} CityList={CityAreaList}></BuyHouse>
104
+            <BuyHouse change={StepChange} toSubmit={submitForm} AreaInfo={AreaInfo} selectArea={() => { setShowCitysPopup(true) }}></BuyHouse>
101 105
           }
102 106
 
103 107
           {/* 租房 */}
104 108
           {
105 109
             CurrentDemandId === 2 &&
106
-            <RentingHouse change={StepChange} toSubmit={submitForm} CityList={CityAreaList}></RentingHouse>
110
+            <RentingHouse change={StepChange} toSubmit={submitForm} AreaInfo={AreaInfo} selectArea={() => { setShowCitysPopup(true) }}></RentingHouse>
107 111
           }
108 112
 
109 113
           {/* 置业 */}
110 114
           {
111 115
             CurrentDemandId === 3 &&
112
-            <HousePurchasing change={StepChange} toSubmit={submitForm} CityList={CityAreaList}></HousePurchasing>
116
+            <HousePurchasing change={StepChange} toSubmit={submitForm} AreaInfo={AreaInfo} selectArea={() => { setShowCitysPopup(true) }}></HousePurchasing>
113 117
           }
114 118
 
115 119
         </view>

+ 6
- 0
src/pages/index/helpToFindHouse/index.scss Просмотреть файл

@@ -1,8 +1,14 @@
1 1
 .Page.helpToFindHouse {
2 2
   background: #fff;
3
+  width: 100%;
4
+  height: 100%;
5
+  position: relative;
6
+  overflow: hidden;
3 7
   > scroll-view {
4 8
     width: 100%;
5 9
     height: 100%;
10
+    position: relative;
11
+    z-index: 1;
6 12
     .PageContent {
7 13
       position: relative;
8 14
       overflow: hidden;