From 0b8e2e5f0c45f8b202dd52cd4c642a1b9e34726b Mon Sep 17 00:00:00 2001 From: hantao Date: Wed, 2 Jul 2025 20:15:07 +0800 Subject: [PATCH] filter --- pages/index/index.js | 32 ++++++++++++++++++++------------ utils/request.js | 2 +- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/pages/index/index.js b/pages/index/index.js index 239ab46..3019fc1 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -33,7 +33,7 @@ Page({ selectedSort: 'default', selectedBrand: '', selectedPrice: '', - selectedParam: '', + filterParams: {}, mainActiveIndex: 0, selectedSeriesId: null, selectedBrandLabel:"品牌", @@ -74,10 +74,6 @@ Page({ this.setData({ selectedSort: e.detail }); this.reloadList(); }, - onBrandChange(e) { - this.setData({ selectedBrand: e.detail }); - this.reloadList(); - }, onPriceChange(e) { this.setData({ selectedPrice: e.detail }); this.reloadList(); @@ -88,10 +84,24 @@ Page({ this.reloadList(); }, - reloadList() { + async reloadList() { // TODO: 根据筛选值重新加载列表 - console.log('筛选值:', this.data.selectedSort, this.data.selectedBrand, - this.data.selectedPrice, this.data.selectedParam); + const data = { + sort:this.data.selectedSort, + brand:this.data.selectedSeriesId, + price:this.data.selectedPrice, + attr:this.data.filterParams, + } + try { + const raw = await request({ + url: '/admin/wechat/api/car', + method: 'POST', + data: data + }); + console.log(raw) + } catch (err) { + console.error('加载品牌失败', err); + } }, openMap() { const { latitude, longitude, address, name } = this.data.company @@ -195,10 +205,8 @@ Page({ } } }); - console.log('参数筛选值:', filterParams); this.selectComponent('#dropdownItemParam').toggle(false); // 关闭 - - // 这里你可以请求后端过滤后的列表 - // request({ url: '/xxx', data: filterParams }).then(...) + this.setData({filterParams:filterParams}); + this.reloadList(); } }) diff --git a/utils/request.js b/utils/request.js index 2e692b5..f044fd0 100644 --- a/utils/request.js +++ b/utils/request.js @@ -1,4 +1,4 @@ -const BASE_URL = 'http://192.168.1.11:8089/'; // 👈 换成你的后端地址 +const BASE_URL = 'http://127.0.0.1:8089/'; // 👈 换成你的后端地址 function request({ url, method = 'GET', data = {}, header = {} }) { const token = '';