index.jsx 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. import { useState, useEffect } from 'react'
  2. import withLayout from '@/layout'
  3. import { ScrollView } from '@tarojs/components'
  4. import Disclaimer from '@/components/Disclaimer'
  5. import Poster from '@/components/Poster'
  6. import { fetch } from '@/utils/request'
  7. import { API_ITEMS_DETAIL } from '@/constants/api'
  8. import useParams from '@/utils/hooks/useParams'
  9. import useShare from '@/utils/hooks/useShare'
  10. import usePoster from '@/utils/hooks/usePoster'
  11. import { savePoint } from '@/services/common'
  12. import { addItemUv } from '@/services/item'
  13. import DetailBottom from './components/DetailBottom/index'
  14. import BuildingDetailBanner from './components/BuildingDetailBanner/index'
  15. import BasicInfo from './components/BasicInfo/index'
  16. import SpecialPriceHouse from './components/SpecialPriceHouse/index'
  17. import ProjectDynamic from './components/ProjectDynamic/index'
  18. import PropertyConsultant from './components/PropertyConsultant/index'
  19. import Periphery from './components/Periphery/index'
  20. import HouseTypeIntro from './components/HouseTypeIntro/index'
  21. import MarketingActivity from './components/MarketingActivity/index'
  22. import LivingActivity from './components/LivingActivity/index'
  23. import News from './components/News/index'
  24. import Pictures from './components/Pictures/index'
  25. import './index.scss'
  26. export default withLayout((props) => {
  27. const { router, person, shareContent, trackData, page, setNavigationBarTitle } = props
  28. const { id } = router.params
  29. const [showPoster, setShowPoster] = useState(false)
  30. const [DetailInfo, setDetailInfo] = useState({})
  31. const [PictureList, setPictureList] = useState([])
  32. // 本页面分享或者海报参数
  33. const paramsRef = useParams({id, buildingId: id, person, from: `${page.type}_share`})
  34. const fullTrackData = { ...trackData, buildingId: id }
  35. // 分享
  36. useShare({
  37. title: shareContent.shareContentTitle || DetailInfo?.buildingName,
  38. path: `${router.path}?${paramsRef.current}`,
  39. image: shareContent.shareContentImg,
  40. },
  41. fullTrackData,
  42. )
  43. useEffect(() => {
  44. if(trackData.eventType && DetailInfo.buildingId) {
  45. savePoint({
  46. ...trackData,
  47. event: 'detail',
  48. eventType: 'building',
  49. buildingId: id,
  50. targetType: 'building'
  51. })
  52. addItemUv(id)
  53. }
  54. }, [trackData, DetailInfo])
  55. // 海报
  56. const posterData = usePoster(person, DetailInfo?.poster, router, paramsRef)
  57. useEffect(() => {
  58. // 获取楼盘信息
  59. fetch({ url: `${API_ITEMS_DETAIL}/${id}`, spin: true }).then((res) => {
  60. setDetailInfo(res || {})
  61. setNavigationBarTitle(res?.buildingName)
  62. if (res?.buildingApartment) {
  63. const List = res.buildingApartment.filter(item => item.apartmentType === 'photo')
  64. setPictureList(List.filter(item => item.buildingImgList.length > 0))
  65. }
  66. }).catch((err) => {
  67. console.error(err)
  68. })
  69. }, [id])
  70. // 户型图
  71. const houseTypeImages = (DetailInfo?.buildingApartment || []).filter(x => x.apartmentType === 'apart')
  72. return (
  73. <view className='Page buildingDetail flex-v'>
  74. <view className='flex-item'>
  75. <view>
  76. <ScrollView scroll-y>
  77. <view className='PageContent'>
  78. {/* banner */}
  79. <view className='BannerContainer'>
  80. <view>
  81. <view>
  82. {
  83. !!DetailInfo.buildingName &&
  84. <BuildingDetailBanner Info={DetailInfo}></BuildingDetailBanner>
  85. }
  86. </view>
  87. </view>
  88. </view>
  89. {/* content */}
  90. <view className='DetailContent'>
  91. {/* 基本信息 */}
  92. <view className='BasicInfo'>
  93. <BasicInfo Info={DetailInfo} trackData={fullTrackData}></BasicInfo>
  94. </view>
  95. {/* 特价房源 */}
  96. {
  97. (DetailInfo?.specialRoomList || []).length > 0 &&
  98. <view className='SpecialPriceHouse' style={{minHeight: 0}}>
  99. <SpecialPriceHouse List={DetailInfo?.specialRoomList}></SpecialPriceHouse>
  100. </view>
  101. }
  102. {/* 项目动态 */}
  103. {
  104. (DetailInfo?.trendList || []).length > 0 &&
  105. <view className='ProjectDynamic' style={{minHeight: 0}}>
  106. <ProjectDynamic List={DetailInfo?.trendList}></ProjectDynamic>
  107. </view>
  108. }
  109. {/* 置业顾问 */}
  110. {
  111. (DetailInfo?.consultants || []).length > 0 &&
  112. <view className='PropertyConsultant' style={{minHeight: 0}}>
  113. <PropertyConsultant Info={DetailInfo}></PropertyConsultant>
  114. </view>
  115. }
  116. {/* 位置及周边 */}
  117. <view className='Periphery' style={{minHeight: 0}}>
  118. <Periphery Info={DetailInfo}></Periphery>
  119. </view>
  120. {/* 户型介绍 */}
  121. {
  122. (houseTypeImages.length || []) > 0 &&
  123. <view className='HouseTypeIntro' style={{minHeight: 0}}>
  124. <HouseTypeIntro Info={houseTypeImages}></HouseTypeIntro>
  125. </view>
  126. }
  127. {/* 营销活动 */}
  128. <view className='MarketingActivity' style={{minHeight: 0}}>
  129. <MarketingActivity Info={DetailInfo}></MarketingActivity>
  130. </view>
  131. {/* 直播活动 */}
  132. {
  133. (DetailInfo?.liveActivityList || []).length > 0 &&
  134. <view className='LivingActivity' style={{minHeight: 0}}>
  135. <LivingActivity Info={DetailInfo}></LivingActivity>
  136. </view>
  137. }
  138. {/* 新鲜资讯 */}
  139. <view className='News' style={{minHeight: 0}}>
  140. <News Info={DetailInfo}></News>
  141. </view>
  142. {/* 相册 */}
  143. {
  144. (PictureList || []).length > 0 &&
  145. <view className='Pictures'>
  146. <Pictures List={PictureList}></Pictures>
  147. </view>
  148. }
  149. {/* 免责声明 */}
  150. <Disclaimer />
  151. </view>
  152. </view>
  153. </ScrollView>
  154. </view>
  155. </view>
  156. <view className='PageBottom'>
  157. <DetailBottom Info={DetailInfo} onPoster={() => setShowPoster(true)}></DetailBottom>
  158. </view>
  159. <Poster
  160. show={showPoster}
  161. dataSource={posterData}
  162. onClose={() => setShowPoster(false)}
  163. onSuccess={() => setShowPoster(false)}
  164. />
  165. </view>
  166. )
  167. })