diff --git a/src/views/housingView/apartment.vue b/src/views/housingView/apartment.vue
index 6db2be1..7c9e88c 100644
--- a/src/views/housingView/apartment.vue
+++ b/src/views/housingView/apartment.vue
@@ -17,9 +17,13 @@
-
+
+
+

+ 更多推荐
+
+
- 到底了 -
@@ -66,19 +70,19 @@ let list = ref([]);
let listCount = ref(0); // 列表数量
let masonryInstance = null;
-// let masonryInstanceMore = null
+let masonryInstanceMore = null;
onMounted(() => {
// 初始化瀑布流
masonryInstance = new Masonry(gridContainer.value, {
itemSelector: ".item",
- gutter: 22,
+ gutter: 22.5,
});
- // masonryInstanceMore = new Masonry(moreShowList.value, {
- // itemSelector: ".item",
- // gutter: 20,
- // })
+ masonryInstanceMore = new Masonry(moreShowList.value, {
+ itemSelector: ".item",
+ gutter: 22.5,
+ });
// pitchValue.value = store.getters.getApartmentPitchValue
@@ -114,11 +118,7 @@ const getData = () => {
localStorage.setItem("apartmentPitchValue", JSON.stringify(pitchValue.value));
proxy
- .$post("https://api.gter.net/v1/apartment/lists", {
- limit: 10,
- page,
- ...pitchValue.value,
- })
+ .$post("https://api.gter.net/v1/apartment/lists", { limit: 12, page, ...pitchValue.value })
.then((res) => {
if (res.code != 200) return;
let data = res.data;
@@ -133,6 +133,13 @@ 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();
+ }
+
// 小于20 代表筛选 数据不够了,需要加载更多的 随便在这里初始化 更多的 瀑布流 HTML
// if (data.data.length < 20 && (pitchValue.value["school"] || pitchValue.value["location"].length != 0)) {
// morePage.value = 1
@@ -149,7 +156,8 @@ 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) getData();
+ if (scrollTop + clientHeight >= scrollHeight - 350 && page != 0) getData();
+ if (scrollTop + clientHeight >= scrollHeight - 350 && page == 0) getMoreList();
};
let pitchValue = ref({
@@ -172,6 +180,9 @@ const handleTransfer = (data) => {
store.state.apartmentPitchValue = pitchValue.value;
page = 1;
list.value = [];
+
+ moreList.value = [];
+
getData();
break;
}
@@ -180,31 +191,42 @@ const handleTransfer = (data) => {
let moreShowList = ref(null);
let moreState = ref(false); // 更多列表 显示状态
-let morePage = ref(1);
+let morePage = 1;
let moreList = ref([]);
let moreLoading = ref(false);
// 加载更多数据列表
const getMoreList = () => {
- if (morePage.value == 0 || moreLoading.value) return;
+ if (morePage == 0 || moreLoading.value) return;
moreLoading.value = true;
- let postData = {
- page: morePage.value,
- ...pitchValue.value,
- };
- api.getMoreLists(postData).then((res) => {
+ // let postData = {
+ // page: morePage.value,
+ // ...pitchValue.value,
+ // };
+
+ 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) => {
if (res.code != 200) return;
const data = res.data;
if (!data.data) return;
+ // moreList.value = data.data || [];
+
+ // nextTick(() => {
+ // masonryInstanceMore.reloadItems();
+ // masonryInstanceMore.layout();
+ // moreLoading.value = false;
+ // });
moreList.value = moreList.value.concat(data.data);
moreState.value = true;
- if (data.data && data.data.length < data.limit) morePage.value = 0;
- else {
- morePage.value++;
- window.addEventListener("scroll", getMoreScroll, true);
- }
+ // if (data.data && data.data.length < data.limit) morePage = 0;
+ // else morePage++;
+
+ morePage = data.page * data.limit >= data.count ? 0 : morePage + 1;
+
nextTick(() => {
masonryInstanceMore.reloadItems();
masonryInstanceMore.layout();
@@ -233,13 +255,34 @@ const handlecollect = (uniqid) => {
}
});
- api.apartmentCollection({ token }).then((res) => {
+ // 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;
list.value[targetIndex]["iscollect"] = data.status;
ElMessage.success(res.message);
});
};
+
+// 处理列表的点击收藏
+const handleMoreCollect = (uniqid) => {
+ let targetIndex = 0;
+ let token = "";
+
+ moreList.value.forEach((element, index) => {
+ if (element.uniqid == uniqid) {
+ targetIndex = index;
+ token = element.token || "";
+ }
+ });
+
+ proxy.$post("https://api.gter.net/v1/apartment/collection", { token }).then((res) => {
+ if (res.code != 200) return;
+ const data = res.data;
+ moreList.value[targetIndex]["iscollect"] = data.status;
+ ElMessage.success(res.message);
+ });
+};
diff --git a/src/views/seachIndex.vue b/src/views/seachIndex.vue
index cb4ca21..0965fab 100644
--- a/src/views/seachIndex.vue
+++ b/src/views/seachIndex.vue
@@ -8,7 +8,7 @@