import { useState, useEffect } from 'react' import Taro from '@tarojs/taro' import withLayout from '@/layout' import { ScrollView, Image } from '@tarojs/components' import { getCardList } from '@/services/card' import { getImgURL } from '@/utils/image' import '@/assets/css/iconfont.css' import './index.scss' export default withLayout((props) => { const { router } = props const { buldingId } = router.params const [List, setList] = useState([]) const [PageList, setPageList] = useState([]) const [ShowMore, setShowMore] = useState(false) useEffect(() => { if(List.length) { if(ShowMore) { setPageList([...List]) } else { setPageList(List.slice(0, 3)) } } }, [ShowMore, List]) const handleChat = (item) => { Taro.navigateTo({ url: `/pages/chat/chatDetail/index?friend=${item.id}` }) } const handleCall = (item) => { if (item.phone) { Taro.makePhoneCall({ phoneNumber: item.phone }) return } Taro.showToast({ title: '暂无联系电话', icon: 'none' }) } const gotoDetail = (item) => { Taro.navigateTo({ url: `/subpackages/pages/consultant/myHomepage/index?id=${item.id}` }) } useEffect(() => { if (!buldingId) { Taro.showToast({ title: '没有楼盘信息', icon: 'none', }) return } getCardList({ pageSize: 500, buildingId: buldingId }).then((res) => { const { records } = res || [] setList(records) }) }, [buldingId]) return ( 有任何买卖房屋的问题,欢迎随时咨询 { PageList.map((item, index) => ( gotoDetail(item)}> {item.name} {item.phone} handleChat(item)} > handleCall(item)} > {item.description || '暂无简介'} )) } { List.length > 3 && !ShowMore && { setShowMore(true) }}>查看更多置业顾问 } { !(List.length > 3 && !ShowMore) && 已经到底了~ } ) })