zs 1 jaar geleden
bovenliggende
commit
00502ffee5
2 gewijzigde bestanden met toevoegingen van 73 en 47 verwijderingen
  1. 30 22
      pagesHome/shop/index.vue
  2. 43 25
      unpackage/dist/dev/mp-weixin/pagesHome/shop/index.js

+ 30 - 22
pagesHome/shop/index.vue

@@ -76,23 +76,23 @@
 									</view>
 									</view>
 								</view>
 								</view>
 							</view>
 							</view>
-							<view class="search_2"
-								v-if="Object.keys(brandInfo).length > 0||Object.keys(moneyInfo).length > 0||Object.keys(yearInfo).length > 0||moreList.length>0">
+							<view class="search_2" v-if="searchInfo.brand||searchInfo.money||moreList.length>0">
 								<view class="left">
 								<view class="left">
 									<scroll-view scroll-x="true">
 									<scroll-view scroll-x="true">
 										<view class="scroll">
 										<view class="scroll">
-											<view v-if="brandInfo&&brandInfo.type" class="title"
+											<view v-if="searchInfo&&searchInfo.brand" class="title"
 												@tap="toDelete({},'0')">
 												@tap="toDelete({},'0')">
-												<span>{{brandInfo.title}}</span>&nbsp;
+												<span>{{searchInfo.brand}}</span>&nbsp;
 												<u-icon color="#000" size="14px" name="close"></u-icon>
 												<u-icon color="#000" size="14px" name="close"></u-icon>
 											</view>
 											</view>
-											<view v-if="moneyInfo&&moneyInfo.type" class="title"
+											<view v-if="searchInfo&&searchInfo.money" class="title"
 												@tap="toDelete({},'1')">
 												@tap="toDelete({},'1')">
-												<span>{{moneyInfo.title}}</span>&nbsp;
+												<span>{{searchInfo.money}}</span>&nbsp;
 												<u-icon color="#000" size="14px" name="close"></u-icon>
 												<u-icon color="#000" size="14px" name="close"></u-icon>
 											</view>
 											</view>
-											<view v-if="yearInfo&&yearInfo.type" class="title" @tap="toDelete({},'2')">
-												<span>{{yearInfo.title}}</span>&nbsp;
+											<view v-if="searchInfo&&searchInfo.year" class="title"
+												@tap="toDelete({},'2')">
+												<span>{{searchInfo.year}}</span>&nbsp;
 												<u-icon color="#000" size="14px" name="close"></u-icon>
 												<u-icon color="#000" size="14px" name="close"></u-icon>
 											</view>
 											</view>
 											<view v-if="moreList.length>0" class="title"
 											<view v-if="moreList.length>0" class="title"
@@ -176,9 +176,7 @@
 	//车龄
 	//车龄
 	const yearList = ref([{ title: '不限车龄', type: '0', is_open: true }, { title: '2年以下', type: '1', is_open: false }, { title: '4年以下', type: '2', is_open: false }, { title: '6年以下', type: '3', is_open: false }]);
 	const yearList = ref([{ title: '不限车龄', type: '0', is_open: true }, { title: '2年以下', type: '1', is_open: false }, { title: '4年以下', type: '2', is_open: false }, { title: '6年以下', type: '3', is_open: false }]);
 	// 选择的查询条件
 	// 选择的查询条件
-	const brandInfo = ref({});
-	const moneyInfo = ref({});
-	const yearInfo = ref({});
+	const searchInfo = ref({});
 	const moreList = ref([]);
 	const moreList = ref([]);
 	// 列表
 	// 列表
 	const list = ref([]);
 	const list = ref([]);
@@ -196,12 +194,13 @@
 		});
 		});
 		await searchConfig();
 		await searchConfig();
 		await search();
 		await search();
-		await searchOther();
 	})
 	})
-	onShow(() => {
+	onShow(async () => {
 		uni.$on('toRoute', function (data) {
 		uni.$on('toRoute', function (data) {
-			brandInfo.value = data
+			if (data && data.name) searchInfo.value.brand = data.name
 		})
 		})
+		await clearPage();
+		await searchOther();
 	})
 	})
 	// config信息
 	// config信息
 	const searchConfig = async () => {
 	const searchConfig = async () => {
@@ -230,6 +229,9 @@
 			status: '0',
 			status: '0',
 			shop: id.value
 			shop: id.value
 		}
 		}
