import { View, Image, Text } from "@tarojs/components";
import { transferImage } from '@/utils/tools'
import dayjs from 'dayjs'

import './index.scss'

export default function RaiseHouse(props) {
  const {
    buildingName,
    termname,
    blockName,
    unitName,
    roomName,
    price,
    createDate,
    buildingImgList = [],
  } = props.summary || {}

  const title = `${buildingName} ${termname||''} ${blockName} ${unitName} ${roomName}`
  const thumb = (buildingImgList || []).length
  const showDT = dayjs(createDate).format('YYYY/MM/DD')
  const wanY = Number(price)

  return (
    <View className="raisehouse">
      <View className="head">
        {thumb ? <Image className="thumb" src={transferImage((buildingImgList)[0].url)} mode="aspectFit" /> :
          <Text style="font-size:26rpx;color:#666">暂无户型图</Text>
        }
      </View>
      <View className="body">
        <View className="apartment">A户型</View>
        <View className="price">现价234万</View>
        <View className="title">XX嘉苑 1号楼 2单元 3楼 303号</View>
        <View className="subtitle">
          <Text>建筑面积约</Text>
          <Text className="red">{wanY + 'm²' || '待定'}</Text>
        </View>
        <View className="subtitle">
          <Text>使用面积约</Text>
          <Text className="red">{wanY + 'm²' || '待定'}</Text>
        </View>
      </View>
    </View>
  )
}
