瀏覽代碼

静态页面

1002884655 3 年之前
父節點
當前提交
38892d2af7

+ 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')

+ 1
- 1
src/pages/index/addedValueService/index.jsx 查看文件

@@ -48,7 +48,7 @@ export default function AddedValueService () {
48 48
     params.map((item) => {
49 49
       payload[item.key] = item.result || item.resultId
50 50
     })
51
-    fetch({ url: API_HELP_FIND_HOUSE_SUBMIT, method: 'post', payload: { ...payload, questionnaire: JSON.stringify(params) } }).then((res) => {
51
+    fetch({ url: API_HELP_FIND_HOUSE_SUBMIT, method: 'post', payload: { ...payload, questionnaire: JSON.stringify(params), type: 4 } }).then((res) => {
52 52
       setResultList(res.taBuildingList || [])
53 53
       setShowPopup(true)
54 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'>

+ 59
- 59
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,6 +37,11 @@ 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 = []
@@ -60,65 +56,69 @@ export default withLayout(() => {
60 56
       }
61 57
     })
62 58
     params.push({ question: '创建人小程序人员', result: user?.userInfo?.person?.personId, key: 'personId' })
59
+    params.push({ question: '意向区域', result: AreaInfo.id, key: 'intentArea' })
63 60
     let payload = {}
64 61
     params.map((item) => {
65 62
       payload[item.key] = item.result || item.resultId
66 63
     })
67
-    fetch({ url: API_HELP_FIND_HOUSE_SUBMIT, method: 'post', payload: { ...payload, questionnaire: JSON.stringify(params) } }).then((res) => {
64
+    fetch({ url: API_HELP_FIND_HOUSE_SUBMIT, method: 'post', payload: { ...payload, questionnaire: JSON.stringify(params), type: CurrentDemandId } }).then((res) => {
68 65
       setResultList(res.taBuildingList || [])
69 66
       setShowPopup(true)
70 67
     })
71 68
   }
72 69
 
73
-return (
74
-  <view className='Page helpToFindHouse'>
75
-    {
76
-      ShowPopup &&
77
-      <SubmitBuyHouseResult List={ResultList}></SubmitBuyHouseResult>
78
-    }
70
+  return (
71
+    <view className='Page helpToFindHouse'>
72
+
73
+      <AreaPickerView show={ShowCitysPopup} Change={AreaChange} Cancel={() => { setShowCitysPopup(false) }}></AreaPickerView>
79 74
 
80
-    <ScrollView scroll-y refresher-enabled={false}>
81
-      <view className='PageContent'>
82
-
83
-        {
84
-          ShowDemand &&
85
-          <view>
86
-            <text>选择您的需求</text>
87
-            <view className='Demand flex-h' style='margin-top: 10px;'>
88
-              {
89
-                DemandList.map((item, index) => (
90
-                  <view key={`DemandItem-${index}`} className={CurrentDemandId === item.id ? 'flex-item active' : 'flex-item'} onClick={CutDemandId(item.id)}>
91
-                    <Image mode='heightFix' src={item.icon || null}></Image>
92
-                    <text>{item.name}</text>
93
-                    <text>{item.spell}</text>
94
-                  </view>
95
-                ))
96
-              }
75
+      {
76
+        ShowPopup &&
77
+        <SubmitBuyHouseResult List={ResultList}></SubmitBuyHouseResult>
78
+      }
79
+
80
+      <ScrollView scroll-y refresher-enabled={false}>
81
+        <view className='PageContent'>
82
+
83
+          {
84
+            ShowDemand &&
85
+            <view>
86
+              <text>选择您的需求</text>
87
+              <view className='Demand flex-h' style='margin-top: 10px;'>
88
+                {
89
+                  DemandList.map((item, index) => (
90
+                    <view key={`DemandItem-${index}`} className={CurrentDemandId === item.id ? 'flex-item active' : 'flex-item'} onClick={CutDemandId(item.id)}>
91
+                      <Image mode='heightFix' src={item.icon || null}></Image>
92
+                      <text>{item.name}</text>
93
+                      <text>{item.spell}</text>
94
+                    </view>
95
+                  ))
96
+                }
97
+              </view>
97 98
             </view>
98
-          </view>
99
-        }
99
+          }
100 100
 
101
-        {/* 买房 */}
102
-        {
103
-          CurrentDemandId === 1 &&
104
-          <BuyHouse change={StepChange} toSubmit={submitForm} CityList={CityAreaList}></BuyHouse>
105
-        }
101
+          {/* 买房 */}
102
+          {
103
+            CurrentDemandId === 1 &&
104
+            <BuyHouse change={StepChange} toSubmit={submitForm} AreaInfo={AreaInfo} selectArea={() => { setShowCitysPopup(true) }}></BuyHouse>
105
+          }
106 106
 
107
-        {/* 租房 */}
108
-        {
109
-          CurrentDemandId === 2 &&
110
-          <RentingHouse change={StepChange} toSubmit={submitForm} CityList={CityAreaList}></RentingHouse>
111
-        }
107
+          {/* 租房 */}
108
+          {
109
+            CurrentDemandId === 2 &&
110
+            <RentingHouse change={StepChange} toSubmit={submitForm} AreaInfo={AreaInfo} selectArea={() => { setShowCitysPopup(true) }}></RentingHouse>
111
+          }
112 112
 
113
-        {/* 置业 */}
114
-        {
115
-          CurrentDemandId === 3 &&
116
-          <HousePurchasing change={StepChange} toSubmit={submitForm} CityList={CityAreaList}></HousePurchasing>
117
-        }
113
+          {/* 置业 */}
114
+          {
115
+            CurrentDemandId === 3 &&
116
+            <HousePurchasing change={StepChange} toSubmit={submitForm} AreaInfo={AreaInfo} selectArea={() => { setShowCitysPopup(true) }}></HousePurchasing>
117
+          }
118 118
 
119
-      </view>
120
-    </ScrollView>
119
+        </view>
120
+      </ScrollView>
121 121
 
122
-  </view>
123
-)
122
+    </view>
123
+  )
124 124
 })

+ 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;