+		if (searchInfo.value.brand) info.brand = searchInfo.value.brand
+		if (searchInfo.value.money) info.money = searchInfo.value.money
+		if (searchInfo.value.year) info.year = searchInfo.value.year
 		res = await $api('car', 'GET', {
 		res = await $api('car', 'GET', {
 			...info,
 			...info,
 		});
 		});
@@ -282,7 +284,7 @@
 		})
 		})
 	};
 	};
 	// 选择
 	// 选择
-	const toSelect = (data, type) => {
+	const toSelect = async (data, type) => {
 		// 判断点击的是那个筛选
 		// 判断点击的是那个筛选
 		if (type == '0') {
 		if (type == '0') {
 			sortList.value = sortList.value.map((item, index) => {
 			sortList.value = sortList.value.map((item, index) => {
@@ -300,26 +302,28 @@
 				else item.is_open = false
 				else item.is_open = false
 				return item
 				return item
 			})
 			})
-			moneyInfo.value = data
+			searchInfo.value.money = data.title
 		} else {
 		} else {
 			yearList.value = yearList.value.map((item, index) => {
 			yearList.value = yearList.value.map((item, index) => {
 				if (item.type == data.type) item.is_open = true
 				if (item.type == data.type) item.is_open = true
 				else item.is_open = false
 				else item.is_open = false
 				return item
 				return item
 			})
 			})
-			yearInfo.value = data
+			searchInfo.value.year = data.title
 		}
 		}
+		await clearPage();
+		await searchOther();
 	};
 	};
 	// 删除筛选
 	// 删除筛选
-	const toDelete = (item, type) => {
-		if (type == '0') brandInfo.value = {}
+	const toDelete = async (item, type) => {
+		if (type == '0') searchInfo.value.brand = ''
 		else if (type == '1') {
 		else if (type == '1') {
 			moneyList.value = moneyList.value.map((item, index) => {
 			moneyList.value = moneyList.value.map((item, index) => {
 				if (item.type == '0') item.is_open = true
 				if (item.type == '0') item.is_open = true
 				else item.is_open = false
 				else item.is_open = false
 				return item
 				return item
 			})
 			})
-			moneyInfo.value = {}
+			searchInfo.value.money = ''
 		}
 		}
 		else if (type == '2') {
 		else if (type == '2') {
 			yearList.value = yearList.value.map((item, index) => {
 			yearList.value = yearList.value.map((item, index) => {
@@ -327,17 +331,21 @@
 				else item.is_open = false
 				else item.is_open = false
 				return item
 				return item
 			})
 			})
-			yearInfo.value = {}
+			searchInfo.value.year = ''
 		}
 		}
 		else moreList.value = moreList.value.filter((i, index) => i.type != item.type)
 		else moreList.value = moreList.value.filter((i, index) => i.type != item.type)
+		await clearPage();
+		await searchOther();
 	};
 	};
 	// 重置
 	// 重置
-	const toReset = () => {
+	const toReset = async () => {
 		toDelete({}, '0')
 		toDelete({}, '0')
 		toDelete({}, '1')
 		toDelete({}, '1')
 		toDelete({}, '2')
 		toDelete({}, '2')
 		moreList.value = []
 		moreList.value = []
 		toClear();
 		toClear();
+		await clearPage();
+		await searchOther();
 	};
 	};
 	// 清除
 	// 清除
 	const toClear = () => {
 	const toClear = () => {

+ 43 - 25
unpackage/dist/dev/mp-weixin/pagesHome/shop/index.js

@@ -29,9 +29,7 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
     const sortList = common_vendor.ref([{ title: "默认排序", type: "0", is_open: true }, { title: "最新上架", type: "1", is_open: false }, { title: "车龄最短", type: "2", is_open: false }, { title: "里程最少", type: "3", is_open: false }, { title: "价格最高", type: "4", is_open: false }, { title: "价格最低", type: "5", is_open: false }]);
     const sortList = common_vendor.ref([{ title: "默认排序", type: "0", is_open: true }, { title: "最新上架", type: "1", is_open: false }, { title: "车龄最短", type: "2", is_open: false }, { title: "里程最少", type: "3", is_open: false }, { title: "价格最高", type: "4", is_open: false }, { title: "价格最低", type: "5", is_open: false }]);
     const moneyList = common_vendor.ref([{ title: "不限价格", type: "0", is_open: true }, { title: "10万以下", type: "1", is_open: false }, { title: "10-15万", type: "2", is_open: false }, { title: "15-20万", type: "3", is_open: false }, { title: "20-25万", type: "4", is_open: false }, { title: "25-30万", type: "5", is_open: false }, { title: "30-50万", type: "6", is_open: false }, { title: "50万以上", type: "7", is_open: false }]);
     const moneyList = common_vendor.ref([{ title: "不限价格", type: "0", is_open: true }, { title: "10万以下", type: "1", is_open: false }, { title: "10-15万", type: "2", is_open: false }, { title: "15-20万", type: "3", is_open: false }, { title: "20-25万", type: "4", is_open: false }, { title: "25-30万", type: "5", is_open: false }, { title: "30-50万", type: "6", is_open: false }, { title: "50万以上", type: "7", is_open: false }]);
     const yearList = common_vendor.ref([{ title: "不限车龄", type: "0", is_open: true }, { title: "2年以下", type: "1", is_open: false }, { title: "4年以下", type: "2", is_open: false }, { title: "6年以下", type: "3", is_open: false }]);
     const yearList = common_vendor.ref([{ title: "不限车龄", type: "0", is_open: true }, { title: "2年以下", type: "1", is_open: false }, { title: "4年以下", type: "2", is_open: false }, { title: "6年以下", type: "3", is_open: false }]);
-    const brandInfo = common_vendor.ref({});
-    const moneyInfo = common_vendor.ref({});
-    const yearInfo = common_vendor.ref({});
+    const searchInfo = common_vendor.ref({});
     const moreList = common_vendor.ref([]);
     const moreList = common_vendor.ref([]);
     const list = common_vendor.ref([]);
     const list = common_vendor.ref([]);
     const total = common_vendor.ref(0);
     const total = common_vendor.ref(0);
@@ -47,12 +45,14 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
       });
       });
       await searchConfig();
       await searchConfig();
       await search();
       await search();
