Your Name пре 4 година
родитељ
комит
035c3149fd

+ 11
- 5
src/pages/index/buildingDetail/components/HouseTypeIntro/index.jsx Прегледај датотеку

@@ -1,12 +1,18 @@
1
-
1
+import Taro from '@tarojs/taro'
2 2
 import { ScrollView, Image } from '@tarojs/components'
3
+import { getImgURL } from '@/utils/image'
3 4
 import '@/assets/css/iconfont.css'
4 5
 import './index.scss'
5 6
 
6 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 16
     <view className='components HouseTypeIntro'>
11 17
 
12 18
       <view className='Title flex-h'>
@@ -23,7 +29,7 @@ export default function HouseTypeIntro (props) {
23 29
             Info.map((item, index) => (
24 30
               <view className='ListItem' key={`List-${index}`}>
25 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 33
                 </view>
28 34
                 <view className='Title'>
29 35
                   <text>{item.apartmentName}</text>
@@ -37,5 +43,5 @@ export default function HouseTypeIntro (props) {
37 43
       </view>
38 44
 
39 45
     </view>
40
-  )
46
+  ) : null
41 47
 }

+ 4
- 4
src/pages/index/buildingDetail/components/LivingActivity/index.jsx Прегледај датотеку

@@ -6,7 +6,7 @@ import './index.scss'
6 6
 
7 7
 export default function LivingActivity (props) {
8 8
   const { List = [] } = props
9
-  return (
9
+  return List.length > 0 ? (
10 10
     <view className='components LivingActivity'>
11 11
 
12 12
       <view className='Title flex-h'>
@@ -21,8 +21,8 @@ export default function LivingActivity (props) {
21 21
         {
22 22
           List.map((item, index) => (
23 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 26
               </view>
27 27
             </view>
28 28
           ))
@@ -30,5 +30,5 @@ export default function LivingActivity (props) {
30 30
       </view>
31 31
 
32 32
     </view>
33
-  )
33
+  ) : null
34 34
 }

+ 4
- 3
src/pages/index/buildingDetail/components/News/index.jsx Прегледај датотеку

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

+ 38
- 24
src/pages/index/buildingDetail/components/Periphery/index.jsx Прегледај датотеку

@@ -1,5 +1,5 @@
1 1
 
2
-import { useEffect, useMemo, useState } from 'react'
2
+import { useCallback, useContext, useEffect, useMemo, useState } from 'react'
3 3
 import { Map, CoverView } from '@tarojs/components'
4 4
 import '@/assets/css/iconfont.css'
5 5
 import './index.scss'
@@ -21,6 +21,14 @@ export default function Periphery (props) {
21 21
 
22 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 32
   const CutTab = () => {
25 33
     return () => {
26 34
       
@@ -28,31 +36,37 @@ export default function Periphery (props) {
28 36
   }
29 37
 
30 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 64
   }, [Info, loc])
55 65
 
66
+  if (!Info?.coordinate) {
67
+    return null
68
+  }
69
+
56 70
   return (
57 71
     <view className='components Periphery'>
58 72
 
@@ -86,7 +100,7 @@ export default function Periphery (props) {
86 100
           poiTypes.map((item) => (
87 101
             <view className='flex-item' key={item.value} onClick={CutTab(item.value)}>
88 102
               <text className={item.class}></text>
89
-              <text>{item.label}(123)</text>
103
+              <text>{item.label}({countLen(item.value)})</text>
90 104
             </view>
91 105
           ))
92 106
         }

+ 19
- 3
src/pages/index/buildingDetail/components/Pictures/index.jsx Прегледај датотеку

@@ -1,10 +1,26 @@
1
-
2
-import '@/assets/css/iconfont.css'
1
+import Taro from '@tarojs/taro'
3 2
 import { ScrollView, Image } from '@tarojs/components'
3
+import { getImgURL } from '@/utils/image'
4
+import '@/assets/css/iconfont.css'
4 5
 import './index.scss'
6
+import { useMemo } from 'react'
5 7
 
6 8
 export default function Pictures (props) {
7 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 24
   return (
9 25
     <view className='components Pictures'>
10 26
 
@@ -18,7 +34,7 @@ export default function Pictures (props) {
18 34
         <ScrollView scroll-x>
19 35
           {
20 36
             List.map((item, index) => (
21
-              <view className='ListItem' key={`List-${index}`}>
37
+              <view className='ListItem' key={`List-${index}`} onClick={() => handlePreview(item)}>
22 38
                 <view className='Img'>
23 39
                   <Image mode='aspectFill' className='centerLabel' src={item.buildingImgList.length ? item.buildingImgList[0].url : null}></Image>
24 40
                 </view>

+ 2
- 2
src/pages/index/buildingDetail/components/PropertyConsultant/index.jsx Прегледај датотеку

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

+ 20
- 59
src/pages/index/buildingDetail/index.jsx Прегледај датотеку

@@ -20,52 +20,33 @@ import News from './components/News/index'
20 20
 import Pictures from './components/Pictures/index'
21 21
 
22 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 25
   const [DetailInfo, setDetailInfo] = useState({})
27 26
   const [ActivityList, setActivityList] = useState([])
28 27
   const [PictureList, setPictureList] = useState([])
29 28
   const [NewsList, setNewsList] = useState([])
30
-  const [LiveList, setLiveList] = useState([])
31 29
 
32 30
   const [IsPull, setPull] = useState(false)
33 31
   const [PullTimer, setPullTimer] = useState(null)
34 32
 
35 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 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 51
   const GetActivityList = () => { // 获取活动列表
71 52
     fetch({ url: `${API_ACTIVITY_GROUP}?buildingId=${props.router.params.id}`, method: 'get' }).then((res) => {
@@ -74,26 +55,6 @@ export default withLayout((props) => {
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 58
   const PageRefresh = () => { // 页面下拉刷新回调
98 59
     setPull(true)
99 60
   }
@@ -143,32 +104,32 @@ export default withLayout((props) => {
143 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 108
                   <PropertyConsultant List={DetailInfo?.consultants}></PropertyConsultant>
148 109
                 </view>
149 110
 
150 111
                 {/* 位置及周边 */}
151
-                <view className='Periphery'>
112
+                <view className='Periphery' style={{minHeight: 0}}>
152 113
                   <Periphery Info={DetailInfo}></Periphery>
153 114
                 </view>
154 115
 
155 116
                 {/* 户型介绍 */}
156
-                <view className='HouseTypeIntro'>
117
+                <view className='HouseTypeIntro' style={{minHeight: 0}}>
157 118
                   <HouseTypeIntro Info={DetailInfo?.buildingApartment}></HouseTypeIntro>
158 119
                 </view>
159 120
 
160 121
                 {/* 营销活动 */}
161
-                <view className='MarketingActivity' style={{ display: ActivityList.length ? 'block' : 'none' }}>
122
+                <view className='MarketingActivity' style={{minHeight: 0}}>
162 123
                   <MarketingActivity List={ActivityList}></MarketingActivity>
163 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 129
                 </view>
169 130
 
170 131
                 {/* 新鲜资讯 */}
171
-                <view className='News' style={{ display: NewsList.length ? 'block' : 'none' }}>
132
+                <view className='News' style={{minHeight: 0}}>
172 133
                   <News List={NewsList}></News>
173 134
                 </view>
174 135