feat: show total cart item count
This commit is contained in:
parent
2b0664b613
commit
e1b2a4a479
2 changed files with 13 additions and 5 deletions
|
|
@ -124,6 +124,10 @@ const market = async () => {
|
||||||
},
|
},
|
||||||
canEditConfig() {
|
canEditConfig() {
|
||||||
return this.account && this.account.pubkey == this.config?.pubkey
|
return this.account && this.account.pubkey == this.config?.pubkey
|
||||||
|
},
|
||||||
|
|
||||||
|
allCartsItemCount() {
|
||||||
|
return this.shoppingCarts.map(s => s.products).flat().reduce((t, p) => t + p.orderedQuantity, 0)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
|
|
@ -567,8 +571,6 @@ const market = async () => {
|
||||||
},
|
},
|
||||||
|
|
||||||
addProductToCart(item) {
|
addProductToCart(item) {
|
||||||
console.log('### addProductToCart:', item)
|
|
||||||
|
|
||||||
let stallCart = this.shoppingCarts.find(s => s.id === item.stall_id)
|
let stallCart = this.shoppingCarts.find(s => s.id === item.stall_id)
|
||||||
if (!stallCart) {
|
if (!stallCart) {
|
||||||
stallCart = {
|
stallCart = {
|
||||||
|
|
|
||||||
|
|
@ -181,10 +181,16 @@
|
||||||
<q-btn v-else @click="accountDialog.show = true" color="gray" icon="person_add" flat
|
<q-btn v-else @click="accountDialog.show = true" color="gray" icon="person_add" flat
|
||||||
size="lg"><q-tooltip>User
|
size="lg"><q-tooltip>User
|
||||||
Config</q-tooltip></q-btn>
|
Config</q-tooltip></q-btn>
|
||||||
<q-btn color="gray" icon="shopping_cart" flat size="lg"
|
<q-btn color="gray" icon="shopping_cart" dense round flat size="lg"
|
||||||
@click="setActivePage('shopping-cart-list')"><q-tooltip>Shopping
|
@click="setActivePage('shopping-cart-list')">
|
||||||
Cart</q-tooltip></q-btn>
|
<q-tooltip>Shopping Cart</q-tooltip>
|
||||||
|
|
||||||
|
<q-badge v-if="allCartsItemCount" color="secondary" floating>
|
||||||
|
<span v-text="allCartsItemCount"></span>
|
||||||
|
</q-badge>
|
||||||
|
</q-btn>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</q-toolbar>
|
</q-toolbar>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue