|
@@ -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
|
})
|