refactor(组件): 移除冗余代码并优化样式和功能

移除`imageWatch.vue`中的冗余变量`index`,优化`apartmentDetail.css`和`apartmentDetail.less`中的样式,增加`cursor: pointer`和`align-items: flex-start`等属性。在`user.vue`中移除调试日志并优化数据处理逻辑。在`apartment-item.vue`中恢复并优化点评展示功能。在`apartmentDetail.vue`中重构点评展示逻辑,增加点评类型切换功能,并优化数据加载和展示逻辑。
This commit is contained in:
DESKTOP-RQ919RC\Pc
2025-05-19 19:00:09 +08:00
parent fbb5a6599d
commit 173e05c13a
6 changed files with 156 additions and 53 deletions

View File

@@ -550,6 +550,7 @@
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.11764706); box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.11764706);
padding: 24px 30px 28px; padding: 24px 30px 28px;
margin-bottom: 20px; margin-bottom: 20px;
cursor: pointer;
} }
.content .details-box .details-left .remark .head { .content .details-box .details-left .remark .head {
justify-content: space-between; justify-content: space-between;
@@ -604,6 +605,7 @@
background-color: #f6f6f6; background-color: #f6f6f6;
border-radius: 8px; border-radius: 8px;
padding-left: 20px; padding-left: 20px;
align-items: flex-start;
} }
.content .details-box .details-left .remark .inspect .left { .content .details-box .details-left .remark .inspect .left {
padding: 18px 0; padding: 18px 0;
@@ -626,6 +628,7 @@
color: #50e3c2; color: #50e3c2;
font-size: 13px; font-size: 13px;
height: 20px; height: 20px;
line-height: 20px;
background-color: rgba(246, 246, 246, 0); background-color: rgba(246, 246, 246, 0);
border: 1px solid #50e3c2; border: 1px solid #50e3c2;
border-radius: 30px; border-radius: 30px;

View File

@@ -709,6 +709,7 @@
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.117647058823529); box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.117647058823529);
padding: 24px 30px 28px; padding: 24px 30px 28px;
margin-bottom: 20px; margin-bottom: 20px;
cursor: pointer;
.head { .head {
justify-content: space-between; justify-content: space-between;
@@ -773,6 +774,7 @@
background-color: rgba(246, 246, 246, 1); background-color: rgba(246, 246, 246, 1);
border-radius: 8px; border-radius: 8px;
padding-left: 20px; padding-left: 20px;
align-items: flex-start;
.left { .left {
padding: 18px 0; padding: 18px 0;
@@ -801,6 +803,7 @@
color: #50e3c2; color: #50e3c2;
font-size: 13px; font-size: 13px;
height: 20px; height: 20px;
line-height: 20px;
background-color: rgba(246, 246, 246, 0); background-color: rgba(246, 246, 246, 0);
border: 1px solid rgba(80, 227, 194, 1); border: 1px solid rgba(80, 227, 194, 1);
border-radius: 30px; border-radius: 30px;

View File

@@ -20,7 +20,6 @@
<img src="../../assets/img/detail/imageArrowIcon.svg" class="image-arrow-icon left-arrow" @click="prev" alt="" /> <img src="../../assets/img/detail/imageArrowIcon.svg" class="image-arrow-icon left-arrow" @click="prev" alt="" />
<img src="../../assets/img/detail/imageArrowIcon.svg" class="image-arrow-icon right-arrow" @click="next" alt="" /> <img src="../../assets/img/detail/imageArrowIcon.svg" class="image-arrow-icon right-arrow" @click="next" alt="" />
</div> </div>
{{ index }}
<div class="tab-text">{{ `${imageTab + 1}/${list.length}` }}</div> <div class="tab-text">{{ `${imageTab + 1}/${list.length}` }}</div>
<div class="dis-f jus-x al-item"> <div class="dis-f jus-x al-item">
<div class="list-img-box dis-f al-item jus-x"> <div class="list-img-box dis-f al-item jus-x">

View File

@@ -10,13 +10,13 @@
<img v-if="item.selection" class="gter-select" src="@/assets/img/publicImage/gter-select.png" /> <img v-if="item.selection" class="gter-select" src="@/assets/img/publicImage/gter-select.png" />
<div class="name flexflex">{{ item.title }}</div> <div class="name flexflex">{{ item.title }}</div>
<img class="img" v-lazy="item['image']" @load="loadload" /> <img class="img" v-lazy="item['image']" @load="loadload" />
<!-- <div class="apartment-introduce flexacenter"> <div class="apartment-introduce flexacenter" v-if="item.comment.content">
<div class="remark-on flexacenter"> <div class="remark-on flexacenter">
<img class="fang-icon" src="https://oss.x-php.com/Zvt57TuJSUvkyhw-xG7Y2l-d_Zwocn3qqsgFptxhcq_cQnrld6YjDgwVBq_D-81qNDQyOQ~~" /> <img class="fang-icon" :src="item.comment.avatar" />
方同学点评 {{ item.comment.type }}
</div> </div>
<div class="remark-text flex1 ellipsis">交通和生活都非常便利房间整洁完善交通和生活都非常便利房间整洁完善交通和生活都非常便利房间整洁完善</div> <div class="remark-text flex1 ellipsis">{{ item.comment.content }}</div>
</div> --> </div>
</div> </div>
<div class="label-list flexacenter"> <div class="label-list flexacenter">
<div class="label-item flexacenter blue"> <div class="label-item flexacenter blue">

View File

@@ -161,45 +161,47 @@
<img class="bottom-orange" src="@/assets/img/publicImage/special-bottom-orange.svg" /> <img class="bottom-orange" src="@/assets/img/publicImage/special-bottom-orange.svg" />
</div> </div>
<div class="remark" ref="inspectEle"> <div class="remark" ref="inspectEle" v-if="spotSum > 0" @click="openInspectPop">
<div class="head flexacenter"> <div class="head flexacenter">
<div class="text">寄托实地考察</div> <div class="text">寄托实地考察</div>
<div class="more flexacenter"> <div class="more flexacenter">
2 {{ spotSum }}
<img class="icon" src="@/assets/img/publicImage/arrow-black-down.svg" /> <img class="icon" src="@/assets/img/publicImage/arrow-black-down.svg" />
</div> </div>
</div> </div>
<div class="inspect flexacenter"> <div class="inspect flexacenter">
<div class="left flex1"> <div class="left flex1">
<div class="info flexacenter"> <div class="info flexacenter">
<img class="avatar" src="https://oss.x-php.com/avatar/97K4EWIMLrsbGTWXslC2WlhUEKSOikN42jDKLNjtax7HJY5hLpXaSdU90AVyYWFjYQ~~/mini" /> <img class="avatar" :src="spotObj.avatar" />
<div class="username">寄托方同学</div> <div class="username">{{ spotObj.nickname }}</div>
<img class="label" src="https://oss.x-php.com/Zvt57TuJSUvkyhw-xG7Y2l-c_ZMtdH_qqsgFptxhcq_cQnrlcfAgCgwSBq_D-81qNDQyOQ~~" /> <img class="label" :src="spotObj.groupimage" />
</div> </div>
<div class="explain two-line-text">交通和生活都非常便利交通和生活都非常便利交通和生活都非常便利房间整洁完善拎包入住没问题周围五百米内超市</div> <div class="explain two-line-text">{{ spotObj.content }}</div>
</div> </div>
<img class="inspect-img" src="https://oss.x-php.com/Zvt57TuJSUvkyhw-xG7Y2l-S-5MvfHrqqsgFptxhXa6QWi2uePJ5Bg8cFLPIqoYV7MsPC27D4Fz_-kU8uRQ0NDI5" /> <img class="inspect-img" :src="spotObj.sources[0].thumbnail" />
</div> </div>
</div> </div>
<div class="remark" ref="followEle"> <div class="remark" ref="followEle" v-if="returnSum > 0" @click="openInspectPop">
<div class="head flexacenter"> <div class="head flexacenter">
<div class="text">寄托回访</div> <div class="text">寄托回访</div>
<div class="more flexacenter"> <div class="more flexacenter">
3 {{ returnSum }}
<img class="icon" src="@/assets/img/publicImage/arrow-black-down.svg" /> <img class="icon" src="@/assets/img/publicImage/arrow-black-down.svg" />
</div> </div>
</div> </div>
<div class="return-visit flexacenter" scroll-x> <div class="return-visit flexacenter" scroll-x>
<div class="item flex1" v-for="(item, index) in 2" :key="index"> <template v-for="(item, index) in remarkList" :key="index">
<div class="info flexacenter"> <div class="item flex1" v-if="item.typeid == 2">
<img class="avatar" src="https://oss.x-php.com/avatar/97K4EWIMLrsbGTWXslC2WlhUEKSOikN42jDKLNjtax7HJY5hLpXaSdU90AVyYWFjYQ~~/mini" /> <div class="info flexacenter">
<div class="username">寄托方同学</div> <img class="avatar" :src="item.avatar" />
<div class="label flexacenter">已入住</div> <div class="username">{{ item.nickname }}</div>
<div class="label flexacenter">已入住</div>
</div>
<div class="explain two-line-text">{{ item.content }}</div>
</div> </div>
<div class="explain two-line-text">交通和生活都非常便利交通和生活都非常便利交通和生活都非常便利房间整洁完善拎包入住没问题周围五百米内超市</div> </template>
</div>
</div> </div>
</div> </div>
@@ -620,35 +622,40 @@
<img src="@/assets/img/detail/close.png" class="close-icon" @click="isSelectSchool = false" /> <img src="@/assets/img/detail/close.png" class="close-icon" @click="isSelectSchool = false" />
</div> --> </div> -->
<div class="type flexacenter"> <div class="type flexacenter">
<div class="item pitch">全部 4</div> <div class="item" :class="{ pitch: remarkTypeid == 0 }" @click="cutRemarkType(0)">全部 {{ spotSum + returnSum }}</div>
<div class="item">寄托实地考察 2</div> <div class="item" :class="{ pitch: remarkTypeid == 1 }" @click="cutRemarkType(1)">寄托实地考察 {{ spotSum }}</div>
<div class="item">寄托回访 2</div> <div class="item" :class="{ pitch: remarkTypeid == 2 }" @click="cutRemarkType(2)">寄托回访 {{ returnSum }}</div>
</div> </div>
<div class="list"> <div class="list">
<div class="item flexflex" v-for="(item, index) in 10" :key="index"> <template v-for="(item, index) in remarkList" :key="index">
<img class="avatar" src="https://oss.x-php.com/Zvt57TuJSUvkyhw-xG7Y2l-d_Zwocn3qqsgFptxhcq_cQnrld6YjDgwVBq_D-81qNDQyOQ~~" /> <div class="item flexflex" v-if="remarkTypeid == 0 || (remarkTypeid == 1 && item.typeid == 1) || (remarkTypeid == 2 && item.typeid == 2)">
<div class="remark-content flexflex flex1"> <img class="avatar" :src="item.avatar" />
<div class="type flexacenter"> <div class="remark-content flexflex flex1">
<img class="image" src="@/assets/img/publicImage/return-visit.png" /> <div class="type flexacenter" v-if="item.typeid == 1">
<img class="image" src="@/assets/img/publicImage/inspect-icon.png" /> <img class="image" src="@/assets/img/publicImage/inspect-icon.png" />
寄托实地考察 寄托实地考察
</div> </div>
<div class="username flexacenter"> <div class="type flexacenter" v-else>
寄托方同学 <img class="image" src="@/assets/img/publicImage/return-visit.png" />
<div class="checked-in">已入住</div> 寄托回访
<img class="image" src="" /> </div>
</div> <div class="username flexacenter">
<div class="date">2025.3.15</div> {{ item.nickname }}
<div class="text">交通和生活都非常便利房间整洁完善拎包入住没问题周围五百米内超市购物广场及娱乐设施应有尽有步行至地铁口仅需3分钟 所有房间都有大窗基本都朝南每个房间阳光都很充足窗外是公园所有房间可以看到绿树公园很开阔不压抑真是非常难得的窗景 客服小COCO24小时在线每日提供清洁服务妥妥的生活无忧</div> <div class="checked-in" v-if="item.typeid == 2">已入住</div>
<div class="media" scroll-x> <img class="image" v-if="item.groupimage" :src="item.groupimage" />
<div class="media-item" v-for="(item, index) in 10" :key="index"> </div>
<img class="media-img" src="https://oss.x-php.com/Zvt57TuJSUvkyhw-xG7Y2l-X9pkucH3qqsgFptxhcq_cQnrleqEnW1EdBq_D-81qNDQyOQ~~" /> <div class="date">{{ item.date }}</div>
<img class="media-icon" src="@/assets/img/publicImage/video-icon.svg" /> <div class="text">{{ item.content }}</div>
<div class="media" scroll-x>
<div class="media-item" v-for="(item, i) in item.sources" :key="i" @click="previewImg(index, i)">
<img class="media-img" :src="item.thumbnail" />
<img class="media-icon" v-if="item.type == 'videos'" src="@/assets/img/publicImage/video-icon.svg" />
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </template>
</div> </div>
</el-dialog> </el-dialog>
</template> </template>
@@ -907,11 +914,9 @@ const init = () => {
handleNavData(); handleNavData();
getFacilitiesHeight(); getFacilitiesHeight();
getDetailsHeight(); getDetailsHeight();
getLikeList(); getLikeList();
getMapDistance(); getMapDistance();
getComment();
if (!data.info.promotionalactivities) navTab.value = "inspectEle";
}); });
if (data.withsameapartments > 0) dualBrandData(); if (data.withsameapartments > 0) dualBrandData();
@@ -1080,8 +1085,17 @@ let navList = ref([]);
let navTab = ref("specialEle"); let navTab = ref("specialEle");
// 初始化 判断 navTab 值
const initNavTab = () => {
if (info.value.promotionalactivities) navTab.value = "specialEle";
else if (spotSum.value > 0) navTab.value = "inspectEle";
else if (returnSum.value > 0) navTab.value = "followEle";
else navTab.value = "roomEle";
};
// 处理 navList 数据 // 处理 navList 数据
const handleNavData = () => { const handleNavData = () => {
navList.value = [];
navconfig.forEach((element) => { navconfig.forEach((element) => {
if (eval(element["value"]).value) navList.value.push(element); if (eval(element["value"]).value) navList.value.push(element);
}); });
@@ -1419,8 +1433,6 @@ const openMap = () => {
}; };
const roomCollect = (id, index) => { const roomCollect = (id, index) => {
console.log(id, index);
proxy.$post("https://api.gter.net/v1/apartment/roomCollection", { id }).then((res) => { proxy.$post("https://api.gter.net/v1/apartment/roomCollection", { id }).then((res) => {
if (res.code != 200) return; if (res.code != 200) return;
const data = res.data; const data = res.data;
@@ -1430,6 +1442,93 @@ const roomCollect = (id, index) => {
}; };
let isInspectPop = ref(false); let isInspectPop = ref(false);
let spotObj = ref({});
let spotSum = ref(0);
let returnSum = ref(0);
let remarkList = ref([]);
let remarkTypeid = ref(0); // 0 全部 1 考察 2 回访
const getComment = () => {
proxy
.$post("https://api.gter.net/v1/apartment/comment", { token })
.then((res) => {
if (res.code != 200) return;
let data = res.data || [];
let spot = null; // 实地考察
let sSum = 0;
let rSum = 0;
data.forEach((element) => {
element.date = formatDate(element.created_at);
// 合并视频和图片资源
element.sources = [
...(element.attachment.videos || []).map((video) => ({
type: "videos",
thumbnail: video.cover,
poster: video.cover,
videourl: video.url,
})),
...(element.attachment.images || []).map((image) => ({
type: "attachment",
imageurl: image.url,
thumbnail: image.cover,
})),
];
// 分类统计
element.typeid === 1 ? ((spot = element), sSum++) : rSum++;
});
spotObj.value = spot;
remarkList.value = data;
spotSum.value = sSum;
returnSum.value = rSum;
nextTick(() => {
handleNavData();
initNavTab();
});
})
.catch((err) => {
initNavTab();
});
};
const formatDate = (dateStr) => {
const date = new Date(dateStr);
const year = date.getFullYear();
const month = date.getMonth() + 1; // 月份从 0 开始
const day = date.getDate();
// 移除前导零(如果需要)
return `${year}.${month}.${day}`;
};
const openInspectPop = () => {
isInspectPop.value = true;
};
const previewImg = (index, i) => {
const list = remarkList.value || [];
// const url = e.currentTarget.dataset.url;
// if (url) {
// list.forEach((element, indexi) => {
// (element.sources || []).forEach((element, indexii) => {
// if (url == element.poster) {
// index = indexi;
// i = indexii;
// }
// });
// });
// }
const sources = list[index].sources || [];
cloaseImageShow(sources, i, "inspect");
};
// 切换点评
const cutRemarkType = (value) => (remarkTypeid.value = value);
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>

View File

@@ -359,12 +359,13 @@ const getFavData = () => {
.then((res) => { .then((res) => {
if (res.code != 200) return; if (res.code != 200) return;
let data = res.data; let data = res.data;
console.log("data", data);
let list = data.data || []; let list = data.data || [];
list = list.map((item) => { list = list.map((item) => {
const newItem = item.data ? { ...item.data } : { ...item }; const newItem = item.data ? { ...item.data } : { ...item };
newItem.typetype = item.type; newItem.typetype = item.type;
newItem.token = item.token; newItem.token = item.token;
if (typeof newItem.hottags == "string") newItem.hottags = JSON.parse(newItem.hottags);
if (newItem.typetype === "apartmentcollection" && typeof newItem.tags === "string") newItem.tags = newItem.tags.split(","); if (newItem.typetype === "apartmentcollection" && typeof newItem.tags === "string") newItem.tags = newItem.tags.split(",");
if (newItem.typetype === "apartmentcollection" && typeof newItem.hottags === "string") newItem.hottags = newItem.hottags.split(","); if (newItem.typetype === "apartmentcollection" && typeof newItem.hottags === "string") newItem.hottags = newItem.hottags.split(",");
return newItem; return newItem;
@@ -498,8 +499,6 @@ const handleDelete = (index, status) => {
// 监听滚动到底部 // 监听滚动到底部
const handleScroll = () => { const handleScroll = () => {
console.log("handleScroll");
if (!user.value["uid"]) return; if (!user.value["uid"]) return;
const scrollHeight = document.documentElement.scrollHeight; const scrollHeight = document.documentElement.scrollHeight;
const clientHeight = document.documentElement.clientHeight; const clientHeight = document.documentElement.clientHeight;