Your Name 4 年前
父节点
当前提交
035c3149fd

+ 11
- 5
src/pages/index/buildingDetail/components/HouseTypeIntro/index.jsx 查看文件

1
-
1
+import Taro from '@tarojs/taro'
2
 import { ScrollView, Image } from '@tarojs/components'
2
 import { ScrollView, Image } from '@tarojs/components'
3
+import { getImgURL } from '@/utils/image'
3
 import '@/assets/css/iconfont.css'
4
 import '@/assets/css/iconfont.css'
4
 import './index.scss'
5
 import './index.scss'
5
 
6
 
6
 export default function HouseTypeIntro (props) {
7
 export default function HouseTypeIntro (props) {
7
-  const { Info = [] } = props
8
+  const { Info } = props
9
+
10
+  const preview = (item) => {
11
+    const current = getImgURL(item.buildingImgList.length ? item.buildingImgList[0].url : null)
12
+    Taro.previewImage({ current, urls: [current] })
13
+  }
8
   
14
   
9
-  return (
15
+  return Info ? (
10
     <view className='components HouseTypeIntro'>
16
     <view className='components HouseTypeIntro'>
11
 
17
 
12
       <view className='Title flex-h'>
18
       <view className='Title flex-h'>
23
             Info.map((item, index) => (
29
             Info.map((item, index) => (
24
               <view className='ListItem' key={`List-${index}`}>
30
               <view className='ListItem' key={`List-${index}`}>
25
                 <view className='Img'>
31
                 <view className='Img'>
26
-                  <Image mode='aspectFill' src={item.buildingImgList.length ? item.buildingImgList[0].url : null}></Image>
32
+                  <Image mode='aspectFill' onClick={() => preview(item)} src={getImgURL(item.buildingImgList.length ? item.buildingImgList[0].url : null)}></Image>
27
                 </view>
33
                 </view>
28
                 <view className='Title'>
34
                 <view className='Title'>
29
                   <text>{item.apartmentName}</text>
35
                   <text>{item.apartmentName}</text>
37
       </view>
43
       </view>
38
 
44
 
39
     </view>
45
     </view>
40
-  )
46
+  ) : null
41
 }
47
 }

+ 4
- 4
src/pages/index/buildingDetail/components/LivingActivity/index.jsx 查看文件

6
 
6
 
7
 export default function LivingActivity (props) {
7
 export default function LivingActivity (props) {
8
   const { List = [] } = props
8
   const { List = [] } = props
9
-  return (
9
+  return List.length > 0 ? (
10
     <view className='components LivingActivity'>
10
     <view className='components LivingActivity'>
11
 
11
 
12
       <view className='Title flex-h'>
12
       <view className='Title flex-h'>
21
         {
21
         {
22
           List.map((item, index) => (
22
           List.map((item, index) => (
23
             <view className='flex-item' key={`ListItem-${index}`}>
23
             <view className='flex-item' key={`ListItem-${index}`}>
24
-              <view style={{display: item.images ? 'block' : 'none'}}>
25
-                <Image mode='aspectFill' src={getImgURL(item.images)} className='centerLabel'></Image>
24
+              <view style={{display: item.listImg ? 'block' : 'none'}}>
25
+                <Image mode='aspectFill' src={getImgURL(item.listImg)} className='centerLabel'></Image>
26
               </view>
26
               </view>
27
             </view>
27
             </view>
28
           ))
28
           ))
30
       </view>
30
       </view>
31
 
31
 
32
     </view>
32
     </view>
33
-  )
33
+  ) : null
34
 }
34
 }

+ 4
- 3
src/pages/index/buildingDetail/components/News/index.jsx 查看文件

1
 
1
 
2
 import { Image } from '@tarojs/components'
2
 import { Image } from '@tarojs/components'
3
+import { getImgURL } from '@/utils/image'
3
 import '@/assets/css/iconfont.css'
4
 import '@/assets/css/iconfont.css'
4
 import './index.scss'
5
 import './index.scss'
5
 
6
 
6
 export default function News (props) {
7
 export default function News (props) {
7
   const { List = [] } = props
8
   const { List = [] } = props
8
-  return (
9
+  return List.length > 0 ? (
9
     <view className='components News'>
10
     <view className='components News'>
10
 
11
 
11
       <view className='Title flex-h'>
12
       <view className='Title flex-h'>
21
           List.map((item, index) => (
22
           List.map((item, index) => (
22
             <view className='flex-item' key={`ListItem-${index}`}>
23
             <view className='flex-item' key={`ListItem-${index}`}>
23
               <view className='Img' style={{display: item.newsImg || item.newsName ? 'block' : 'none'}}>
24
               <view className='Img' style={{display: item.newsImg || item.newsName ? 'block' : 'none'}}>
24
-                <Image mode='aspectFill' src={item.newsImg} className='centerLabel'></Image>
25
+                <Image mode='aspectFill' src={getImgURL(item.newsImg)} className='centerLabel'></Image>
25
               </view>
26
               </view>
26
               <text className='Title'>{item.newsName}</text>
27
               <text className='Title'>{item.newsName}</text>
27
             </view>
28
             </view>
30
       </view>
31
       </view>
31
 
32
 
32
     </view>
33
     </view>
33
-  )
34
+  ) : null;
34
 }
35
 }

+ 38
- 24
src/pages/index/buildingDetail/components/Periphery/index.jsx 查看文件

1
 
1
 
2
-import { useEffect, useMemo, useState } from 'react'
2
+import { useCallback, useContext, useEffect, useMemo, useState } from 'react'
3
 import { Map, CoverView } from '@tarojs/components'
3
 import { Map, CoverView } from '@tarojs/components'
4
 import '@/assets/css/iconfont.css'
4
 import '@/assets/css/iconfont.css'
5
 import './index.scss'
5
 import './index.scss'
21
 
21
 
22
   const loc = useMemo(() => (Info?.coordinate ? Info.coordinate.split(',') : []), [Info?.coordinate])
22
   const loc = useMemo(() => (Info?.coordinate ? Info.coordinate.split(',') : []), [Info?.coordinate])
23
 
23
 
24
+  const countLen = useCallback((type) => {
25
+    if (!Info) return 0;
26
+    const tagLen = (Info[`building${type}`] || '').split(',').filter(Boolean).length
27
+    const poiLen = pois.filter((poi) => poi.key === type).map((it) => (it.data ? it.data.length : 0)).reduce((acc, i) => (acc + i), 0)
28
+
29
+    return tagLen + poiLen
30
+  }, [Info, pois])
31
+
24
   const CutTab = () => {
32
   const CutTab = () => {
25
     return () => {
33
     return () => {
26
       
34
       
28
   }
36
   }
29
 
37
 
30
   useEffect(() => {
38
   useEffect(() => {
31
-    if (!Info?.coordinate) {
32
-      setMarkers([])
33
-      return;
34
-    }
35
-
36
-    const mks = []
37
-    // 项目位置
38
-    mks.push({
39
-      id: -1,
40
-      longitude: loc[0],
41
-      latitude: loc[1],
42
-      iconPath: '',
43
-      width: 24,
44
-      height: 36,
45
-      customCallout: {
46
-        anchorY: 0,
47
-        anchorX: 0,
48
-        display: 'ALWAYS',
39
+    // 地图 marker
40
+    if (Info?.coordinate) {
41
+      const mks = []
42
+      // 项目位置
43
+      mks.push({
44
+        id: -1,
45
+        longitude: loc[0],
46
+        latitude: loc[1],
47
+        iconPath: '',
48
+        width: 24,
49
+        height: 36,
50
+        customCallout: {
51
+          anchorY: 0,
52
+          anchorX: 0,
53
+          display: 'ALWAYS',
54
+        }
55
+      })
56
+      // pois
57
+      if (Info?.mapJson) {
58
+        const poiArr = JSON.parse(Info.mapJson).map((it) => ({ ...it, data: JSON.parse(it.data) }))
59
+        setPois(poiArr)
49
       }
60
       }
50
-    })
51
-
52
-    setMarkers(mks)
53
-
61
+  
62
+      setMarkers(mks)
63
+    }
54
   }, [Info, loc])
64
   }, [Info, loc])
55
 
65
 
66
+  if (!Info?.coordinate) {
67
+    return null
68
+  }
69
+
56
   return (
70
   return (
57
     <view className='components Periphery'>
71
     <view className='components Periphery'>
58
 
72
 
86
           poiTypes.map((item) => (
100
           poiTypes.map((item) => (
87
             <view className='flex-item' key={item.value} onClick={CutTab(item.value)}>
101
             <view className='flex-item' key={item.value} onClick={CutTab(item.value)}>
88
               <text className={item.class}></text>
102
               <text className={item.class}></text>
89
-              <text>{item.label}(123)</text>
103
+              <text>{item.label}({countLen(item.value)})</text>
90
             </view>
104
             </view>
91
           ))
105
           ))
92
         }
106
         }

+ 19
- 3
src/pages/index/buildingDetail/components/Pictures/index.jsx 查看文件

1
-
2
-import '@/assets/css/iconfont.css'
1
+import Taro from '@tarojs/taro'
3
 import { ScrollView, Image } from '@tarojs/components'
2
 import { ScrollView, Image } from '@tarojs/components'
3
+import { getImgURL } from '@/utils/image'
4
+import '@/assets/css/iconfont.css'
4
 import './index.scss'
5
 import './index.scss'
6
+import { useMemo } from 'react'
5
 
7
 
6
 export default function Pictures (props) {
8
 export default function Pictures (props) {
7
   const { List = [] } = props
9
   const { List = [] } = props
10
+
11
+  const urls = useMemo(() => {
12
+    return List.map((x) => (x.buildingImgList?.length ? x.buildingImgList : undefined))
13
+      .filter(Boolean)
14
+      .reduce((acc, arr) => acc.concat(arr.map((f) => f.url)), [])
15
+      .filter(Boolean)
16
+      .map((x) => getImgURL(x))
17
+  }, [List])
18
+
19
+  const handlePreview = (item) => {
20
+    const current = getImgURL(item.buildingImgList.length ? item.buildingImgList[0].url : null)
21
+    Taro.previewImage({ current, urls })
22
+  }
23
+
8
   return (
24
   return (
9
     <view className='components Pictures'>
25
     <view className='components Pictures'>
10
 
26
 
18
         <ScrollView scroll-x>
34
         <ScrollView scroll-x>
19
           {
35
           {
20
             List.map((item, index) => (
36
             List.map((item, index) => (
21
-              <view className='ListItem' key={`List-${index}`}>
37
+              <view className='ListItem' key={`List-${index}`} onClick={() => handlePreview(item)}>
22
                 <view className='Img'>
38
                 <view className='Img'>
23
                   <Image mode='aspectFill' className='centerLabel' src={item.buildingImgList.length ? item.buildingImgList[0].url : null}></Image>
39
                   <Image mode='aspectFill' className='centerLabel' src={item.buildingImgList.length ? item.buildingImgList[0].url : null}></Image>
24
                 </view>
40
                 </view>

+ 2
- 2
src/pages/index/buildingDetail/components/PropertyConsultant/index.jsx 查看文件

18
     Taro.makePhoneCall({ phoneNumber: phone })
18
     Taro.makePhoneCall({ phoneNumber: phone })
19
   }
19
   }
20
 
20
 
21
-  return (
21
+  return List.length > 0 ? (
22
     <view className='components PropertyConsultant'>
22
     <view className='components PropertyConsultant'>
23
 
23
 
24
       <view className='Title flex-h'>
24
       <view className='Title flex-h'>
59
       </view>
59
       </view>
60
 
60
 
61
     </view>
61
     </view>
62
-  )
62
+  ) : null
63
 }
63
 }

+ 20
- 59
src/pages/index/buildingDetail/index.jsx 查看文件

20
 import Pictures from './components/Pictures/index'
20
 import Pictures from './components/Pictures/index'
21
 
21
 
22
 export default withLayout((props) => {
22
 export default withLayout((props) => {
23
+  const { id } = props.router.params
23
 
24
 
24
-  const user = useSelector(state => state.user)
25
-  const [PersonId, setPersonId] = useState(null)
26
   const [DetailInfo, setDetailInfo] = useState({})
25
   const [DetailInfo, setDetailInfo] = useState({})
27
   const [ActivityList, setActivityList] = useState([])
26
   const [ActivityList, setActivityList] = useState([])
28
   const [PictureList, setPictureList] = useState([])
27
   const [PictureList, setPictureList] = useState([])
29
   const [NewsList, setNewsList] = useState([])
28
   const [NewsList, setNewsList] = useState([])
30
-  const [LiveList, setLiveList] = useState([])
31
 
29
 
32
   const [IsPull, setPull] = useState(false)
30
   const [IsPull, setPull] = useState(false)
33
   const [PullTimer, setPullTimer] = useState(null)
31
   const [PullTimer, setPullTimer] = useState(null)
34
 
32
 
35
   useEffect(() => {
33
   useEffect(() => {
36
-    if (user?.userInfo?.person?.personId) {
37
-      setPersonId(user.userInfo.person.personId)
38
-    }
39
-  }, [user])
40
-
41
-  useEffect(() => {
42
-    if (PersonId) {
43
-      GetBuildingDetail()
44
-      GetProjectTrendList()
45
-      GetActivityList()
46
-      GetLiveList()
47
-      GetNewsList()
48
-    }
49
-  }, [PersonId])
50
-
51
-  useEffect(() => {
52
-    if (DetailInfo.buildingApartment) {
53
-      const List = DetailInfo.buildingApartment.filter(item => item.apartmentType === 'photo')
54
-      setPictureList(List.filter(item => item.buildingImgList.length > 0))
55
-    }
56
-  }, [DetailInfo])
57
-
58
-  const GetBuildingDetail = () => { // 获取楼盘信息
59
-    fetch({ url: `${API_ITEMS_DETAIL}/${props.router.params.id}`, method: 'get' }).then((res) => {
34
+    // 获取楼盘信息
35
+    fetch({ url: `${API_ITEMS_DETAIL}/${id}` }).then((res) => {
60
       setDetailInfo(res || {})
36
       setDetailInfo(res || {})
37
+      
38
+      if (res?.buildingApartment) {
39
+        const List = res.buildingApartment.filter(item => item.apartmentType === 'photo')
40
+        setPictureList(List.filter(item => item.buildingImgList.length > 0))
41
+      }
61
     })
42
     })
62
-  }
63
 
43
 
64
-  const GetProjectTrendList = () => { // 获取项目动态
65
-    fetch({ url: API_PROJECT_TREND_LIST, method: 'get' }).then((res) => {
66
-      console.log(res)
44
+    // 获取资讯列表
45
+    fetch({ url: API_NEWS_LIST, params: { buildingId: id, pageSize: 2, pageNum: 1 } }).then((res) => {
46
+      setNewsList(res.records || [])
67
     })
47
     })
68
-  }
48
+    GetActivityList()
49
+  }, [id])
69
 
50
 
70
   const GetActivityList = () => { // 获取活动列表
51
   const GetActivityList = () => { // 获取活动列表
71
     fetch({ url: `${API_ACTIVITY_GROUP}?buildingId=${props.router.params.id}`, method: 'get' }).then((res) => {
52
     fetch({ url: `${API_ACTIVITY_GROUP}?buildingId=${props.router.params.id}`, method: 'get' }).then((res) => {
74
     })
55
     })
75
   }
56
   }
76
 
57
 
77
-  const GetLiveList = () => { // 获取直播列表
78
-    fetch({ url: `${API_LIVE_LIST}?buildingId=${props.router.params.id}`, method: 'get' }).then((res) => {
79
-      let ResArr = res.records.slice(0, 2)
80
-      if (ResArr.length === 1) {
81
-        ResArr.push({})
82
-      }
83
-      setLiveList(ResArr || [])
84
-    })
85
-  }
86
-
87
-  const GetNewsList = () => { // 获取资讯列表
88
-    fetch({ url: `${API_NEWS_LIST}?buildingId=${props.router.params.id}&pageSize=2&pageNum=1`, method: 'get' }).then((res) => {
89
-      let ResArr = res.records.slice(0, 2)
90
-      if (ResArr.length === 1) {
91
-        ResArr.push({})
92
-      }
93
-      setNewsList(ResArr || [])
94
-    })
95
-  }
96
-
97
   const PageRefresh = () => { // 页面下拉刷新回调
58
   const PageRefresh = () => { // 页面下拉刷新回调
98
     setPull(true)
59
     setPull(true)
99
   }
60
   }
143
                 </view>
104
                 </view>
144
 
105
 
145
                 {/* 置业顾问 */}
106
                 {/* 置业顾问 */}
146
-                <view className='PropertyConsultant' style={{ display: DetailInfo?.consultants?.length ? 'block' : 'none' }}>
107
+                <view className='PropertyConsultant' style={{minHeight: 0}}>
147
                   <PropertyConsultant List={DetailInfo?.consultants}></PropertyConsultant>
108
                   <PropertyConsultant List={DetailInfo?.consultants}></PropertyConsultant>
148
                 </view>
109
                 </view>
149
 
110
 
150
                 {/* 位置及周边 */}
111
                 {/* 位置及周边 */}
151
-                <view className='Periphery'>
112
+                <view className='Periphery' style={{minHeight: 0}}>
152
                   <Periphery Info={DetailInfo}></Periphery>
113
                   <Periphery Info={DetailInfo}></Periphery>
153
                 </view>
114
                 </view>
154
 
115
 
155
                 {/* 户型介绍 */}
116
                 {/* 户型介绍 */}
156
-                <view className='HouseTypeIntro'>
117
+                <view className='HouseTypeIntro' style={{minHeight: 0}}>
157
                   <HouseTypeIntro Info={DetailInfo?.buildingApartment}></HouseTypeIntro>
118
                   <HouseTypeIntro Info={DetailInfo?.buildingApartment}></HouseTypeIntro>
158
                 </view>
119
                 </view>
159
 
120
 
160
                 {/* 营销活动 */}
121
                 {/* 营销活动 */}
161
-                <view className='MarketingActivity' style={{ display: ActivityList.length ? 'block' : 'none' }}>
122
+                <view className='MarketingActivity' style={{minHeight: 0}}>
162
                   <MarketingActivity List={ActivityList}></MarketingActivity>
123
                   <MarketingActivity List={ActivityList}></MarketingActivity>
163
                 </view>
124
                 </view>
164
 
125
 
165
                 {/* 直播活动 */}
126
                 {/* 直播活动 */}
166
-                <view className='LivingActivity' style={{ display: LiveList.length ? 'block' : 'none' }}>
167
-                  <LivingActivity List={LiveList}></LivingActivity>
127
+                <view className='LivingActivity' style={{minHeight: 0}}>
128
+                  <LivingActivity List={DetailInfo?.liveActivityList}></LivingActivity>
168
                 </view>
129
                 </view>
169
 
130
 
170
                 {/* 新鲜资讯 */}
131
                 {/* 新鲜资讯 */}
171
-                <view className='News' style={{ display: NewsList.length ? 'block' : 'none' }}>
132
+                <view className='News' style={{minHeight: 0}}>
172
                   <News List={NewsList}></News>
133
                   <News List={NewsList}></News>
173
                 </view>
134
                 </view>
174
 
135