refactor: 移除调试日志并优化代码结构

移除多个组件中的调试日志语句,优化代码结构以提高可读性和维护性。同时调整了部分样式和逻辑,确保功能一致性和用户体验。
This commit is contained in:
DESKTOP-RQ919RC\Pc
2025-05-22 18:58:39 +08:00
parent 4f3989f756
commit fbb9e5a76c
12 changed files with 512 additions and 412 deletions

View File

@@ -3,18 +3,18 @@
<login></login>
</template>
<script setup>
import login from "@/components/public/login.vue"
import store from "@/store"
import { onMounted, watch, watchEffect } from "vue"
import { useRoute } from "vue-router"
import api from "./utils/api"
let socketTask = null
import login from "@/components/public/login.vue";
import store from "@/store";
import { onMounted, watch, watchEffect } from "vue";
import { useRoute } from "vue-router";
import api from "./utils/api";
let socketTask = null;
onMounted(() => {
// useSocket()
document.addEventListener("visibilitychange", () => {
if (document.visibilityState === "visible" && socketTask?.readyState != 1) useSocket()
})
if (document.visibilityState === "visible" && socketTask?.readyState != 1) useSocket();
});
// 创建cnzz统计js //v1.cnzz.com/z_stat.php?id=1281224882&amp;web_id=1281224882
// const script = document.createElement("script")
@@ -22,31 +22,31 @@ onMounted(() => {
// script.language = "JavaScript"
// document.body.appendChild(script)
getBannerData()
})
getBannerData();
});
const route = useRoute()
const route = useRoute();
watch(route, (newValue, oldValue) => {
if (window._czc) {
let location = window.location
let contentUrl = location.pathname + location.hash
let refererUrl = "/"
let location = window.location;
let contentUrl = location.pathname + location.hash;
let refererUrl = "/";
window._czc.push(["_trackPageview", contentUrl, refererUrl])
window._czc.push(["_setAutoPageview", false])
window._czc.push(["_trackPageview", contentUrl, refererUrl]);
window._czc.push(["_setAutoPageview", false]);
}
if (window._hmt) {
if (newValue["path"]) window._hmt.push(["_trackPageview", newValue["fullPath"]])
if (newValue["path"]) window._hmt.push(["_trackPageview", newValue["fullPath"]]);
}
})
});
const useSocketInterval = 50000 // Socket的时间间隔
const useSocketInterval = 50000; // Socket的时间间隔
const useSocket = () => {
let token = getMiucmsSessionCookie() || ""
socketTask = new WebSocket(`wss://app.gter.net/socket?token=${token}`)
let token = getMiucmsSessionCookie() || "";
socketTask = new WebSocket(`wss://app.gter.net/socket?token=${token}`);
socketTask.onopen = () => {
let user = store.state.user || {}
let user = store.state.user || {};
if (user && token) {
socketTask.send(
JSON.stringify({
@@ -56,46 +56,46 @@ const useSocket = () => {
uid: user.uid || 0,
},
})
)
}
setTimeout(() => timedTransmission(), useSocketInterval)
);
}
setTimeout(() => timedTransmission(), useSocketInterval);
};
socketTask.onclose = () => {
// timedTransmissionState = false
console.log("socket关闭了", new Date())
}
}
console.log("socket关闭了", new Date());
};
};
// let timedTransmissionState = false // 定时器启动状态
// 定时发送
const timedTransmission = () => {
// if (socketTask.readyState != 1 || timedTransmissionState) return
if (socketTask.readyState != 1) return
if (socketTask.readyState != 1) return;
// timedTransmissionState = true
socketTask.send(JSON.stringify({ type: "ping" }))
setTimeout(() => timedTransmission(), useSocketInterval)
}
socketTask.send(JSON.stringify({ type: "ping" }));
setTimeout(() => timedTransmission(), useSocketInterval);
};
const getMiucmsSessionCookie = () => {
let cookies = document.cookie.split(";")
let cookies = document.cookie.split(";");
for (let i = 0; i < cookies.length; i++) {
let cookie = cookies[i].split("=")
let cookie = cookies[i].split("=");
if (cookie[0].trim() === "miucms_session") {
return cookie[1]
return cookie[1];
}
}
return null
}
return null;
};
// 获取轮播图的 数据
const getBannerData = () => {
api.banner().then(res => {
api.banner().then((res) => {
if (res.code === 200) {
// bannerData
store.state.bannerData = res.data
}
})
store.state.bannerData = res.data;
}
});
};
</script>
<style lang="less">
header.page-header {
@@ -137,7 +137,6 @@ img {
-webkit-line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
}
.shadow {
@@ -180,7 +179,7 @@ img {
.box-min-1200-src {
min-width: 1200px;
overflow-x: scroll;
overflow-x: auto;
}
/* // 全局css 加上以下代码,可以隐藏上下箭头 */

View File

@@ -439,6 +439,13 @@
.content .details-box {
justify-content: space-between;
align-items: flex-start;
position: relative;
}
.content .details-box .details-left {
transition: bottom 0.5s;
}
.content .details-box .details-left.fixed {
position: fixed;
}
.content .details-box .details-left .special-offer {
width: 876px;
@@ -956,7 +963,6 @@
line-height: 24px;
font-size: 13px;
padding: 30px;
margin-bottom: 100px;
}
.content .details-box .details-left .details-item.hint-box .hint-item {
min-height: 24px;

View File

@@ -576,8 +576,15 @@
.details-box {
justify-content: space-between;
align-items: flex-start;
position: relative;
.details-left {
&.fixed {
position: fixed;
}
transition: bottom 0.5s;
.special-offer {
width: 876px;
position: relative;
@@ -1392,7 +1399,7 @@
line-height: 24px;
font-size: 13px;
padding: 30px;
margin-bottom: 100px;
// margin-bottom: 100px;
.hint-item {
min-height: 24px;

View File

@@ -32,11 +32,14 @@
</template>
<script setup>
import { defineProps } from "vue"
import { useRouter } from "vue-router";
const props = defineProps({
item: Object,
});
let router = useRouter();
const gobrand = (item) => router.push(`/apartmentDetail?uniqid=${item.uniqid}`);
</script>
@@ -47,9 +50,12 @@ const gobrand = (item) => router.push(`/apartmentDetail?uniqid=${item.uniqid}`);
border-radius: 17px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.117647058823529);
padding: 8px 0;
margin-bottom: 20px;
cursor: pointer;
&:not(:last-of-type) {
margin-bottom: 20px;
}
&:hover {
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.25686275);
}

View File

@@ -267,7 +267,6 @@ let pitchValue = ref({
watchEffect(() => {
// nearSchoolList = store.state.apartment.school || []
console.log('store.state.schoolList',store.state.schoolList);
nearSchoolList = store.state.schoolList || [];
roomTypeList = store.state.apartment.roomtype || [];
roomTypeKey = store.state.roomTypeKey || {};

View File

@@ -1,6 +1,6 @@
<template>
<!-- <div class="top-bg-img-box pos-r" :style="{ 'height': bannerLists.data.length ? '530px' : '260px' }"> -->
<div class="top-bg-img-box pos-r" :style="{ 'height': bannerLists.data.length ? '470px' : '260px' }">
<div class="top-bg-img-box pos-r" :style="{ height: bannerLists.data.length ? '450px' : '260px' }">
<img src="../../assets/homeImage/indexBg.jpg" class="bg-img" alt="" v-if="bannerLists.data.length" />
<img src="../../assets//img/edit/bj-img1920.png" class="bg-img" alt="" v-if="!bannerLists.data.length" />
<div class="info-box">
@@ -19,9 +19,7 @@
<div class="user-out-box">
<div class="box-bg dis-f jus-x">
<div class="top-box"></div>
<a :href="quitUrl" style="color: #fff;">
退出
</a>
<a :href="quitUrl" style="color: #fff"> 退出 </a>
</div>
</div>
</div>
@@ -31,18 +29,18 @@
</div>
</div>
</div>
<div class="dis-f jus-x al-item body-maxWidth" style="margin: auto;">
<div class="dis-f jus-x al-item body-maxWidth" style="margin: auto">
<div class="logo-box dis-f al-item body-maxWidth">
<img src="../../assets/homeImage/logo.png" class="logo-img" alt="" @click="goIndex()" />
<img src="../../assets/homeImage/logoText.png" class="logo-text-img" alt="" @click="goIndex()" />
</div>
</div>
<!-- <div class="dis-f jus-x al-item" style="margin-top:20px;" v-if="bannerLists.data.length"> -->
<div class="dis-f jus-x al-item" v-if="bannerLists.data.length">
<div class="dis-f jus-x al-item" v-if="bannerLists.data.length" style="margin-top: 37px">
<div class="body-maxWidth">
<el-carousel :interval="5000" arrow="always" height="330" style="height: 330px;" @change="carouselChange">
<el-carousel :interval="5000" arrow="always" style="height: 236px" @change="carouselChange">
<el-carousel-item v-for="(item, i) in bannerLists.data" :key="item.feedId">
<div style="width: 100%; height: 100%;" class="dis-f jus-x al-item">
<div style="width: 100%; height: 100%" class="dis-f jus-x al-item">
<img v-if="i >= carouselIndex - 1 && i <= carouselIndex + 1" class="carousel-img" :src="item.imageurl" alt="" :title="item.title" @click="openInfo(item)" />
</div>
</el-carousel-item>
@@ -50,10 +48,10 @@
</div>
</div>
<div class="btm-seach-btn-box dis-f al-item jus-x" v-if="pageTopBarShow">
<div class="body-maxWidth dis-f" style="height: 40px;">
<div class="body-maxWidth dis-f" style="height: 40px">
<div class="tab-btn dis-f al-item jus-x" :class="{ 'tab-btn-click': item.path === tabBtnType }" v-for="(item, i) in seachTab.data" :key="i" @click="changeTabBtnType(item)">
<el-badge v-if="item['path'] == '/user' && user.data['messagenum'] != 0" :value="user.data['messagenum']">
<div style="padding: 0 10px;">{{ item.name }}</div>
<div style="padding: 0 10px">{{ item.name }}</div>
</el-badge>
<div v-else>{{ item.name }}</div>
</div>
@@ -64,112 +62,114 @@
</template>
<script setup>
import store from "../../store/index"
import { useRoute, useRouter } from "vue-router"
import { reactive, watchEffect, ref, defineProps } from "vue"
import { goTologin } from "@/utils/util.js"
import store from "../../store/index";
import { useRoute, useRouter } from "vue-router";
import { reactive, watchEffect, ref, defineProps } from "vue";
import { goTologin } from "@/utils/util.js";
const props = defineProps({
bannerList: {
type: Array,
default: function () {
return []
return [];
},
},
})
});
//退出登录
let url = location.href
let quitUrl = ref(`https://passport.gter.net/login/quit?referer=${url}`)
let url = location.href;
let quitUrl = ref(`https://passport.gter.net/login/quit?referer=${url}`);
//个人信息
let user = reactive({ data: {} })
let user = reactive({ data: {} });
//组件数据
let topTab = reactive({ data: [] })
let seachTab = reactive({ data: [] })
let bannerLists = reactive({ data: [] })
let topTab = reactive({ data: [] });
let seachTab = reactive({ data: [] });
let bannerLists = reactive({ data: [] });
watchEffect(() => {
user.data = store.state.user
user.data = store.state.user;
// bannerLists.data = props.bannerList
if (!store.state.indexData.menu) return
store.state.indexData.menu.map(res => {
if (!store.state.indexData.menu) return;
store.state.indexData.menu.map((res) => {
if (res.name === "首页") {
res.path = "/"
res.path = "/";
} else if (res.name === "个人房源") {
res.path = "/personHousing"
res.path = "/personHousing";
} else if (res.name === "中介房源") {
res.path = "/intermediaryHousing"
res.path = "/intermediaryHousing";
} else if (res.name === "品牌公寓") {
res.path = "/apartment"
res.path = "/apartment";
} else if (res.name === "求房源") {
res.path = "/needHousing"
res.path = "/needHousing";
} else if (res.name === "我的") {
res.path = "/user"
res.path = "/user";
}
})
seachTab.data = store.state.indexData.menu
topTab.data = store.state.indexData.nav
})
});
seachTab.data = store.state.indexData.menu;
topTab.data = store.state.indexData.nav;
});
//顶部导航跳转
let topTabNum = ref("fang")
let topTabNum = ref("fang");
let topTabSelect = (type, item) => {
// topTabNum.value=type
window.open(item.url)
}
window.open(item.url);
};
//页面跳转
const router = useRouter()
let tabBtnType = ref("/")
const router = useRouter();
let tabBtnType = ref("/");
let pageTopBarShow = router.currentRoute.value.meta.topBarShow
let changeTabBtnType = item => {
let pageTopBarShow = router.currentRoute.value.meta.topBarShow;
let changeTabBtnType = (item) => {
// 判断点击进入 user 时是否已经登录
if (item["path"] == "/user" && (user.data["uid"] == 0 || user.data["uin"] == 0)) {
loginBtn("login")
return
}
tabBtnType.value = item.path
router.push({
path: item.path,
})
loginBtn("login");
return;
}
tabBtnType.value = item.path;
// router.push({
// path: item.path,
// })
let openInfo = data => {
window.open(data.url)
}
router.push(item.path);
};
let openInfo = (data) => {
window.open(data.url);
};
//监听路由
const route = useRoute()
let routePath = ref("")
routePath.value = route.meta.path
tabBtnType.value = route.meta.path
const route = useRoute();
let routePath = ref("");
routePath.value = route.meta.path;
tabBtnType.value = route.meta.path;
// 点击登录注册 type login 登录 register注册
const loginBtn = type => {
const loginBtn = (type) => {
if (type == "login") {
store.state.showloginmodal = true
return
}
goTologin()
store.state.showloginmodal = true;
return;
}
goTologin();
};
// 跳转首页
const goIndex = () => router.push("/")
const goIndex = () => router.push("/");
watchEffect(() => {
if (routePath.value == "/needHousing") bannerLists.data = store.state.bannerData.needHousing || []
else if (routePath.value == "/intermediaryHousing") bannerLists.data = store.state.bannerData.intermediaryHousing || []
else if (routePath.value == "/personHousing") bannerLists.data = store.state.bannerData.personHousing || []
else if (routePath.value == "/apartment") bannerLists.data = store.state.bannerData.apartment || []
else if (routePath.value == "/") bannerLists.data = store.state.bannerData.home || []
})
if (routePath.value == "/needHousing") bannerLists.data = store.state.bannerData.needHousing || [];
else if (routePath.value == "/intermediaryHousing") bannerLists.data = store.state.bannerData.intermediaryHousing || [];
else if (routePath.value == "/personHousing") bannerLists.data = store.state.bannerData.personHousing || [];
else if (routePath.value == "/apartment") bannerLists.data = store.state.bannerData.apartment || [];
else if (routePath.value == "/") bannerLists.data = store.state.bannerData.home || [];
});
let carouselIndex = ref(0) // 轮播图的索引
let carouselIndex = ref(0); // 轮播图的索引
const carouselChange = value => {
carouselIndex.value = value
}
const carouselChange = (value) => {
carouselIndex.value = value;
};
</script>
<style lang="less" scoped>
.pos-r {
@@ -320,8 +320,9 @@ const carouselChange = value => {
.carousel-img {
margin: 0 auto;
width: 660px;
height: 280px;
// width: 660px;
// height: 280px;
height: 200px;
border-radius: 15px;
cursor: pointer;
}
@@ -405,6 +406,10 @@ const carouselChange = value => {
text-align: left;
}
/deep/ .el-carousel__container {
height: 200px;
}
.dropdown {
background: #000;
}

View File

@@ -71,7 +71,7 @@
<div class="collect-type flexacenter">
<div class="collect flexacenter flex1">
<img class="flame-icon" src="@/assets/img/publicImage/flame-icon.png" />
近15天{{ item.collectnum }}收藏
近15天{{ item.collectnum }}感兴趣
</div>
<div class="house-type flexacenter">
{{ item.roomnum || 0 }}个房型

View File

@@ -2,7 +2,7 @@
<page-top-bar></page-top-bar>
<div class="content wid1200">
<div class="header">
<div class="header" ref="headerRef">
<div class="top flexflex">
<div class="brand-abstract flexflex">
<div class="flexacenter" style="height: min-content">
@@ -92,7 +92,7 @@
</div>
</div>
<div class="figure flexacenter">
<div class="figure flexacenter" v-if="distancePitch?.alias">
距离
<div class="school">{{ distancePitch.alias }}</div>
{{ distancePitch.distance }}km
@@ -100,7 +100,7 @@
</div>
<div class="vehicle flexflex">
<div class="item flexacenter" v-for="(item, index) in distancePitch.obj" :key="index">
<div class="item flexacenter" v-for="(item, index) in distancePitch?.obj" :key="index">
<img v-if="index == 'walking'" class="icon" src="@/assets/img/apartmentDetail/walk-icon.png" />
<img v-if="index == 'driving'" class="icon" src="@/assets/img/apartmentDetail/taxi-icon.png" />
<img v-if="index == 'transit'" class="icon" src="@/assets/img/apartmentDetail/subway-icon.png" />
@@ -122,7 +122,7 @@
</div>
</div>
<div class="operate-box-bj flexcenter">
<div class="operate-box-bj flexcenter" v-if="isOperateShow">
<div class="operate-box flexacenter" aria-label="详情的导航栏">
<div class="nav-box flexacenter">
<div class="nav-item flexcenter" :class="{ pitch: navTab == item.value }" :aria-label="`${item['name']}-按钮`" v-for="(item, index) in navList" :key="index" @click="handleClickNav(item.value)">{{ item["value"] == "roomEle" ? `${item["name"]} ${roomList.length}` : item["name"] }}</div>
@@ -142,8 +142,9 @@
</div>
</div>
</div>
<div class="details-box flexflex">
<div class="details-left flex1" ref="detailsLeft">
<div class="details-box flexflex" ref="detailsBox">
<div class="flex1">
<div class="details-left flex1" :class="{ fixed: isFixed }" :style="{ bottom: FixedBottom + 'px' }" ref="detailsLeft">
<div class="special-offer" v-if="info.promotionalactivities" ref="specialEle">
<img class="special-bj" src="@/assets/img/publicImage/special-bj.svg" />
<img class="head" src="@/assets/img/publicImage/special-title.png" />
@@ -519,7 +520,9 @@
<div class="hint-item flexacenter">公寓/酒店/中介房源推广合作请联系<a @click="copy('ad@gter.net')">ad@gter.net</a></div>
</div>
</div>
<div class="details-right flexacenter">
</div>
<div class="details-right flexacenter" ref="detailsRigth">
<phoneqrcode type="apartment" :qrcode="qrcode"></phoneqrcode>
<groupqrcode type="apartment"></groupqrcode>
<!-- 同品牌公寓 -->
@@ -692,7 +695,7 @@ watch(route, () => {
mediaBtnstate.value = {};
slideshowList.value = null;
detailsLeft.value = null;
// detailsLeft.value = null;
token = "";
carouselIndex.value = 0;
@@ -792,7 +795,7 @@ const facilityKeyName = {
room: "房间设施",
};
const facilityArr = ["public", "room", "service", "sport", "outdoor", "security"]; // 公寓设施 顺序
const facilityArr = ["room", "public", "service", "sport", "outdoor", "security"]; // 公寓设施 顺序
let facilitylist = ref([]);
let costList = ref([]);
@@ -1105,7 +1108,9 @@ const handleNavData = () => {
// 处理点击nav 滚动事件
const handleClickNav = (value) => {
let scrollTop = eval(value).value.offsetTop + 136;
const headerHeight = headerRef.value.getBoundingClientRect().height + 20 + 260 - 36 - 20;
let scrollTop = eval(value).value.offsetTop + headerHeight;
window.scrollTo({ top: scrollTop, behavior: "smooth" });
};
@@ -1211,6 +1216,7 @@ const slideshowItem = (index) => remarkCaruselUp.value.setActiveItem(index);
const slideshowType = (type) => slideshowItem(carouselsconfig.value[type].index);
let detailsLeft = ref(null);
let detailsRigth = ref(null);
onMounted(() => {
window.addEventListener("scroll", handleScroll);
@@ -1220,8 +1226,43 @@ onUnmounted(() => {
window.removeEventListener("scroll", handleScroll);
});
let isFixed = ref(false); // 详情左侧是否固定
let FixedBottom = ref(0); // 详情左侧固定的距离
let detailsBox = ref(null); // 详情的节点
let headerRef = ref(null); // 头部节点
let isOperateShow = ref(true); // 底部操作栏是否显示
const handleScroll = () => {
if (Math.random() > 0.3) return;
let body = document.documentElement ? document.documentElement : document.body ? document.body : document.querySelector(".element")
let offsetHeight = body.offsetHeight
const clientHeight = document.documentElement.clientHeight;
const scrollTop = document.documentElement.scrollTop;
const top = scrollTop + clientHeight;
const headerHeight = headerRef.value.getBoundingClientRect().height + 20;
const left = detailsLeft.value.getBoundingClientRect();
const rigth = detailsRigth.value.getBoundingClientRect();
const leftHeight = left.height;
const rigthHeight = rigth.height;
if (leftHeight < rigthHeight) {
// 整个左边高度到顶部的距离
const topDistance = 260 - 36 + headerHeight + leftHeight + 223;
if (top > topDistance && isFixed.value == false) {
isFixed.value = true;
FixedBottom.value = document.querySelector(".index-footer").getBoundingClientRect().height + 20
}
if (top < topDistance && isFixed.value == true) isFixed.value = false;
}
if (scrollTop + clientHeight >= offsetHeight - 200) isOperateShow.value = false;
else isOperateShow.value = true;
for (let i = 0; i < navList.value.length; i++) {
let element = navList.value[i];

View File

@@ -170,7 +170,7 @@
<span v-for="(item, i) in housingInfo['data'] && housingInfo['data'].info.sunshinearea" :key="i"><span v-show="i != 0">/</span>{{ item == 0 ? "不限" : indexData["data"] && indexData["data"]["config"] && indexData["data"]["config"]["sunshinearea"][item] }} </span>
</div>
</div>
<div class="info dis-f al-item" v-if="housingInfo['data'] && housingInfo['data'].info.acreage[0]">
<div class="info dis-f al-item" v-if="housingInfo['data'] && housingInfo['data'].info.acreage?.[0]">
<div class="title-box">
面积
</div>

View File

@@ -86,8 +86,17 @@ onMounted(() => {
// pitchValue.value = store.getters.getApartmentPitchValue
const value = localStorage.getItem("apartmentPitchValue");
if (value) pitchValue.value = JSON.parse(value);
let value = localStorage.getItem("apartmentPitchValue");
if (value) {
value = JSON.parse(value);
// 判断 学校id是否在筛选
if (value["school"]) {
const schoolList = store.state.schoolList || [];
const isExist = schoolList.some((item) => item.sid == value["school"]);
if (!isExist) value["school"] = 0;
}
pitchValue.value = value;
}
if (route.query["companyid"]) pitchValue.value["companyid"] = route.query["companyid"];
@@ -118,7 +127,7 @@ const getData = () => {
localStorage.setItem("apartmentPitchValue", JSON.stringify(pitchValue.value));
proxy
.$post("https://api.gter.net/v1/apartment/lists", { limit: 12, page, ...pitchValue.value })
.$post("https://api.gter.net/v1/apartment/lists", { limit: 1000, page, ...pitchValue.value })
.then((res) => {
if (res.code != 200) return;
let data = res.data;
@@ -133,8 +142,6 @@ const getData = () => {
requestLoading = false;
});
// console.log("pitchValue.value", pitchValue.value);
if (page == 0 && (pitchValue.value.companyid || pitchValue.value.rent_max || pitchValue.value.rent_min || pitchValue.value.roomlistings || pitchValue.value.roomtype || pitchValue.value.school || pitchValue.value.tag)) {
morePage = 1;
getMoreList();
@@ -156,8 +163,10 @@ const handleScroll = () => {
const scrollHeight = document.documentElement.scrollHeight;
const clientHeight = document.documentElement.clientHeight;
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
if (scrollTop + clientHeight >= scrollHeight - 350 && page != 0) getData();
if (scrollTop + clientHeight >= scrollHeight - 350 && page == 0) getMoreList();
if (scrollTop + clientHeight >= scrollHeight - 350) {
if (page != 0) getData();
else if (page == 0 && (pitchValue.value.companyid || pitchValue.value.rent_max || pitchValue.value.rent_min || pitchValue.value.roomlistings || pitchValue.value.roomtype || pitchValue.value.school || pitchValue.value.tag)) getMoreList();
}
};
let pitchValue = ref({
@@ -213,7 +222,7 @@ const getMoreList = () => {
let notids = [];
list.value.forEach((element) => notids.push(element.id));
proxy.$post("https://api.gter.net/v1/apartment/lists", { notids, page: morePage, limit: 12 }).then((res) => {
proxy.$post("https://api.gter.net/v1/apartment/lists", { notids, page: morePage, limit: 1000 }).then((res) => {
if (res.code != 200) return;
const data = res.data;
if (!data.data) return;
@@ -245,7 +254,7 @@ const getMoreScroll = () => {
let scrollTop = body.scrollTop;
let clientHeight = body.clientHeight;
let offsetHeight = body.offsetHeight;
if (scrollTop + clientHeight >= offsetHeight - 200 && !moreLoading.value) getMoreList();
if (scrollTop + clientHeight >= offsetHeight - 200 && !moreLoading.value && (pitchValue.value.companyid || pitchValue.value.rent_max || pitchValue.value.rent_min || pitchValue.value.roomlistings || pitchValue.value.roomtype || pitchValue.value.school || pitchValue.value.tag)) getMoreList();
};
// 处理列表的点击收藏

View File

@@ -8,7 +8,7 @@
<biserialItem v-for="(item, i) in pageList" :key="i" :item="item"></biserialItem>
</div>
<div class="body-maxWidth" v-show="seachSelectData.data && seachSelectData.data.tabType === 'apartment' && dataList.data && dataList.data.length > 0" ref="gridContainer">
<apartment-item v-for="(item, index) in listApartment" :key="index" :item="item" :masonryInstance="masonryInstance"></apartment-item>
<apartment-item v-for="(item, index) in listApartment" :key="index" :item="item" :masonryInstance="masonryInstance" @handlecollect="handlecollect"></apartment-item>
</div>
<div class="dis-f jus-x no-list-box al-item" v-show="dataList.data && dataList.data.length === 0">
<noList hintText="暂无搜索结果" hintTextTwo="建议更换搜索关键词,或放宽筛选条件"></noList>
@@ -79,7 +79,6 @@ let setInitial = () => {
//获取搜索数据
let getDataList = (data, type = true) => {
console.log("data", data);
if (!type) {
//是否继续搜索
seachSelectData.data.tabType !== "apartment" ? (pageList.value = []) : (listApartment.value = []);
@@ -186,6 +185,28 @@ onMounted(() => {
onBeforeUnmount(() => {
window.removeEventListener("scroll", downLoadMore, true);
});
// 处理列表的点击收藏
const handlecollect = (uniqid) => {
let targetIndex = 0;
let token = "";
listApartment.value.forEach((element, index) => {
if (element.uniqid == uniqid) {
targetIndex = index;
token = element.token || "";
}
});
// api.apartmentCollection({ token }).then((res) => {
proxy.$post("https://api.gter.net/v1/apartment/collection", { token }).then((res) => {
if (res.code != 200) return;
const data = res.data;
listApartment.value[targetIndex]["iscollect"] = data.status;
ElMessage.success(res.message);
});
};
</script>
<style scoped lang="less">
img {

View File

@@ -215,7 +215,7 @@ import backToTop from "@/components/public/backToTop.vue";
import authenticationInfo from "@/components/seachModule/authenticationInfo.vue";
import { redirectToExternalWebsite } from "@/utils/util.js";
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, nextTick, pushScopeId } from "vue";
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, onBeforeUnmount, nextTick, pushScopeId, onDeactivated } from "vue";
import { useRoute, useRouter } from "vue-router";
import { ElLoading, ElMessage } from "element-plus";
@@ -243,7 +243,6 @@ onMounted(() => {
});
init();
console.log("onMounted");
window.addEventListener("scroll", handleScroll);
});
@@ -341,6 +340,7 @@ const getPublishData = () => {
let favData = ref({
page: 1,
list: [],
limit: 200000,
});
// 获取收藏数据
@@ -355,7 +355,7 @@ const getFavData = () => {
// .$post("/tenement/pc/api/user/favList", {
// .$post("/tenement/pc/api/user/collectionList", {
proxy
.$post("https://app.gter.net/tenement/v2/api/user/collections", { page: favData.value["page"] })
.$post("https://app.gter.net/tenement/v2/api/user/collections", { page: favData.value["page"], limit: favData.value["limit"] })
.then((res) => {
if (res.code != 200) return;
let data = res.data;
@@ -410,7 +410,6 @@ let cancelCollection = (data) => {
if (index == -1) return;
// const list = favData.value.list || [];
console.log("list", list);
proxy
.$post(url, {
@@ -499,6 +498,8 @@ const handleDelete = (index, status) => {
// 监听滚动到底部
const handleScroll = () => {
// 判断是不是 user 页面
if (route.path.indexOf("/user") == -1) window.removeEventListener("scroll", handleScroll);
if (!user.value["uid"]) return;
const scrollHeight = document.documentElement.scrollHeight;
const clientHeight = document.documentElement.clientHeight;
@@ -512,7 +513,13 @@ const handleScroll = () => {
// 跳转公寓详情页
const goApartmentDetail = (item) => redirectToExternalWebsite(`/apartmentDetail?uniqid=${item.uniqid}`);
onUnmounted(() => window.removeEventListener("scroll", handleScroll));
onBeforeUnmount(() => {
window.removeEventListener("scroll", handleScroll);
});
onUnmounted(() => {
window.removeEventListener("scroll", handleScroll);
});
</script>
<style lang="less" scoped>