index.jsx 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import { useState, useEffect } from 'react'
  2. import Taro from '@tarojs/taro'
  3. import { useSelector } from 'react-redux'
  4. import { Image } from '@tarojs/components'
  5. import AuthRole from '@/components/auth/AuthRole'
  6. // import Poster from '@/components/Poster'
  7. import { queryActivityList } from '@/services/activity'
  8. import { ROLE_CODE } from '@/constants/user'
  9. import './index.scss'
  10. export default function DetailBottom (props) {
  11. const { Info = {}, onPoster } = props
  12. // 当前推荐置业
  13. const { consultant } = useSelector(s => s.system)
  14. // const [showPoster, setShowPoster] = useState(false)
  15. const [actList, setActList] = useState([])
  16. const handleCall = () => {
  17. if (Info.tel) {
  18. Taro.makePhoneCall({ phoneNumber: Info.tel })
  19. return
  20. }
  21. Taro.showToast({ title: '暂无联系电话', icon: 'none' })
  22. }
  23. const handleChat = () => {
  24. // TODO 订阅消息
  25. if (consultant?.id) {
  26. Taro.navigateTo({
  27. url: `/pages/chat/detail?targetPerson=${consultant.id}}`
  28. })
  29. } else {
  30. Taro.navigateTo({
  31. url: `/pages/index/buildingPropertyConsultant/index?buldingId=${Info?.buildingId}`
  32. })
  33. }
  34. }
  35. const handleRecommender = () => {
  36. const params = `buildingId=${Info?.buildingId}&buildingName=${Info?.buildingName}`
  37. Taro.navigateTo({
  38. url: `/pages/mine/recommendUser/index?${params}`
  39. })
  40. }
  41. const handleTuanfang = () => {
  42. const id = actList[0].dynamicId
  43. Taro.navigateTo({
  44. url: `/pages/index/activityDetail/index?id=${id}`
  45. })
  46. }
  47. useEffect(() => {
  48. if (Info.buildingId) {
  49. // 请求看房活动
  50. queryActivityList({ buildingId: Info.buildingId, pageSize: 1, type: 'look' }).then((res) => {
  51. const { list } = res || {}
  52. // 只保留已发布的活动
  53. setActList((list || []))
  54. })
  55. }
  56. }, [Info.buildingId])
  57. return (
  58. <view>
  59. <view className='components DetailBottom flex-h'>
  60. <view className='flex-item'>
  61. <view className='Item' onClick={onPoster}>
  62. <Image mode='heightFix' src={require('@/assets/buildingDetail-icon3.png')}></Image>
  63. <text>一键海报</text>
  64. </view>
  65. {
  66. actList.length > 0 && (
  67. <view className='Item' onClick={handleTuanfang}>
  68. <Image mode='heightFix' src={require('@/assets/buildingDetail-icon1.png')}></Image>
  69. <text>一键带看</text>
  70. </view>
  71. )
  72. }
  73. <AuthRole role={ROLE_CODE.CONSULTANT}>
  74. <view className='Item' onClick={handleRecommender}>
  75. <Image mode='heightFix' src={require('@/assets/buildingDetail-icon2.png')}></Image>
  76. <text>一键推荐</text>
  77. </view>
  78. <view className='Item'>
  79. <Image mode='heightFix' src={require('@/assets/buildingDetail-icon1.png')}></Image>
  80. <text>一键带看</text>
  81. </view>
  82. <AuthRole role={ROLE_CODE.CONSULTANT}>
  83. <view className='Item' onClick={handleRecommender}>
  84. <Image mode='heightFix' src={require('@/assets/buildingDetail-icon2.png')}></Image>
  85. <text>一键推荐</text>
  86. </view>
  87. </AuthRole>
  88. </AuthRole>
  89. </view>
  90. <view className='Btn'>
  91. <text onClick={handleChat}>一键咨询</text>
  92. <text className='active' onClick={handleCall}>一键电话</text>
  93. </view>
  94. </view>
  95. {/* <Poster
  96. show={showPoster}
  97. dataSource={poster}
  98. onClose={() => setShowPoster(false)}
  99. onSuccess={() => setShowPoster(false)}
  100. /> */}
  101. </view>
  102. )
  103. }