.
This commit is contained in:
+166
-10
@@ -5,6 +5,7 @@ import { useAuthStore } from '@/stores/auth'
|
||||
import { useCrmStore } from '@/stores/crm'
|
||||
import { useFavoritesStore } from '@/stores/favorites'
|
||||
import { fetchAgentProfile, fetchBanners, type AppBannerDto } from '@/services/agentApi'
|
||||
import { fetchMySuggestions, type ProductSuggestionDto } from '@/services/suggestionsApi'
|
||||
import IconBell from '@/components/icons/IconBell.vue'
|
||||
import IconChevronLeft from '@/components/icons/IconChevronLeft.vue'
|
||||
import levelMedalIcon from '@/assets/images/level-medal.webp'
|
||||
@@ -30,6 +31,7 @@ const favorites = useFavoritesStore()
|
||||
const loading = ref(true)
|
||||
const error = ref<string | null>(null)
|
||||
const newest = ref<CatalogProductCard[]>([])
|
||||
const suggestions = ref<ProductSuggestionDto[]>([])
|
||||
const favError = ref<string | null>(null)
|
||||
const agentLevel = ref<{
|
||||
label: string
|
||||
@@ -47,17 +49,17 @@ type QuickAction = {
|
||||
}
|
||||
|
||||
const customerActions: QuickAction[] = [
|
||||
{ id: 'qa-club', label: 'باشگاه مشتریان', to: '/profile', image: quickClubCrownIcon },
|
||||
{ id: 'qa-cat', label: 'دسته بندی', to: '/categories', image: quickCategoriesGridIcon },
|
||||
{ id: 'qa-new', label: 'محصولات جدید', to: '/products', image: quickNewProductsIcon },
|
||||
{ id: 'qa-swatch', label: 'درخواست کالیته', to: '/catalog-request', image: quickCatalogRequestIcon },
|
||||
{ id: 'qa-cat', label: 'دسته بندی', to: '/categories', image: quickCategoriesGridIcon },
|
||||
{ id: 'qa-club', label: 'آخرین وضعیت سفارش', to: '/orders/latest-status', image:'/' },
|
||||
{ id: 'qa-swatch', label: 'آخرین درخواست کالیته', to: '/catalog-requests/latest-status', image: quickCatalogRequestIcon },
|
||||
]
|
||||
|
||||
const agentActions: QuickAction[] = [
|
||||
{ id: 'qa-customers', label: 'باشگاه مشتریان', to: '/customers', image: quickClubCrownIcon },
|
||||
{ id: 'qa-new', label: 'محصولات جدید', to: '/products', image: quickNewProductsIcon },
|
||||
{ id: 'qa-cat', label: 'دسته بندی', to: '/categories', image: quickCategoriesGridIcon },
|
||||
{ id: 'qa-swatch', label: 'درخواست کالیته', to: '/catalog-request', image: quickCatalogRequestIcon },
|
||||
{ id: 'qa-customers', label: 'آخرین وضعیت سفارش', to: '/orders/latest-status', image: '/' },
|
||||
{ id: 'qa-swatch', label: 'آخرین درخواست کالیته', to: '/catalog-requests/latest-status', image: quickCatalogRequestIcon },
|
||||
]
|
||||
|
||||
const actions = computed(() => (auth.isAgent ? agentActions : customerActions))
|
||||
@@ -167,6 +169,12 @@ onMounted(async () => {
|
||||
} catch {
|
||||
// سطح از /auth/me؛ عدم دیپلوی agent API خانه را خراب نکند
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
suggestions.value = await fetchMySuggestions()
|
||||
} catch {
|
||||
suggestions.value = []
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
error.value = e instanceof Error ? e.message : 'بارگذاری خانه ناموفق بود.'
|
||||
@@ -299,7 +307,7 @@ async function toggleFavorite(productId: string) {
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<section class="level-card" aria-label="سطح عضویت">
|
||||
<section v-if="auth.isAgent" class="level-card" aria-label="سطح عضویت">
|
||||
<div class="level-card__top">
|
||||
<div class="level-card__identity">
|
||||
<img
|
||||
@@ -339,6 +347,38 @@ 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>
|
||||
|
||||
<section class="section">
|
||||
<div class="section__head">
|
||||
<h3 class="section__title">جدیدترین محصولات</h3>
|
||||
@@ -347,7 +387,7 @@ async function toggleFavorite(productId: string) {
|
||||
<IconChevronLeft :size="14" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="product-row">
|
||||
<div class="product-row scroll-x">
|
||||
<article
|
||||
v-for="(item, index) in newest"
|
||||
:key="item.id"
|
||||
@@ -777,6 +817,110 @@ 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);
|
||||
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;
|
||||
@@ -803,12 +947,10 @@ async function toggleFavorite(productId: string) {
|
||||
.product-row {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
overflow-x: auto;
|
||||
padding-bottom: 0;
|
||||
margin-inline: calc(-1 * var(--page-padding));
|
||||
padding-inline: var(--page-padding);
|
||||
scroll-snap-type: x mandatory;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
scroll-snap-type: x proximity;
|
||||
}
|
||||
|
||||
.product-card {
|
||||
@@ -977,6 +1119,20 @@ async function toggleFavorite(productId: string) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user