Browse Source

静态页面

1002884655 3 years ago
parent
commit
d4faba434a

+ 2
- 2
config/dev.js View File

3
     NODE_ENV: '"development"'
3
     NODE_ENV: '"development"'
4
   },
4
   },
5
   defineConstants: {
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
     WSS_HOST: '"wss://xlk.njyz.tech"',
8
     WSS_HOST: '"wss://xlk.njyz.tech"',
9
     OSS_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
9
     OSS_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
10
     OSS_FAST_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
10
     OSS_FAST_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',

+ 13
- 3
src/pages/index/addedValueService/index.jsx View File

3
 import { Image, Slider, Textarea, ScrollView } from '@tarojs/components'
3
 import { Image, Slider, Textarea, ScrollView } from '@tarojs/components'
4
 import { fetch } from '@/utils/request'
4
 import { fetch } from '@/utils/request'
5
 import { API_HELP_FIND_HOUSE_SUBMIT } from '@/constants/api'
5
 import { API_HELP_FIND_HOUSE_SUBMIT } from '@/constants/api'
6
+import { useSelector } from 'react-redux'
6
 import './index.scss'
7
 import './index.scss'
7
 import questions from './formData'
8
 import questions from './formData'
8
 import SubmitBuyHouseResult from '../helpToFindHouse/components/SubmitBuyHouseResult/index'
9
 import SubmitBuyHouseResult from '../helpToFindHouse/components/SubmitBuyHouseResult/index'
9
 
10
 
10
 export default function AddedValueService () {
11
 export default function AddedValueService () {
11
 
12
 
13
+  const user = useSelector(state => state.user)
12
   const [FormData, setFormData] = useState(questions)
14
   const [FormData, setFormData] = useState(questions)
13
 
15
 
14
   const [StepId, setStepId] = useState(1)
16
   const [StepId, setStepId] = useState(1)
30
 
32
 
31
   const SubmitForm = (data) => {
33
   const SubmitForm = (data) => {
32
     data = data || []
34
     data = data || []
33
-    let params = {}
35
+    let params = []
34
     data.map((item) => {
36
     data.map((item) => {
35
-      params[item.key] = item.result
37
+      if(item.key === 'budget') {
38
+        params.push({...item, key: 'minPrice', result: item.options[0] * 10000})
39
+        params.push({...item, key: 'maxPrice', result: item.result * 10000})
40
+      } else {
41
+        if(item.result !== '' || item.resultId !== null) {
42
+          params.push(item)
43
+        }
44
+      }
36
     })
45
     })
37
-    fetch({ url: API_HELP_FIND_HOUSE_SUBMIT, method: 'post', payload: { ...params, type: 4 } }).then((res) => {
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) => {
38
       setResultList(res.taBuildingList || [])
48
       setResultList(res.taBuildingList || [])
39
       setShowPopup(true)
49
       setShowPopup(true)
40
     })
50
     })

+ 20
- 20
src/pages/index/components/HotRecommend/index.jsx View File

7
 
7
 
8
 export default function HotRecommend (props) {
8
 export default function HotRecommend (props) {
9
 
9
 
10
-  const { change = () => {} } = props
10
+  const { change = () => { } } = props
11
   const city = useSelector(state => state.city)
11
   const city = useSelector(state => state.city)
12
   const [MenuList] = useState([{ name: '热门活动', id: 'dymic' }, { name: '热门团房', id: 'house' }])
12
   const [MenuList] = useState([{ name: '热门活动', id: 'dymic' }, { name: '热门团房', id: 'house' }])
13
   const [CurrentId, setCurrentId] = useState('dymic')
13
   const [CurrentId, setCurrentId] = useState('dymic')
14
-  const [list,setList]=useState([])
15
-  const [CurrentContentInfo, setCurrentContentInfo] = useState({ })
14
+  const [list, setList] = useState([])
15
+  const [CurrentContentInfo, setCurrentContentInfo] = useState({})
16
 
16
 
17
   useEffect(() => {
17
   useEffect(() => {
18
-    if(city.curCity.name) {
18
+    if (city.curCity.name) {
19
       GetRecommendActivity()
19
       GetRecommendActivity()
20
     }
20
     }
21
   }, [city])
21
   }, [city])
22
 
22
 
23
   const GetRecommendActivity = () => {
23
   const GetRecommendActivity = () => {
24
-    
25
-      queryActivityList({home:1,cityId: city.curCity.id}).then((res)=>{
26
-        const resArr = res.list || []
27
-        setList(resArr)
28
-        change(!!resArr.length)
29
-      })
24
+
25
+    queryActivityList({ home: 1, cityId: city.curCity.id }).then((res) => {
26
+      const resArr = res.records || []
27
+      setList(resArr)
28
+      change(!!resArr.length)
29
+    })
30
   }
30
   }
31
 
31
 
32
   useEffect(() => {
32
   useEffect(() => {
33
-    if(list.length>0) {
34
-      setCurrentContentInfo(list.filter(x=>x.type==CurrentId)[0]||{})
33
+    if (list.length > 0) {
34
+      setCurrentContentInfo(CurrentId === 'dymic' ? list[0] : list[1])
35
     }
35
     }
36
-  }, [CurrentId,list])
36
+  }, [CurrentId, list])
37
 
37
 
38
   const CutMenu = (id) => {
38
   const CutMenu = (id) => {
39
     return () => {
39
     return () => {
40
       setCurrentId(id)
40
       setCurrentId(id)
41
     }
41
     }
42
   }
42
   }
43
-// x?type=dymic' },
44
-//     { name: '团房信息', id: 8, icon: require('../../../../assets/index-icon12.png'), router: '/pages/index/activityList/index?type=house'
43
+  // x?type=dymic' },
44
+  //     { name: '团房信息', id: 8, icon: require('../../../../assets/index-icon12.png'), router: '/pages/index/activityList/index?type=house'
45
   const ToMore = () => {
45
   const ToMore = () => {
46
-    Taro.navigateTo({url: `/pages/index/activityList/index?type=${CurrentId}`})
46
+    Taro.navigateTo({ url: `/pages/index/activityList/index?type=${CurrentId}` })
47
   }
47
   }
48
 
48
 
49
   const toDetail = () => {
49
   const toDetail = () => {
50
-    if(CurrentContentInfo.dynamicId){
51
-      Taro.navigateTo({url: `/pages/index/activityDetail/index?id=${CurrentContentInfo.dynamicId}`})
50
+    if (CurrentContentInfo.dynamicId) {
51
+      Taro.navigateTo({ url: `/pages/index/activityDetail/index?id=${CurrentContentInfo.dynamicId}` })
52
     }
52
     }
53
   }
53
   }
54
   // url: `/pages/index/activityDetail/index?id=${data.dynamicId}`
54
   // url: `/pages/index/activityDetail/index?id=${data.dynamicId}`
62
             ))
62
             ))
63
           }
