feat: harden phase one workflows

This commit is contained in:
王鹏
2026-07-14 16:04:51 +08:00
parent 47f4a24760
commit 767534df48
103 changed files with 4849 additions and 388 deletions

View File

@@ -5,6 +5,7 @@ Page({
loading: false,
categories: [],
activeCategoryId: null,
keyword: '',
products: []
},
@@ -14,7 +15,7 @@ Page({
load() {
this.setData({ loading: true })
Promise.all([listCategories(), listProducts()])
Promise.all([listCategories(), listProducts(null, this.data.keyword)])
.then(([categories, products]) => {
this.setData({
categories: categories || [],
@@ -28,14 +29,24 @@ Page({
chooseCategory(event) {
const categoryId = event.currentTarget.dataset.id
this.setData({ activeCategoryId: categoryId })
listProducts(categoryId)
listProducts(categoryId, this.data.keyword)
.then((products) => this.setData({ products: products || [] }))
.catch((error) => wx.showToast({ title: error.message, icon: 'none' }))
},
clearCategory() {
this.setData({ activeCategoryId: null })
listProducts()
listProducts(null, this.data.keyword)
.then((products) => this.setData({ products: products || [] }))
.catch((error) => wx.showToast({ title: error.message, icon: 'none' }))
},
onKeywordInput(event) {
this.setData({ keyword: event.detail.value })
},
search() {
listProducts(this.data.activeCategoryId, this.data.keyword)
.then((products) => this.setData({ products: products || [] }))
.catch((error) => wx.showToast({ title: error.message, icon: 'none' }))
},