From 19a8584fa08a7a4c85e499d55736d5dac4fa5bf0 Mon Sep 17 00:00:00 2001 From: MojtabaSoumi Date: Sat, 31 Jan 2026 10:19:21 +0330 Subject: [PATCH] 1404/11/11-add description in product --- src/views/base/cart/index.vue | 11 +++++++-- .../base/products/components/ProductItem.vue | 6 +++++ .../components/ProductItemVertical.vue | 6 +++++ src/views/base/products/product/[id].vue | 24 ++++++++++--------- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/views/base/cart/index.vue b/src/views/base/cart/index.vue index a56f39e..6d84edb 100644 --- a/src/views/base/cart/index.vue +++ b/src/views/base/cart/index.vue @@ -36,7 +36,7 @@
@@ -165,7 +165,14 @@ const totalPrice = computed(() => { return cartStore.cartItems.reduce((sum, item) => sum + item.totalPrice, 0) }) -function getProductImage(type?: string) { +function getProductImage(product: any) { + // Check if product has file field from server with src property + if (product?.file?.src) { + return product.file.src + } + + // Fallback to local images based on group_type if file is empty or doesn't exist + const type = product?.group_type switch (type) { case 'گوی': return goyImg diff --git a/src/views/base/products/components/ProductItem.vue b/src/views/base/products/components/ProductItem.vue index 8e22730..b7bca38 100644 --- a/src/views/base/products/components/ProductItem.vue +++ b/src/views/base/products/components/ProductItem.vue @@ -132,6 +132,12 @@ const amountProduct = computed(() => { }) const productImage = computed(() => { + // Check if product has file field from server with src property + if (props.ProductItem?.file?.src) { + return props.ProductItem.file.src + } + + // Fallback to local images based on group_type if file is empty or doesn't exist switch (props.ProductItem.group_type) { case 'گوی': return goyImg diff --git a/src/views/base/products/components/ProductItemVertical.vue b/src/views/base/products/components/ProductItemVertical.vue index 6547418..b5468dd 100644 --- a/src/views/base/products/components/ProductItemVertical.vue +++ b/src/views/base/products/components/ProductItemVertical.vue @@ -66,6 +66,12 @@ const amountProduct = computed(() => { }) const productImage = computed(() => { + // Check if product has file field from server with src property + if (props.ProductItem?.file?.src) { + return props.ProductItem.file.src + } + + // Fallback to local images based on group_type if file is empty or doesn't exist switch (props.ProductItem.group_type) { case 'گوی': return goyImg diff --git a/src/views/base/products/product/[id].vue b/src/views/base/products/product/[id].vue index 3d536d7..348cfc8 100644 --- a/src/views/base/products/product/[id].vue +++ b/src/views/base/products/product/[id].vue @@ -7,12 +7,7 @@
- - - - - - +
@@ -46,10 +41,10 @@ -
+
توضیحات محصول:
- -
شمش طلای نقش برجسته ونوس ۱ گرمی انتخابی ظریف و ارزشمند برای سرمایه‌گذاری و هدیه است. این شمش از طلای خالص با عیار بالا ساخته شده و نقش برجسته‌ی الهه ونوس، نمادی از زیبایی و ظرافت، جلوه‌ای هنری و خاص به آن بخشیده است. وزن دقیق ۱ گرم، ابعاد مناسب و بسته‌بندی شکیل، این محصول را به گزینه‌ای ایده‌آل برای نگهداری ارزش، هدیه‌های خاص و کلکسیون‌های طلا تبدیل می‌کند.
+
{{ product?.description }}
+
@@ -71,7 +66,7 @@
@@ -225,7 +220,14 @@ function goToProduct(id: number) { router.push({ name: 'productDetail', params: { id } }) } -function getProductImage(type?: string) { +function getProductImage(product: any) { + // Check if product has file field from server with src property + if (product?.file?.src) { + return product.file.src + } + + // Fallback to local images based on group_type if file is empty or doesn't exist + const type = product?.group_type switch (type) { case 'گوی': return goyImg