-      await searchOther();
     });
     });
-    common_vendor.onShow(() => {
+    common_vendor.onShow(async () => {
       common_vendor.index.$on("toRoute", function(data) {
       common_vendor.index.$on("toRoute", function(data) {
-        brandInfo.value = data;
+        if (data && data.name)
+          searchInfo.value.brand = data.name;
       });
       });
+      await clearPage();
+      await searchOther();
     });
     });
     const searchConfig = async () => {
     const searchConfig = async () => {
       config.value = common_vendor.index.getStorageSync("config");
       config.value = common_vendor.index.getStorageSync("config");
@@ -78,6 +78,12 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
         status: "0",
         status: "0",
         shop: id.value
         shop: id.value
       };
       };
+      if (searchInfo.value.brand)
+        info.brand = searchInfo.value.brand;
+      if (searchInfo.value.money)
+        info.money = searchInfo.value.money;
+      if (searchInfo.value.year)
+        info.year = searchInfo.value.year;
       res = await $api("car", "GET", {
       res = await $api("car", "GET", {
         ...info
         ...info
       });
       });
@@ -129,7 +135,7 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
         return item;
         return item;
       });
       });
     };
     };
-    const toSelect = (data, type2) => {
+    const toSelect = async (data, type2) => {
       if (type2 == "0") {
       if (type2 == "0") {
         sortList.value = sortList.value.map((item, index) => {
         sortList.value = sortList.value.map((item, index) => {
           if (item.type == data.type)
           if (item.type == data.type)
@@ -151,7 +157,7 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
             item.is_open = false;
             item.is_open = false;
           return item;
           return item;
         });
         });
-        moneyInfo.value = data;
+        searchInfo.value.money = data.title;
       } else {
       } else {
         yearList.value = yearList.value.map((item, index) => {
         yearList.value = yearList.value.map((item, index) => {
           if (item.type == data.type)
           if (item.type == data.type)
@@ -160,12 +166,14 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
             item.is_open = false;
             item.is_open = false;
           return item;
           return item;
         });
         });
-        yearInfo.value = data;
+        searchInfo.value.year = data.title;
       }
       }
+      await clearPage();
+      await searchOther();
     };
     };
