From 39c119ffe4764756cbeb59f0633f899296c80099 Mon Sep 17 00:00:00 2001 From: Agent Date: Fri, 27 Mar 2026 00:58:12 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E5=93=81=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E9=A1=B5=E9=9D=A2=EF=BC=9A=E5=B7=A6=E4=BE=A7=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E6=A0=8F+=E5=8F=B3=E4=BE=A7=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/product/select.vue | 173 ++++++++++++++++++++++++----------- 1 file changed, 122 insertions(+), 51 deletions(-) diff --git a/src/pages/product/select.vue b/src/pages/product/select.vue index 1ed1d0a..4dd5996 100644 --- a/src/pages/product/select.vue +++ b/src/pages/product/select.vue @@ -1,38 +1,52 @@ @@ -43,6 +57,8 @@ export default { data() { return { keyword: '', + categoryId: '', + categories: [], productList: [], page: 1, pageSize: 50, @@ -50,14 +66,24 @@ export default { } }, onLoad() { + this.loadCategories() this.getProducts() }, methods: { + async loadCategories() { + try { + const categories = await productApi.getCategories() + this.categories = categories || [] + } catch (e) { + console.error(e) + } + }, async getProducts() { this.loading = true try { const res = await productApi.getProducts({ keyword: this.keyword, + categoryId: this.categoryId, page: this.page, pageSize: this.pageSize }) @@ -68,12 +94,16 @@ export default { this.loading = false } }, + selectCategory(id) { + this.categoryId = id + this.page = 1 + this.getProducts() + }, search() { this.page = 1 this.getProducts() }, selectProduct(item) { - // 返回上一页并传递选中的商品 const pages = getCurrentPages() const prevPage = pages[pages.length - 2] prevPage.$vm.addProduct(item) @@ -83,48 +113,81 @@ export default { } - + +.empty-text { + font-size: 28rpx; + color: #999; + margin-top: 20rpx; +} + \ No newline at end of file