7/7/405
This commit is contained in:
+63
-150
@@ -22,6 +22,7 @@ import { useGoBack } from '@/composables/useGoBack'
|
||||
import AuthThemeToggle from '@/components/ui/AuthThemeToggle.vue'
|
||||
import PageSkeleton from '@/components/ui/PageSkeleton.vue'
|
||||
import UserAvatar from '@/components/ui/UserAvatar.vue'
|
||||
import HomeSuggestionsSection from '@/components/home/HomeSuggestionsSection.vue'
|
||||
|
||||
const router = useRouter()
|
||||
const { goBack } = useGoBack('/')
|
||||
@@ -32,6 +33,7 @@ const loading = ref(true)
|
||||
const error = ref<string | null>(null)
|
||||
const newest = ref<CatalogProductCard[]>([])
|
||||
const suggestions = ref<ProductSuggestionDto[]>([])
|
||||
const browseProducts = ref<CatalogProductCard[]>([])
|
||||
const favError = ref<string | null>(null)
|
||||
const agentLevel = ref<{
|
||||
label: string
|
||||
@@ -62,6 +64,22 @@ const agentActions: QuickAction[] = [
|
||||
|
||||
const actions = computed(() => (auth.isAgent ? agentActions : customerActions))
|
||||
|
||||
const suggestionsForHome = computed(() => {
|
||||
const byId = new Map(browseProducts.value.map((p) => [p.id, p]))
|
||||
return suggestions.value.map((item) => {
|
||||
const product = byId.get(item.productId)
|
||||
return {
|
||||
...item,
|
||||
composition: item.composition?.trim() || product?.composition?.trim() || '',
|
||||
widthCm: item.widthCm ?? product?.widthCm,
|
||||
colors: item.colors?.length ? item.colors : product?.colors ?? [],
|
||||
colorImages: item.colorImages?.some(Boolean)
|
||||
? item.colorImages
|
||||
: product?.colorImages,
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const FALLBACK_BANNER: AppBannerDto = {
|
||||
id: 'fallback',
|
||||
slot: 'home_hero',
|
||||
@@ -147,7 +165,10 @@ onMounted(async () => {
|
||||
error.value = null
|
||||
try {
|
||||
const [products, homeBanners] = await Promise.all([
|
||||
crm.loadBrowseProducts(),
|
||||
crm.loadBrowseProducts().then((list) => {
|
||||
browseProducts.value = list
|
||||
return list
|
||||
}),
|
||||
fetchBanners('home_hero').catch(() => [] as AppBannerDto[]),
|
||||
favorites.hydrate(),
|
||||
])
|
||||
@@ -240,7 +261,10 @@ async function toggleFavorite(productId: string) {
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="page__scroll page__scroll--with-nav home-scroll">
|
||||
<div
|
||||
class="page__scroll page__scroll--with-nav home-scroll"
|
||||
:class="{ 'home-scroll--customer': !auth.isAgent }"
|
||||
>
|
||||
<p v-if="error" class="home-error">{{ error }}</p>
|
||||
<PageSkeleton v-else-if="loading" variant="home" />
|
||||
<template v-else>
|
||||
@@ -345,37 +369,11 @@ async function toggleFavorite(productId: string) {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-else class="suggest-card" aria-label="پیشنهاد اختصاصی">
|
||||
<div class="suggest-card__head">
|
||||
<h3 class="suggest-card__title">پیشنهاد اختصاصی ما برای شما</h3>
|
||||
<p v-if="!suggestions.length" class="suggest-card__empty">
|
||||
هنوز پیشنهاد اختصاصی برای شما ثبت نشده است.
|
||||
</p>
|
||||
</div>
|
||||
<div v-if="suggestions.length" class="suggest-card__row scroll-x">
|
||||
<article
|
||||
v-for="(item, index) in suggestions"
|
||||
:key="item.id"
|
||||
class="suggest-card__item"
|
||||
@click="go(`/product?id=${item.productId}`)"
|
||||
>
|
||||
<div
|
||||
class="suggest-card__image"
|
||||
:class="`suggest-card__image--${index % 3}`"
|
||||
:style="item.imageUrl ? { backgroundImage: `url(${item.imageUrl})` } : undefined"
|
||||
>
|
||||
<span v-if="item.isNew" class="suggest-card__badge">جدید</span>
|
||||
</div>
|
||||
<div class="suggest-card__body">
|
||||
<strong class="suggest-card__name">{{ item.productName }}</strong>
|
||||
<span class="suggest-card__sub">
|
||||
{{ item.subtitle || item.catalogName || item.productCode }}
|
||||
</span>
|
||||
<p v-if="item.note" class="suggest-card__note">{{ item.note }}</p>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
<HomeSuggestionsSection
|
||||
v-if="!auth.isAgent"
|
||||
class="home-suggestions"
|
||||
:items="suggestionsForHome"
|
||||
/>
|
||||
|
||||
<section class="section">
|
||||
<div class="section__head">
|
||||
@@ -718,6 +716,19 @@ async function toggleFavorite(productId: string) {
|
||||
font-size: 0.7rem;
|
||||
text-align: center;
|
||||
line-height: 1.4;
|
||||
/* Force navy color for quick-card labels (override global/link styles on server) */
|
||||
color: var(--color-accent-navy) !important;
|
||||
}
|
||||
|
||||
/* Keep the same color on hover/focus so it doesn't turn default link/blue */
|
||||
.quick-card:hover .quick-card__label,
|
||||
.quick-card:focus .quick-card__label {
|
||||
color: var(--color-accent-navy) !important;
|
||||
}
|
||||
|
||||
/* Ensure dark mode keeps readable navy (adjust if you prefer a different dark color) */
|
||||
html.dark .quick-card__label {
|
||||
color: var(--color-accent-navy) !important;
|
||||
}
|
||||
|
||||
.level-card {
|
||||
@@ -815,110 +826,10 @@ async function toggleFavorite(productId: string) {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.suggest-card {
|
||||
background: var(--color-surface);
|
||||
border-radius: 18px;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--color-border);
|
||||
.home-suggestions {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.suggest-card__head {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.suggest-card__title {
|
||||
margin: 0;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 800;
|
||||
color: var(--color-accent-navy);
|
||||
}
|
||||
|
||||
.suggest-card__empty {
|
||||
margin: 8px 0 0;
|
||||
font-size: 0.8rem;
|
||||
color: var(--color-text-muted);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.suggest-card__row {
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
gap: 10px;
|
||||
margin-inline: -16px;
|
||||
padding-inline: 16px;
|
||||
padding-bottom: 4px;
|
||||
scroll-snap-type: x proximity;
|
||||
}
|
||||
|
||||
.suggest-card__item {
|
||||
flex: 0 0 132px;
|
||||
width: 132px;
|
||||
scroll-snap-align: start;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.suggest-card__image {
|
||||
position: relative;
|
||||
height: 92px;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(145deg, #e8ecf0, #d5dbe3);
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
.suggest-card__image--0 {
|
||||
background-color: #e7dfd6;
|
||||
}
|
||||
|
||||
.suggest-card__image--1 {
|
||||
background-color: #dfe8ea;
|
||||
}
|
||||
|
||||
.suggest-card__image--2 {
|
||||
background-color: #ebe4df;
|
||||
}
|
||||
|
||||
.suggest-card__badge {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
background: var(--color-primary);
|
||||
color: #fff;
|
||||
font-size: 0.62rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.suggest-card__body {
|
||||
padding: 8px 2px 0;
|
||||
}
|
||||
|
||||
.suggest-card__name {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
font-size: 0.78rem;
|
||||
line-height: 1.35;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.suggest-card__sub {
|
||||
display: block;
|
||||
font-size: 0.68rem;
|
||||
color: var(--color-text-muted);
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.suggest-card__note {
|
||||
margin: 4px 0 0;
|
||||
font-size: 0.65rem;
|
||||
color: var(--color-primary);
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.section__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -1057,7 +968,6 @@ async function toggleFavorite(productId: string) {
|
||||
html.dark .section__title,
|
||||
html.dark .home-desk-head__title,
|
||||
html.dark .level-card__name,
|
||||
html.dark .suggest-card__title,
|
||||
html.dark .product-card__name {
|
||||
color: #fff;
|
||||
}
|
||||
@@ -1110,15 +1020,31 @@ html.dark .product-card__sub {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.home-scroll--customer {
|
||||
grid-template-areas:
|
||||
'hero hero hero'
|
||||
'quick quick quick'
|
||||
'suggest suggest suggest'
|
||||
'products products products';
|
||||
}
|
||||
|
||||
.home-scroll--customer .hero-banner {
|
||||
aspect-ratio: 2.35 / 1;
|
||||
}
|
||||
|
||||
.home-suggestions {
|
||||
grid-area: suggest;
|
||||
}
|
||||
|
||||
.hero-banner {
|
||||
grid-area: hero;
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
height: auto;
|
||||
height: 100%;
|
||||
aspect-ratio: 2.1 / 1;
|
||||
align-self: start;
|
||||
align-self: stretch;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
@@ -1132,19 +1058,6 @@ html.dark .product-card__sub {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.suggest-card {
|
||||
grid-area: level;
|
||||
padding: 20px 22px;
|
||||
align-self: start;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.suggest-card__row {
|
||||
margin-inline: -22px;
|
||||
padding-inline: 22px;
|
||||
}
|
||||
|
||||
.quick-grid {
|
||||
grid-area: quick;
|
||||
display: grid;
|
||||
|
||||
Reference in New Issue
Block a user