63
           }
64
         </view>
64
         </view>
65
-      <view className='Content' onClick={toDetail}>
65
+        <view className='Content' onClick={toDetail}>
66
           <view className='flex-h'>
66
           <view className='flex-h'>
67
-            <text className='flex-item'>{CurrentContentInfo.title||'暂无活动'}</text>
67
+            <text className='flex-item'>{CurrentContentInfo.title || '暂无活动'}</text>
68
             <text onClick={ToMore}>{CurrentId === 'dymic' ? '更多活动' : '更多团房'}</text>
68
             <text onClick={ToMore}>{CurrentId === 'dymic' ? '更多活动' : '更多团房'}</text>
69
           </view>
69
           </view>
70
           <text>{CurrentContentInfo.halfTitle}</text>
70
           <text>{CurrentContentInfo.halfTitle}</text>

+ 20
- 20
src/pages/index/components/Menu/index.jsx View File

1
-import React, { useState, useEffect } from 'react'
2
-import './index.scss'
1
+import { useState } from 'react'
3
 import { Swiper, SwiperItem, Image } from '@tarojs/components'
2
 import { Swiper, SwiperItem, Image } from '@tarojs/components'
4
 import Taro from '@tarojs/taro'
3
 import Taro from '@tarojs/taro'
4
+import './index.scss'
5
 
