change image src in product card

This commit is contained in:
mohadese-nm
2024-07-24 20:11:46 +04:30
parent 03d14fe36c
commit 3400b200c7
+5 -4
View File
@@ -1,7 +1,7 @@
<template> <template>
<router-link :to="`/product/${uid}`"> <router-link :to="`/product/${uid}`">
<article :class="['product-card', `product-card-${type}`]"> <article :class="['product-card', `product-card-${type}`]">
<img :src="coverPath" :alt="title" /> <img :src="coverImage" :alt="title" />
<div> <div>
<h2 v-if="type != 'minimal'"> <h2 v-if="type != 'minimal'">
{{ category[category.length - 1]?.name }} {{ category[category.length - 1]?.name }}
@@ -38,7 +38,8 @@ const props = defineProps({
data: { type: Object, default: {} }, data: { type: Object, default: {} },
type: { type: String, default: 'main' } type: { type: String, default: 'main' }
}) })
const { _id: id, uid, coverPath, category = [], title, price, specialPrice, stars, orderRange } = props.data
const { _id: id, uid, coverImage, category = [], title, price, specialPrice, stars, orderRange } = props.data
const favorite = useFavoritesStore() const favorite = useFavoritesStore()
const like = computed(() => favorite.find(id)) const like = computed(() => favorite.find(id))
@@ -46,7 +47,7 @@ const like = computed(() => favorite.find(id))
const cart = useCartStore() const cart = useCartStore()
const quantity = computed({ const quantity = computed({
get: () => cart.find(id)?.quantity || 0, get: () => cart.find(id)?.quantity || 0,
set: (v) => cart.update(id, v) set: (v) => cart.update(props.data, v)
}) })
const starsClass = (i) => (i > stars ? 'opacity-25' : '') const starsClass = (i) => (i > stars ? 'opacity-25' : '')
@@ -56,7 +57,7 @@ const numberFormat = (number) =>
<style lang="scss"> <style lang="scss">
.product-card { .product-card {
box-shadow: 0px 2px 14px 0px #e5eef5; box-shadow: 0px 2px 20px 0px #e5eef5;
@apply bg-white rounded-[0.6rem] border flex flex-col relative; @apply bg-white rounded-[0.6rem] border flex flex-col relative;
&>img { &>img {