Files
gterFang/src/components/public/apartment-item.vue
2025-08-20 15:23:09 +08:00

566 lines
17 KiB
Vue

<template>
<div class="item flexflex" @click="goapArtmentDetails">
<div class="collect-box flexcenter" @click.stop="handleCollect1(item.uniqid)">
<img class="collect-icon" v-if="item.iscollect == 0" src="@/assets/img/publicImage/collect-icon.svg" />
<img class="collect-icon" v-else src="@/assets/img/publicImage/collect-pitch-icon.svg" />
<!-- <img v-if="item.iscollect == 0" class="collect-icon" src="@/assets/img/apartmentDetail/collect.jpg" /> -->
<!-- <img v-else class="collect-icon" src="@/assets/img/apartmentDetail/collect-star.jpg" /> -->
</div>
<div class="img-box">
<img v-if="item.selection" class="gter-select" src="@/assets/img/publicImage/gter-select.png" />
<div class="name flexflex">{{ item.title }}</div>
<img class="img" v-lazy="item['image']" @load="loadload" />
<div class="apartment-introduce flexacenter">
<template v-if="item.comment.content">
<div class="remark-on flexacenter">
<img class="fang-icon" :src="item.comment.avatar" />
{{ item.comment.type }}
</div>
<div class="remark-text flex1 ellipsis">{{ item.comment.content }}</div>
</template>
<template v-else>
<div class="apartment-tag flexcenter" v-if="item.company">{{ item.company }}</div>
<div class="flex1 ellipsis">{{ item.propaganda }}</div>
</template>
</div>
</div>
<div class="label-list flexacenter">
<div class="label-item flexacenter blue" v-if="item.fieldtrips == 1">
<img class="safety-icon" src="@/assets/img/publicImage/safety-icon.png" />
实地考察
</div>
<div class="label-item flexacenter violet">0服务费</div>
<div class="label-item flexacenter red" v-for="(item, index) in item.hottags" :key="index">{{ item }}</div>
<template v-if="item.tags">
<div class="label-item flexacenter" v-for="(item, index) in item.tags.split(',')" :key="index">{{ item
}}</div>
</template>
</div>
<!-- <div class="title">{{ item["title"] }}</div>
<div class="hint">{{ item["propaganda"] }}</div>
<div class="tab-box flexflex" v-if="item['tags']">
<div class="tab-item flexcenter" v-for="(it, index) in item['tags'].split(',')" :key="index">{{ it }}</div>
</div> -->
<div class="location flexacenter" v-if="item['address']">
<img class="location-icon" src="@/assets/img/publicImage/location-icon.png" />
<div class="ellipsis">{{ item["address"] }}</div>
</div>
<div class="distance flexflex">
<div class="figure flexflex" v-if="item.distance?.alias">
距离
<div class="school">{{ item.distance.alias }}</div>
<div class="mile" v-if="item.distance.distance > 0">{{ item.distance.distance }}km</div>
</div>
<div class="vehicle-list flex1 flexflex" v-if="distanceArr.length > 0">
<div class="vehicle-item flexacenter" v-for="(item, index) in distanceArr" :key="index">{{ item.text + item.duration }}</div>
<!-- <div class="vehicle-item flexacenter" v-if="item.distance?.walking_duration > 0">
步行{{ calculateDuration(item.distance.walking_duration) }}
</div>
<div class="vehicle-item flexacenter" v-if="item.distance?.driving_duration > 0">
地铁{{ calculateDuration(item.distance.driving_duration) }}
</div>
<div class="vehicle-item flexacenter" v-if="item.distance?.transit_duration > 0">
巴士{{ calculateDuration(item.distance.transit_duration) }}
</div> -->
</div>
</div>
<div class="collect-type flexacenter">
<div class="collect flexacenter flex1">
<img class="flame-icon" src="@/assets/img/publicImage/flame-icon.png" />
近15天{{ item.viewnum }}人感兴趣
</div>
<div class="house-type flexacenter">
{{ item.roomnum || 0 }}个房型
<img class="icon" src="@/assets/img/publicImage/arrow-return.svg" />
</div>
</div>
<div class="type-list" v-if="item['roomlist']">
<div class="type-item flexacenter" v-for="(it, index) in item['roomlist']" :key="index">
<div class="type-name flex1 ellipsis">{{ it["name"] }}</div>
<div class="price flexflex">
<div class="type-data flexacenter">
<div class="unit">HK$</div>
<div class="price">{{ it.discountprice || it.price }}</div>
/
</div>
<div class="original-price" v-if="it.discountprice">HK${{ it.price }}/</div>
</div>
</div>
</div>
<!-- <div class="type-quantity flexacenter">
<div class="type-quantity-number">{{ item["roomnum"] }}</div>
个房型
<img class="black-arrow" src="@/assets/img/publicImage/black-arrow.svg" />
</div> -->
</div>
</template>
<script setup>
import { ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import { redirectToExternalWebsite, calculateDuration, calculateDistance } from "@/utils/util.js";
const router = useRouter();
const props = defineProps({
item: Object,
pitchValue: Object,
masonryInstance: Object,
});
let distanceArr = ref([])
// 监听 item 变化
watch(
() => props.item,
(newItem) => {
const keyobj = {
metrobus_duration: "地铁巴士",
walking_duration: "步行",
driving_duration: "地铁",
transit_duration: "巴士",
}
const arr = ["metrobus_duration", "walking_duration", "transit_duration", "driving_duration"]
const distance = newItem.distance || {}
let valueArr = []
arr.forEach(key => {
if (distance[key] > 0) {
const value = distance[key]
valueArr.push({
text: keyobj[key],
value,
duration: calculateDuration(value),
})
}
})
distanceArr.value = valueArr.sort((a, b) => Number(a.value) - Number(b.value)).slice(0, 3);
},
{
immediate: true, // 初始化时立即执行一次
deep: true // 如果需要监听 item 内部属性的深层变化
}
);
const emit = defineEmits(["handlecollect"]);
const goapArtmentDetails = () => {
let url = `/apartmentDetail?uniqid=${props["item"].uniqid}`;
if (props?.pitchValue?.school) url += `&school=${props.pitchValue["school"]}`;
redirectToExternalWebsite(url);
};
// 点击收藏后传过父组件
const handleCollect1 = (uniqid) => emit("handlecollect", uniqid);
const loadload = () => {
props.masonryInstance && props.masonryInstance.reloadItems();
props.masonryInstance && props.masonryInstance.layout();
};
</script>
<style lang="less" scoped>
.item {
width: 385px;
// width: 288.75px;
background-color: rgba(255, 255, 255, 1);
// border-radius: 20px;
border-radius: 24px;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.156862745098039);
flex-direction: column;
padding-top: 7px;
padding-bottom: 16px;
margin-bottom: 20px;
position: relative;
height: fit-content;
cursor: pointer;
&:hover {
-moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.256862745098039);
-webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.256862745098039);
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.256862745098039);
}
.collect-box {
width: 24px;
height: 24px;
border-radius: 50%;
position: absolute;
top: 10px;
right: 10px;
z-index: 1;
cursor: pointer;
background-color: rgba(0, 0, 0, 0.4);
.collect-icon {
width: 16px;
height: 15px;
}
}
.img-box {
position: relative;
border-radius: 16px;
overflow: hidden;
margin: 0 7px 16px;
.gter-select {
position: absolute;
top: 0;
left: 0;
width: 158px;
height: 24px;
}
.name {
height: 32px;
background-color: rgba(255, 255, 255, 0.847058823529412);
border: 1px solid rgba(255, 255, 255, 1);
border-radius: 16px;
font-family: "PingFangSC-Semibold", "PingFang SC Semibold", "PingFang SC", sans-serif;
font-weight: 650;
font-style: normal;
font-size: 20px;
color: #000000;
padding: 0 25px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: max-content;
}
.img {
// width: 366px;
// width: 268.75px;
width: 371px;
// height: 244px;
// object-fit: cover;
display: block;
}
.apartment-introduce {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 30px;
background-color: rgba(0, 0, 0, 0.63921568627451);
color: #ffffff;
font-size: 13px;
padding-left: 6px;
padding-right: 17px;
.remark-on {
font-size: 13px;
color: #d7d7d7;
margin-right: 6px;
.fang-icon {
width: 20px;
height: 20px;
border-radius: 50%;
margin-right: 6px;
}
}
.remark-text {
width: 247px;
}
.apartment-tag {
padding: 0 8px;
border-radius: 6px;
border: 1px solid #797979;
margin-right: 8px;
color: #fdda55;
}
}
}
.label-list {
flex-wrap: wrap;
margin: 0 12px 7px;
.label-item {
color: #434343;
text-align: center;
height: 22px;
background-color: #eeeeee;
border-radius: 8px;
padding: 0 8px;
font-size: 13px;
width: fit-content;
margin-bottom: 8px;
margin-right: 10px;
&.blue {
color: #ffffff;
background-color: rgba(98, 177, 255, 1);
}
&.violet {
color: #ffffff;
background-color: rgba(128, 128, 255, 1);
}
&.red {
color: #ffffff;
background-color: rgba(249, 93, 93, 1);
}
.safety-icon {
width: 14px;
height: 14px;
margin-right: 5px;
}
}
}
.title {
font-weight: 650;
font-size: 17px;
color: #000000;
margin-bottom: 5px;
padding-left: 6px;
word-break: break-all;
}
.hint {
color: #aaaaaa;
font-size: 14px;
margin: 0 6px 8px;
word-break: break-all;
}
.tab-box {
flex-wrap: wrap;
margin-bottom: 4px;
padding-left: 6px;
.tab-item {
// height: 28px;
line-height: 24px;
background-color: rgba(224, 240, 255, 1);
border-radius: 5px;
font-family: "PingFangSC-Regular", "PingFang SC", sans-serif;
font-weight: 400;
font-size: 13px;
color: #447eb3;
padding: 0 8px;
margin-right: 6px;
margin-bottom: 6px;
word-break: break-word;
}
}
.location {
.location-icon {
width: 18px;
height: 18px;
margin-right: 2px;
}
font-size: 14px;
color: #555555;
margin: 0 12px 9px;
// margin-bottom: 9px;
// padding-left: 6px;
}
.distance {
padding: 0 1px 12px 29px;
border-bottom: 1px dotted #d7d7d7;
.figure {
font-size: 14px;
color: #555555;
text-align: right;
line-height: 22px;
margin-right: 8px;
.school {
font-family: "Arial-BoldMT", "Arial Bold", "Arial", sans-serif;
font-weight: 700;
font-style: normal;
font-size: 14px;
color: #000000;
margin: 0 3px;
}
.mile {
font-size: 14px;
color: #34be9f;
}
}
.vehicle-list {
flex-wrap: wrap;
padding-right: 5px;
.vehicle-item {
height: 22px;
line-height: 22px;
background-color: rgba(255, 255, 255, 0);
border: 1px solid rgba(127, 127, 127, 1);
border-radius: 30px;
font-size: 12px;
color: #333333;
padding: 0 6px;
margin-bottom: 5px;
&:not(:last-of-type) {
margin-right: 6px;
}
.vehicle-icon {
width: 14px;
height: 14px;
margin-right: 5px;
}
}
}
}
.collect-type {
margin: 0 12px;
height: 52px;
.collect {
.flame-icon {
width: 20px;
height: 20px;
margin-right: 7px;
}
font-size: 13px;
color: #555555;
}
.house-type {
font-size: 13px;
color: #555555;
.icon {
width: 12px;
height: 12px;
margin-left: 5px;
}
}
}
.type-list {
// width: 354px;
// height: 108px;
background: rgba(246, 246, 246, 1);
border-radius: 12px;
padding: 0 10px;
margin: 0 12px;
.type-item {
height: 54px;
&:not(:last-of-type) {
border-bottom: 1px solid #ebebeb;
}
.type-name {
color: #000000;
font-size: 14px;
padding-right: 15px;
}
.price {
flex-direction: column;
align-items: flex-end;
.type-data {
.unit {
font-family: "Arial-Black", "Arial Black", sans-serif;
font-weight: 900;
color: #000000;
}
.price {
font-family: "Arial-Black", "Arial Black", sans-serif;
font-weight: 900;
font-size: 18px;
color: #f95d5d;
margin: 0 5px;
}
font-size: 13px;
color: #555555;
}
.original-price {
text-align: right;
font-size: 13px;
color: #7f7f7f;
position: relative;
width: max-content;
&::after {
position: absolute;
top: 50%;
left: -4px;
transform: translateY(-50%);
content: "";
width: calc(100% + 6px);
height: 1px;
display: block;
border-bottom: 1px solid #000;
}
}
}
}
}
.type-quantity {
font-size: 14px;
color: #555555;
margin: 22px auto;
.type-quantity-number {
font-weight: 650;
font-size: 14px;
color: #000000;
// height: 18px;
line-height: 18px;
background-color: rgba(253, 223, 109, 1);
border-radius: 9px;
padding: 0 8px;
margin: 0 8px;
}
.black-arrow {
width: 7px;
height: 12px;
margin-left: 8px;
}
}
}
.area-distance {
margin-left: 16px;
color: #50e3c2;
position: relative;
&::after {
content: "|";
position: absolute;
left: -8px;
color: #d7d7d7;
}
}
</style>