index.jsx 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import { useState, useEffect } from 'react'
  2. import Taro from '@tarojs/taro'
  3. import withLayout from '@/layout'
  4. import { ScrollView, Image } from '@tarojs/components'
  5. import { getCardList } from '@/services/card'
  6. import { getImgURL } from '@/utils/image'
  7. import '@/assets/css/iconfont.css'
  8. import './index.scss'
  9. export default withLayout((props) => {
  10. const { router } = props
  11. const { buldingId } = router.params
  12. const [List, setList] = useState([])
  13. const [PageList, setPageList] = useState([])
  14. const [ShowMore, setShowMore] = useState(false)
  15. useEffect(() => {
  16. if(List.length) {
  17. if(ShowMore) {
  18. setPageList([...List])
  19. } else {
  20. setPageList(List.slice(0, 3))
  21. }
  22. }
  23. }, [ShowMore, List])
  24. const handleChat = (item) => {
  25. Taro.navigateTo({
  26. url: `/pages/chat/chatDetail/index?friend=${item.id}`
  27. })
  28. }
  29. const handleCall = (item) => {
  30. if (item.phone) {
  31. Taro.makePhoneCall({ phoneNumber: item.phone })
  32. return
  33. }
  34. Taro.showToast({ title: '暂无联系电话', icon: 'none' })
  35. }
  36. const gotoDetail = (item) => {
  37. Taro.navigateTo({
  38. url: `/subpackages/pages/consultant/myHomepage/index?id=${item.id}`
  39. })
  40. }
  41. useEffect(() => {
  42. if (!buldingId) {
  43. Taro.showToast({
  44. title: '没有楼盘信息',
  45. icon: 'none',
  46. })
  47. return
  48. }
  49. getCardList({ pageSize: 500, buildingId: buldingId }).then((res) => {
  50. const { records } = res || []
  51. setList(records)
  52. })
  53. }, [buldingId])
  54. return (
  55. <view className='Page buildingPropertyConsultant'>
  56. <ScrollView scroll-y>
  57. <text className='TopTips'>有任何买卖房屋的问题,欢迎随时咨询</text>
  58. <view className='List'>
  59. {
  60. PageList.map((item, index) => (
  61. <view key={`ListItem-${index}`}>
  62. <view className='flex-h'>
  63. <view className='Icon'>
  64. <Image mode='scaleToFill' src={getImgURL(item.photo || item.avatar)}></Image>
  65. </view>
  66. <view className='flex-item' onClick={() => gotoDetail(item)}>
  67. <view className='Name'>
  68. <text>{item.name}</text>
  69. <Image mode='heightFix' src={require('@/assets/index-icon17.png')}></Image>
  70. </view>
  71. <text>{item.phone}</text>
  72. </view>
  73. <text
  74. className='iconfont icon-liaotian'
  75. onClick={() => handleChat(item)}
  76. ></text>
  77. <text
  78. className='iconfont icon-dianhua'
  79. onClick={() => handleCall(item)}
  80. ></text>
  81. </view>
  82. <view className='Desc'>
  83. <text>{item.description || '暂无简介'}</text>
  84. </view>
  85. </view>
  86. ))
  87. }
  88. {
  89. List.length > 3 && !ShowMore &&
  90. <view className='More'>
  91. <text onClick={() => { setShowMore(true) }}>查看更多置业顾问</text>
  92. </view>
  93. }
  94. {
  95. !(List.length > 3 && !ShowMore) &&
  96. <text className='BottomTips'>已经到底了~</text>
  97. }
  98. </view>
  99. </ScrollView>
  100. </view>
  101. )
  102. })