feat: harden phase one workflows
This commit is contained in:
@@ -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' }))
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user