5
 
6
-export default function Menu (props) {
6
+export default function Menu () {
7
   const List = [
7
   const List = [
8
-    { name: '全部楼盘', id: 1, icon: require('../../../../assets/index-icon9.png'), router: '/pages/index/buildingList/index' },
9
-    { name: '品牌地产', id: 2, icon: require('../../../../assets/index-icon8.png'), router: '/pages/index/brandList/index' },
10
-    { name: '近期开盘', id: 3, icon: require('../../../../assets/index-icon6.png'), router: `/pages/index/buildingList/index?isRecentOpening=1` },
11
-    { name: '帮我找房', id: 4, icon: require('../../../../assets/index-icon1.png'), router: '/pages/index/helpToFindHouse/index' },
12
-    { name: '增值服务', id: 5, icon: require('../../../../assets/index-icon16.png'), router: '/pages/index/addedValueService/index' },
13
-    { name: '地图找房', id: 6, icon: require('../../../../assets/index-icon2.png'), router: '/pages/index/findHouseFromMap/index' },
14
-    { name: '活动信息', id: 7, icon: require('../../../../assets/index-icon5.png'), router: '/pages/index/activityList/index?type=dymic' },
15
-    { name: '团房信息', id: 8, icon: require('../../../../assets/index-icon12.png'), router: '/pages/index/activityList/index?type=house' },
16
-    { name: '特价房', id: 9, icon: require('../../../../assets/index-icon11.png'), router: '/pages/index/specialPriceHouse/index' },
17
-    { name: '康养', id: 10, icon: require('../../../../assets/index-icon7.png'), router: '/pages/index/recovered/index' },
18
-    { name: '文旅商办', id: 11, icon: require('../../../../assets/index-icon13.png'), router: `/pages/index/buildingList/index?isCommerce=1` },
19
-    { name: '新闻资讯', id: 12, icon: require('../../../../assets/index-icon15.png'), router: '/pages/index/newsList/index' },
20
-    { name: '购房百科', id: 13, icon: require('../../../../assets/index-icon4.png'), router: '/pages/index/encyclopediasOfBuyHouse/index' },
21
-    { name: '房贷计算', id: 14, icon: require('../../../../assets/index-icon3.png'), router: '/pages/index/mortgageCalculation/index' }
8
+    { name: '全部楼盘', id: 1, icon: require('@/assets/index-icon9.png'), router: '/pages/index/buildingList/index' },
9
+    { name: '品牌地产', id: 2, icon: require('@/assets/index-icon8.png'), router: '/pages/index/brandList/index' },
10
+    { name: '近期开盘', id: 3, icon: require('@/assets/index-icon6.png'), router: `/pages/index/buildingList/index?isRecentOpening=1` },
11
+    { name: '帮我找房', id: 4, icon: require('@/assets/index-icon1.png'), router: '/pages/index/helpToFindHouse/index' },
12
+    { name: '增值服务', id: 5, icon: require('@/assets/index-icon16.png'), router: '/pages/index/addedValueService/index' },
13
+    { name: '地图找房', id: 6, icon: require('@/assets/index-icon2.png'), router: '/pages/index/findHouseFromMap/index' },
14
+    { name: '活动信息', id: 7, icon: require('@/assets/index-icon5.png'), router: '/pages/index/activityList/index?type=dymic' },
15
+    { name: '团房信息', id: 8, icon: require('@/assets/index-icon12.png'), router: '/pages/index/activityList/index?type=house' },
16
+    { name: '特价房', id: 9, icon: require('@/assets/index-icon11.png'), router: '/pages/index/specialPriceHouse/index' },
17
+    { name: '康养', id: 10, icon: require('@/assets/index-icon7.png'), router: '/pages/index/recovered/index' },
18
+    { name: '文旅商办', id: 11, icon: require('@/assets/index-icon13.png'), router: `/pages/index/buildingList/index?isCommerce=1` },
19
+    { name: '新闻资讯', id: 12, icon: require('@/assets/index-icon15.png'), router: '/pages/index/newsList/index' },
20
+    { name: '购房百科', id: 13, icon: require('@/assets/index-icon4.png'), router: '/pages/index/encyclopediasOfBuyHouse/index' },
21
+    { name: '房贷计算', id: 14, icon: require('@/assets/index-icon3.png'), router: '/pages/index/mortgageCalculation/index' }
22
   ]
22
   ]
23
   let Arr = []
23
   let Arr = []
24
   List.map((item) => {
24
   List.map((item) => {
32
       Arr.push([{ ...item }])
32
       Arr.push([{ ...item }])
33
     }
33
     }
34
   })
34
   })
