feat: add product to cart from main page

This commit is contained in:
Vlad Stan 2023-07-13 11:01:14 +03:00
parent 7516e0bc99
commit e72f013d84
7 changed files with 14 additions and 53 deletions

View file

@ -28,7 +28,7 @@
<q-infinite-scroll v-if="showProducts" @load="onLoad" :offset="250">
<div class="row q-col-gutter-md">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3" v-for="(item, idx) in partialProducts" :key="idx">
<product-card :product="item" @change-page="changePageM"></product-card>
<product-card :product="item" @change-page="changePageM" @add-to-cart="addToCart"></product-card>
</div>
</div>
<template v-if="lastProductIndex < filteredProducts.length" v-slot:loading>

View file

@ -62,7 +62,9 @@ async function customerMarket(path) {
this.partialProducts.push(...this.filteredProducts.slice(0, this.lastProductIndex))
setTimeout(() => { this.showProducts = true }, 0)
console.log('### xxx this.filteredProducts', this.lastProductIndex, this.filteredProducts)
},
addToCart(item) {
this.$emit('add-to-cart', item)
},
changePageM(page, opts) {
this.$emit('change-page', page, opts)
@ -109,7 +111,6 @@ async function customerMarket(path) {
},
created() {
this.filteredProducts = [...this.products]
console.log('#### created this.filteredProducts', this.filteredProducts)
this.lastProductIndex = Math.min(this.filteredProducts.length, 24)
this.partialProducts.push(...this.filteredProducts.slice(0, this.lastProductIndex))
}

View file

@ -105,52 +105,6 @@ async function customerStall(path) {
},
addToCart(item) {
this.$emit('add-to-cart', item)
// console.log('### addToCart', item)
// console.log('### this.cart.products', this.cart.products)
// let prod = this.cart.products
// if (prod.has(item.id)) {
// let qty = prod.get(item.id).quantity
// if (qty == item.quantity) {
// this.$q.notify({
// type: 'warning',
// message: `${item.name} only has ${item.quantity} units!`,
// icon: 'production_quantity_limits'
// })
// return
// }
// prod.set(item.id, {
// ...prod.get(item.id),
// quantity: qty + 1
// })
// } else {
// prod.set(item.id, {
// name: item.name,
// quantity: 1,
// price: item.price,
// image: item?.images[0] || null
// })
// }
// this.$q.notify({
// type: 'positive',
// message: `'${item.name}' added to cart`,
// icon: 'thumb_up'
// })
// this.cart.products = prod
// this.updateCart()
// },
// removeFromCart(item, del = false) {
// let prod = this.cart.products
// let qty = prod.get(item.id).quantity
// if (qty == 1 || del) {
// prod.delete(item.id)
// } else {
// prod.set(item.id, {
// ...prod.get(item.id),
// quantity: qty - 1
// })
// }
// this.cart.products = prod
// this.updateCart()
},
updateCart() {
this.cart.total = 0

View file

@ -15,7 +15,6 @@ async function marketConfig(path) {
},
methods: {
addMerchant: async function () {
console.log('### market config', this.merchants)
if (!isValidKey(this.inputPubkey, 'npub')) {
this.$q.notify({
message: 'Invalid Public Key!',

View file

@ -4,7 +4,7 @@
alt="Product Image" loading="lazy" spinner-color="white" fit="contain" height="300px"></q-img>
<q-card-section class="q-pb-xs q-pt-md">
<q-btn v-if="isStall" round :disabled="product.quantity < 1" color="primary" rounded icon="shopping_cart" size="lg" style="
<q-btn round :disabled="product.quantity < 1" color="primary" rounded icon="shopping_cart" size="lg" style="
position: absolute;
top: 0;
right: 0;