feat: show market categories
This commit is contained in:
parent
27e55b00b3
commit
79ce34467c
2 changed files with 36 additions and 1 deletions
|
|
@ -148,6 +148,19 @@ const market = async () => {
|
|||
|
||||
allCartsItemCount() {
|
||||
return this.shoppingCarts.map(s => s.products).flat().reduce((t, p) => t + p.orderedQuantity, 0)
|
||||
},
|
||||
|
||||
allCategories() {
|
||||
const categories = this.products.map(p => p.categories).flat().filter(c => !!c)
|
||||
const countedCategories = categories.reduce((all, c) => {
|
||||
all[c] = (all[c] || 0) + 1
|
||||
return all
|
||||
}, {})
|
||||
const x = Object.keys(countedCategories)
|
||||
.map(category => ({ category, count: countedCategories[category] }))
|
||||
.sort((a,b) => b.count - a.count)
|
||||
console.log('### x', x)
|
||||
return x
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue