index.jsx 6.1KB

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