35
-  const [MenuList, setMenuList] = useState(Arr)
35
+  const [MenuList] = useState(Arr)
36
 
36
 
37
   const MenuClick = (item) => {
37
   const MenuClick = (item) => {
38
     return () => {
38
     return () => {
46
     <view className='components Menu'>
46
     <view className='components Menu'>
47
       <view>
47
       <view>
48
         <view>
48
         <view>
49
-          <Swiper autoplay={false} indicator-dots={true}>
49
+          <Swiper autoplay={false} indicator-dots>
50
             {
50
             {
51
               MenuList.map((item, index) => (
51
               MenuList.map((item, index) => (
52
                 <SwiperItem key={`Banner-${index}`}>
52
                 <SwiperItem key={`Banner-${index}`}>
53
-                  <view className="swiper-item">
53
+                  <view className='swiper-item'>
54
                     {
54
                     {
55
                       item.map((subItem, subIndex) => (
55
                       item.map((subItem, subIndex) => (
56
                         <view key={`BannerItem-${subIndex}`} onClick={MenuClick(subItem)}>
56
                         <view key={`BannerItem-${subIndex}`} onClick={MenuClick(subItem)}>

+ 1
- 1
src/pages/index/helpToFindHouse/components/BuyHouse/index.jsx View File

59
     if (StepId < 4) {
59
     if (StepId < 4) {
60
       setStepId(StepId + 1)
60
       setStepId(StepId + 1)
61
     } else {
61
     } else {
62
-      toSubmit(FormData.concat([{result: CityId, key: 'intentArea'}]))
62
+      toSubmit(FormData.concat([{result: CityId, key: 'intentArea', question: '意向区域'}]))
63
     }
63
     }
64
   }
64
   }
65
 
65
 

+ 17
- 5
src/pages/index/helpToFindHouse/components/HousePurchasing/index.jsx View File

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

+ 17
- 5
src/pages/index/helpToFindHouse/components/RentingHouse/index.jsx View File

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

+ 1
- 1
src/pages/index/helpToFindHouse/components/SubmitBuyHouseResult/index.jsx View File

38
                   </view>
38
                   </view>
39
                 </view>
39
                 </view>
40
                 {
40
                 {
41
-                  List.map((item, index) => (
41
+                  List.slice(0, 1).map((item, index) => (
42
                     <Block key={`ListItem-${index}`}>
42
                     <Block key={`ListItem-${index}`}>
43
                       <view className='PlanTitle'>“方案一”</view>
43
                       <view className='PlanTitle'>“方案一”</view>
44
                       <view className='RecommendBuildingItem' onClick={() => {Taro.navigateTo({ url: `/pages/index/buildingDetail/index?id=${item.buildingId}` })}}>
44
                       <view className='RecommendBuildingItem' onClick={() => {Taro.navigateTo({ url: `/pages/index/buildingDetail/index?id=${item.buildingId}` })}}>

+ 13
- 3
src/pages/index/helpToFindHouse/index.jsx View File

4
 import { fetch } from '@/utils/request'
4
 import { fetch } from '@/utils/request'
5
 import { API_HELP_FIND_HOUSE_SUBMIT, API_CITY_LIST } from '@/constants/api'
5
 import { API_HELP_FIND_HOUSE_SUBMIT, API_CITY_LIST } from '@/constants/api'
6
 import '@/assets/css/iconfont.css'
6
 import '@/assets/css/iconfont.css'
7
+import { useSelector } from 'react-redux'
7
 import './index.scss'
8
 import './index.scss'
8
 import BuyHouse from './components/BuyHouse/index'
9
 import BuyHouse from './components/BuyHouse/index'
9
 import RentingHouse from './components/RentingHouse/index'
10
 import RentingHouse from './components/RentingHouse/index'
12
 
13
 
13
 export default withLayout(() => {
14
 export default withLayout(() => {
14
 
15
 
16
+  const user = useSelector(state => state.user)
15
   const [DemandList] = useState([
17
   const [DemandList] = useState([
16
     { name: '我要买房', id: 1, icon: '', spell: 'MAI FANG' },
18
     { name: '我要买房', id: 1, icon: '', spell: 'MAI FANG' },
17
     { name: '我要租房', id: 2, icon: '', spell: 'ZU FANG' },
19
     { name: '我要租房', id: 2, icon: '', spell: 'ZU FANG' },
41
 
43
 
42
   const submitForm = (data) => {
44
   const submitForm = (data) => {
43
     data = data || []
45
     data = data || []
44
-    let params = {}
46
+    let params = []
45
     data.map((item) => {
47
     data.map((item) => {
46
-      params[item.key] = item.result
48
+      if(item.key === 'budget') {
49
+        params.push({...item, key: 'minPrice', result: CurrentDemandId === 2 ? item.options[0] : item.options[0] * 10000})
50
+        params.push({...item, key: 'maxPrice', result: CurrentDemandId === 2 ? item.result : item.result * 10000})
51
+      } else {
52
+        if(item.result !== '' || item.resultId !== null) {
53
+          params.push(item)
54
+        }
55
+      }
47
     })
56
     })
48
-    fetch({ url: API_HELP_FIND_HOUSE_SUBMIT, method: 'post', payload: { ...params, type: CurrentDemandId } }).then((res) => {
57
+    params.push({question: '创建人小程序人员', result: user?.userInfo?.person?.personId, key: 'personId' })
58
+    fetch({ url: API_HELP_FIND_HOUSE_SUBMIT, method: 'post', payload: params }).then((res) => {
49
       setResultList(res.taBuildingList || [])
59
       setResultList(res.taBuildingList || [])
50
       setShowPopup(true)
60
       setShowPopup(true)
51
     })
61
     })

+ 52
- 27
src/pages/index/specialPriceHouse/index.jsx View File

3
 import withLayout from '@/layout'
3
 import withLayout from '@/layout'
4
 import { ScrollView, Image } from '@tarojs/components'
4
 import { ScrollView, Image } from '@tarojs/components'
5
 import Disclaimer from '@/components/Disclaimer'
5
 import Disclaimer from '@/components/Disclaimer'
6
-import { getSpecialRoomList } from '@/services/project'
7
 import { getImgURL } from '@/utils/image'
6
 import { getImgURL } from '@/utils/image'
8
 import { formateLeftTime } from '@/utils/tools'
7
 import { formateLeftTime } from '@/utils/tools'
8
+import { useSelector } from 'react-redux'
9
+import { fetch } from '@/utils/request'
10
+import { API_SPECIAL_ROOM_LIST } from '@/constants/api'
9
 import '@/assets/css/iconfont.css'
11
 import '@/assets/css/iconfont.css'
10
 import './index.scss'
12
 import './index.scss'
11
 
13
 
12
 const defaultRuleImage = 'https://yz-websit.oss-cn-hangzhou.aliyuncs.com/xlk/index-icon19.jpg'
14
 const defaultRuleImage = 'https://yz-websit.oss-cn-hangzhou.aliyuncs.com/xlk/index-icon19.jpg'
13
 
15
 
14
-export default withLayout((props) => {
15
-  const { city } = props
16
-
17
-  const [list, setList] = useState([])
18
-
19
-  const getRoomList = (params) => {
20
-    Taro.showLoading()
21
-    getSpecialRoomList({
22
-      cityId: city?.id,
23
-      ...params,
24
-    }).then((res) => {
25
-      const { records } = res
26
-      setList(records || [])
27
-      Taro.hideLoading()
28
-    }).catch((err) => {
29
-      console.error(err)
30
-      Taro.hideLoading()
16
+export default withLayout(() => {
17
+  
18
+  const user = useSelector(state => state.user)
19
+  const [PageList, setPageList] = useState([])
20
+  const [IsPull, setPull] = useState(false)
21
+  const [PersonId, setPersonId] = useState(null)
22
+  const [pageNumber, setPageNumber] = useState(1)
23
+  const [HasNextPage, setHasNextPage] = useState(true)
24
+
25
+  useEffect(() => {
26
+    if(user?.userInfo?.person?.personId) {
27
+      setPersonId(user.userInfo.person.personId)
28
+    }
29
+  }, [user])
30
+
31
+  useEffect(() => {
32
+    if(PersonId) {
33
+      GetPageList()
34
+    }
35
+  }, [pageNumber, PersonId])
36
+
37
+  const PageRefresh = () => { // 页面下拉刷新回调
38
+    setPull(true)
39
+  }
40
+
41
+  const GetPageList = () => {
42
+    setHasNextPage(false)
43
+    fetch({ url: API_SPECIAL_ROOM_LIST, method: 'get', payload: { pageNumber, pageSize: 10 } }).then((res) => {
44
+      setPageList(pageNumber === 1 ? res.records || [] : PageList.concat(res.records || []))
45
+      setHasNextPage(res.current < res.pages)
46
+      setPull(false)
31
     })
47
     })
32
   }
48
   }
33
 
49
 
50
+  const PageLoadMore = () => { // 页面上拉加载更多
51
+    if(HasNextPage) {
52
+      setPageNumber(pageNumber + 1)
53
+    }
54
+  }
55
+
56
+  useEffect(() => { // 下拉刷新触发
57
+    if (IsPull) {
58
+      if(pageNumber === 1) {
59
+        GetPageList()
60
+      } else {
61
+        setPageNumber(1)
62
+      }
63
+    }
64
+  }, [IsPull])
65
+
34
   const goto = (it) => {
66
   const goto = (it) => {
35
     Taro.navigateTo({
67
     Taro.navigateTo({
36
       url: `/pages/index/buildingDetail/index?id=${it.buildingId}`
68
       url: `/pages/index/buildingDetail/index?id=${it.buildingId}`
37
     })
69
     })
38
   }
70
   }
39
 
71
 
40
-  useEffect(() => {
41
-    console.log('------params---->', city, city?.id)
42
-    if (city?.id) {
43
-      getRoomList({ pageNum: 1 })
44
-    }
45
-  }, [city?.id])
46
-
47
   return (
72
   return (
48
     <view className='Page specialPriceHouse'>
73
     <view className='Page specialPriceHouse'>
49
-      <ScrollView scroll-y>
74
+      <ScrollView scroll-y refresher-enabled refresher-triggered={IsPull} onrefresherrefresh={PageRefresh} onscrolltolower={PageLoadMore} refresher-background='#f8f8f8'>
50
         <view className='PageContent'>
75
         <view className='PageContent'>
51
 
76
 
52
           {/* 主图 */}
77
           {/* 主图 */}
57
           {/* 列表 */}
82
           {/* 列表 */}
58
           <view className='List'>
83
           <view className='List'>
59
             {
84
             {
60
-              list.map((item, index) => {
85
+              PageList.map((item, index) => {
61
                 const mainImg = getImgURL(item?.buildingListImg?.length ? item.buildingListImg[0].url : null)
86
                 const mainImg = getImgURL(item?.buildingListImg?.length ? item.buildingListImg[0].url : null)
62
                 const price = item.price || '价格待定'
87
                 const price = item.price || '价格待定'
63
                 const shareNum = item.shareList?.total || 0
88
                 const shareNum = item.shareList?.total || 0