-    const toDelete = (item, type2) => {
+    const toDelete = async (item, type2) => {
       if (type2 == "0")
       if (type2 == "0")
-        brandInfo.value = {};
+        searchInfo.value.brand = "";
       else if (type2 == "1") {
       else if (type2 == "1") {
         moneyList.value = moneyList.value.map((item2, index) => {
         moneyList.value = moneyList.value.map((item2, index) => {
           if (item2.type == "0")
           if (item2.type == "0")
@@ -174,7 +182,7 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
             item2.is_open = false;
             item2.is_open = false;
           return item2;
           return item2;
         });
         });
-        moneyInfo.value = {};
+        searchInfo.value.money = "";
       } else if (type2 == "2") {
       } else if (type2 == "2") {
         yearList.value = yearList.value.map((item2, index) => {
         yearList.value = yearList.value.map((item2, index) => {
           if (item2.type == "0")
           if (item2.type == "0")
@@ -183,16 +191,20 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
             item2.is_open = false;
             item2.is_open = false;
           return item2;
           return item2;
         });
         });
-        yearInfo.value = {};
+        searchInfo.value.year = "";
       } else
       } else
         moreList.value = moreList.value.filter((i, index) => i.type != item.type);
         moreList.value = moreList.value.filter((i, index) => i.type != item.type);
+      await clearPage();
+      await searchOther();
     };
     };
-    const toReset = () => {
+    const toReset = async () => {
       toDelete({}, "0");
       toDelete({}, "0");
       toDelete({}, "1");
       toDelete({}, "1");
       toDelete({}, "2");
       toDelete({}, "2");
       moreList.value = [];
       moreList.value = [];
       toClear();
       toClear();
+      await clearPage();
+      await searchOther();
     };
     };
     const toClear = () => {
     const toClear = () => {
       searchList.value = searchList.value.map((i, index) => {
       searchList.value = searchList.value.map((i, index) => {
@@ -258,6 +270,12 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
       } else
       } else
         is_bottom.value = true;
         is_bottom.value = true;
     };
     };
+    const clearPage = () => {
+      list.value = [];
+      skip.value = 0;
+      limit.value = 6;
+      page.value = 0;
+    };
     return (_ctx, _cache) => {
     return (_ctx, _cache) => {
       var _a2;
       var _a2;
       return common_vendor.e({
       return common_vendor.e({
@@ -343,11 +361,11 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
         q: type.value == "3",
         q: type.value == "3",
         t: is_show.value,
         t: is_show.value,
         v: common_vendor.o(toClose),
         v: common_vendor.o(toClose),
-        w: Object.keys(brandInfo.value).length > 0 || Object.keys(moneyInfo.value).length > 0 || Object.keys(yearInfo.value).length > 0 || moreList.value.length > 0
-      }, Object.keys(brandInfo.value).length > 0 || Object.keys(moneyInfo.value).length > 0 || Object.keys(yearInfo.value).length > 0 || moreList.value.length > 0 ? common_vendor.e({
-        x: brandInfo.value && brandInfo.value.type
-      }, brandInfo.value && brandInfo.value.type ? {
-        y: common_vendor.t(brandInfo.value.title),
+        w: searchInfo.value.brand || searchInfo.value.money || moreList.value.length > 0
+      }, searchInfo.value.brand || searchInfo.value.money || moreList.value.length > 0 ? common_vendor.e({
+        x: searchInfo.value && searchInfo.value.brand
+      }, searchInfo.value && searchInfo.value.brand ? {
+        y: common_vendor.t(searchInfo.value.brand),
         z: common_vendor.p({
         z: common_vendor.p({
           color: "#000",
           color: "#000",
           size: "14px",
           size: "14px",
@@ -355,9 +373,9 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
         }),
         }),
         A: common_vendor.o(($event) => toDelete({}, "0"))
         A: common_vendor.o(($event) => toDelete({}, "0"))
       } : {}, {
       } : {}, {
-        B: moneyInfo.value && moneyInfo.value.type
-      }, moneyInfo.value && moneyInfo.value.type ? {
-        C: common_vendor.t(moneyInfo.value.title),
+        B: searchInfo.value && searchInfo.value.money
+      }, searchInfo.value && searchInfo.value.money ? {
+        C: common_vendor.t(searchInfo.value.money),
         D: common_vendor.p({
         D: common_vendor.p({
           color: "#000",
           color: "#000",
           size: "14px",
           size: "14px",
@@ -365,9 +383,9 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
         }),
         }),
         E: common_vendor.o(($event) => toDelete({}, "1"))
         E: common_vendor.o(($event) => toDelete({}, "1"))
       } : {}, {
       } : {}, {
-        F: yearInfo.value && yearInfo.value.type
-      }, yearInfo.value && yearInfo.value.type ? {
-        G: common_vendor.t(yearInfo.value.title),
+        F: searchInfo.value && searchInfo.value.year
+      }, searchInfo.value && searchInfo.value.year ? {
+        G: common_vendor.t(searchInfo.value.year),
         H: common_vendor.p({
         H: common_vendor.p({
           color: "#000",
           color: "#000",
           size: "14px",
           size: "14px",