import { useEffect, useState } from 'react' import Taro from '@tarojs/taro' import withLayout from '@/layout' import { ScrollView, Image } from '@tarojs/components' import Disclaimer from '@/components/Disclaimer' import { getImgURL } from '@/utils/image' import { formateLeftTime } from '@/utils/tools' import { fetch } from '@/utils/request' import { API_SPECIAL_ROOM_LIST } from '@/constants/api' import '@/assets/css/iconfont.css' import './index.scss' const defaultRuleImage = 'https://yz-websit.oss-cn-hangzhou.aliyuncs.com/xlk/index-icon19.jpg' export default withLayout((props) => { const { city } = props const [PageList, setPageList] = useState([]) const [IsPull, setPull] = useState(false) const [pageNumber, setPageNumber] = useState(1) const [HasNextPage, setHasNextPage] = useState(true) useEffect(() => { GetPageList() }, [pageNumber]) const PageRefresh = () => { // 页面下拉刷新回调 setPull(true) } const GetPageList = () => { setHasNextPage(false) fetch({ url: API_SPECIAL_ROOM_LIST, method: 'get', payload: { pageNumber, pageSize: 10, cityId: city?.id } }).then((res) => { setPageList(pageNumber === 1 ? res.records || [] : PageList.concat(res.records || [])) setHasNextPage(res.current < res.pages) setPull(false) }) } const PageLoadMore = () => { // 页面上拉加载更多 if (HasNextPage) { setPageNumber(pageNumber + 1) } } useEffect(() => { // 下拉刷新触发 if (IsPull) { if (pageNumber === 1) { GetPageList() } else { setPageNumber(1) } } }, [IsPull]) const goto = (it) => { Taro.navigateTo({ url: `/pages/index/buildingDetail/index?id=${it.buildingId}` }) } return ( {/* 主图 */} {/* 列表 */} { PageList.map((item, index) => { const mainImg = getImgURL(item?.buildingListImg?.length ? item.buildingListImg[0].url : null) const price = item.price || '价格待定' const shareNum = item.shareList?.total || 0 const uvNum = item.uvList?.length || 0 // 最多6个 const tags = (item.buildingTag || []).map(x => x.tagName).slice(0, 6) // const specialRoomList = item.specialRoomList || [] return ( {index + 1 > 9 ? index + 1 : `0${index + 1}`} goto(item)}> { item.panoramaList.length > 0 && } { item.videoUrl !== null && } goto(item)}> {item.buildingName} {price} goto(item)}>{item.address} goto(item)}> { tags.map((x) => ({x})) } goto(item)}> {`${shareNum} 次分享`} { uvNum > 0 && ( { item.uvList.map((x) => ( )) } ) } {`...${uvNum}人围观`} { specialRoomList.map((it) => { const unitPrice = it.area ? it.currentPrice / it.area : undefined const unitW = unitPrice ? `${Number(unitPrice).toFixed(0)}/㎡` : '单价待定' const currentW = it.currentPrice ? `${Number(it.currentPrice / 10000).toFixed(1)}万` : '待定' const originalW = it.originalPrice ? `${Number(it.originalPrice / 10000).toFixed(1)}万` : '待定' const thriftW = it.thriftPrice ? `省${Number(it.thriftPrice / 10000).toFixed(1)}万` : '待定' const leftTime = formateLeftTime(new Date(it.endTime) - new Date(), 'min'); return ( {thriftW} {currentW} {originalW} {`距结束 ${leftTime}`} {`${it.unitType} ${unitW}`} {it.roomName} ) }) } ) }) } {/* 免责声明   以上价格仅供参考,具体一房一价的信息以售楼处展示为准。房屋位置交通、医疗、教育、商业等配套信息,来源于第三方不作为要约,仅供参考,双方具体权利义务应以法律规定及买卖合同约定为准。本平台对项目周边文化教育的介绍旨在提供相关信息1 意味着信息发布方对就学安排作出承诺。相关教育资首页信息存在调整的可能,应以政府教育主管部门门及办学颁布的政策规定为准。详情请仔细阅读 《新联康使用免责条款》 */} ) })