Fix product discount bug
This commit is contained in:
@@ -47,10 +47,11 @@ withDefaults(defineProps<Props>(), {
|
|||||||
:title="product.name"
|
:title="product.name"
|
||||||
:picture="product.image ?? product.variants[0].images[0].image"
|
:picture="product.image ?? product.variants[0].images[0].image"
|
||||||
:colors="product.colors"
|
:colors="product.colors"
|
||||||
:price="product.variants[0].price_after_discount ?? product.variants[0].price"
|
:price="product.best_deal_price_before_discount"
|
||||||
:rate="product.rating"
|
:rate="product.rating"
|
||||||
:dark-layer="true"
|
:dark-layer="true"
|
||||||
:tag="`${product.variants[0].discount}% تخفیف`"
|
:tag="product.best_deal_discount > 0 ? `${product.best_deal_discount}% تخفیف` : undefined"
|
||||||
|
:price-after="product.best_deal_discount > 0 ? product.best_deal_price_after_discount : undefined"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -93,9 +93,13 @@ const onSwiper = (swiper: SwiperClass) => {
|
|||||||
:title="product.name"
|
:title="product.name"
|
||||||
:picture="product.image ?? product.variants[0].images[0].image"
|
:picture="product.image ?? product.variants[0].images[0].image"
|
||||||
:colors="product.colors"
|
:colors="product.colors"
|
||||||
:price="product.variants[0].price"
|
|
||||||
:rate="product.rating"
|
:rate="product.rating"
|
||||||
:dark-layer="true"
|
:dark-layer="true"
|
||||||
|
:price="product.best_deal_price_before_discount"
|
||||||
|
:tag="product.best_deal_discount > 0 ? `${product.best_deal_discount}% تخفیف` : undefined"
|
||||||
|
:price-after="
|
||||||
|
product.best_deal_discount > 0 ? product.best_deal_price_after_discount : undefined
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
</SwiperSlide>
|
</SwiperSlide>
|
||||||
</Swiper>
|
</Swiper>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ type Props = {
|
|||||||
colors: string[];
|
colors: string[];
|
||||||
price: string;
|
price: string;
|
||||||
picture: string;
|
picture: string;
|
||||||
|
priceAfter?: string;
|
||||||
tag?: string;
|
tag?: string;
|
||||||
rate?: number;
|
rate?: number;
|
||||||
darkLayer?: boolean;
|
darkLayer?: boolean;
|
||||||
@@ -110,10 +111,14 @@ const parallaxStyle = computed(() => {
|
|||||||
<span class="typo-sub-h-sm font-normal w-full truncate">
|
<span class="typo-sub-h-sm font-normal w-full truncate">
|
||||||
{{ title }}
|
{{ title }}
|
||||||
</span>
|
</span>
|
||||||
<div class="flex items-center justify-between w-full mt-1">
|
<div class="flex flex-col w-full mt-1">
|
||||||
<span class="typo-p-xs !font-bold whitespace-nowrap">
|
<span
|
||||||
|
class="typo-p-xs whitespace-nowrap"
|
||||||
|
:class="priceAfter ? 'line-through' : '!font-bold'"
|
||||||
|
>
|
||||||
{{ price }}
|
{{ price }}
|
||||||
</span>
|
</span>
|
||||||
|
<span v-if="priceAfter" class="whitespace-nowrap !font-bold">{{ priceAfter }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Vendored
+14
-1
@@ -107,11 +107,24 @@ declare global {
|
|||||||
colors: string[];
|
colors: string[];
|
||||||
added_to_favorites: boolean;
|
added_to_favorites: boolean;
|
||||||
image: string | null;
|
image: string | null;
|
||||||
|
best_deal_price_before_discount: string;
|
||||||
|
best_deal_price_after_discount: string;
|
||||||
|
best_deal_discount: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ProductListItem = Pick<
|
type ProductListItem = Pick<
|
||||||
Product,
|
Product,
|
||||||
"id" | "variants" | "name" | "rating" | "slug" | "category" | "colors" | "image"
|
| "id"
|
||||||
|
| "variants"
|
||||||
|
| "name"
|
||||||
|
| "rating"
|
||||||
|
| "slug"
|
||||||
|
| "category"
|
||||||
|
| "colors"
|
||||||
|
| "image"
|
||||||
|
| "best_deal_discount"
|
||||||
|
| "best_deal_price_after_discount"
|
||||||
|
| "best_deal_price_before_discount"
|
||||||
>;
|
>;
|
||||||
|
|
||||||
type Article = {
|
type Article = {
|
||||||
|
|||||||
Reference in New Issue
Block a user