change UI & fix bugs
This commit is contained in:
+305
-56
@@ -7,12 +7,12 @@ import { useFavoritesStore } from '@/stores/favorites'
|
||||
import { fetchAgentProfile, fetchBanners, type AppBannerDto } from '@/services/agentApi'
|
||||
import IconBell from '@/components/icons/IconBell.vue'
|
||||
import IconChevronLeft from '@/components/icons/IconChevronLeft.vue'
|
||||
import IconMedal from '@/components/icons/IconMedal.vue'
|
||||
import levelMedalIcon from '@/assets/images/level-medal.webp'
|
||||
import quickClubCrownIcon from '@/assets/images/quick-club-crown.webp'
|
||||
import quickCategoriesGridIcon from '@/assets/images/quick-categories-grid.webp'
|
||||
import quickCatalogRequestIcon from '@/assets/images/quick-catalog-request.webp'
|
||||
import quickNewProductsIcon from '@/assets/images/quick-new-products.webp'
|
||||
import IconHeart from '@/components/icons/IconHeart.vue'
|
||||
import IconCatalog from '@/components/icons/IconCatalog.vue'
|
||||
import IconDiamond from '@/components/icons/IconDiamond.vue'
|
||||
import IconLayoutGrid from '@/components/icons/IconLayoutGrid.vue'
|
||||
import IconProfile from '@/components/icons/IconProfile.vue'
|
||||
import IconChevronBack from '@/components/icons/IconChevronBack.vue'
|
||||
import { formatNumber } from '@/utils/format'
|
||||
import type { CatalogProductCard } from '@/types/crm'
|
||||
@@ -38,18 +38,26 @@ const agentLevel = ref<{
|
||||
progressPercent: number
|
||||
} | null>(null)
|
||||
|
||||
const customerActions: Array<{ id: string; label: string; to: string; icon: Component }> = [
|
||||
{ id: 'qa-club', label: 'باشگاه مشتریان', to: '/profile', icon: IconProfile },
|
||||
{ id: 'qa-cat', label: 'دسته بندی', to: '/categories', icon: IconLayoutGrid },
|
||||
{ id: 'qa-new', label: 'محصولات جدید', to: '/products', icon: IconDiamond },
|
||||
{ id: 'qa-swatch', label: 'درخواست کالیته', to: '/catalog-request', icon: IconCatalog },
|
||||
type QuickAction = {
|
||||
id: string
|
||||
label: string
|
||||
to: string
|
||||
icon?: Component
|
||||
image?: string
|
||||
}
|
||||
|
||||
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 },
|
||||
]
|
||||
|
||||
const agentActions: Array<{ id: string; label: string; to: string; icon: Component }> = [
|
||||
{ id: 'qa-customers', label: 'مشتریان من', to: '/customers', icon: IconProfile },
|
||||
{ id: 'qa-reminders', label: 'یادآورها', to: '/reminders', icon: IconBell },
|
||||
{ id: 'qa-cat', label: 'دسته بندی', to: '/categories', icon: IconLayoutGrid },
|
||||
{ id: 'qa-swatch', label: 'درخواست کالیته', to: '/catalog-request', icon: IconCatalog },
|
||||
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 },
|
||||
]
|
||||
|
||||
const actions = computed(() => (auth.isAgent ? agentActions : customerActions))
|
||||
@@ -62,26 +70,42 @@ const FALLBACK_BANNER: AppBannerDto = {
|
||||
ctaLabel: 'مشاهده کالکشن',
|
||||
ctaLink: '/categories',
|
||||
imageUrl: '',
|
||||
showTitle: true,
|
||||
showSubtitle: true,
|
||||
showCta: true,
|
||||
}
|
||||
|
||||
const banners = ref<AppBannerDto[]>([FALLBACK_BANNER])
|
||||
const bannerIndex = ref(0)
|
||||
const heroAnim = ref<'hero-next' | 'hero-prev'>('hero-next')
|
||||
let bannerTimer: number | undefined
|
||||
|
||||
const banner = computed(() => banners.value[bannerIndex.value] ?? FALLBACK_BANNER)
|
||||
|
||||
const heroStyle = computed(() => {
|
||||
const image = banner.value.imageUrl
|
||||
if (!image) return undefined
|
||||
return { '--hero-image': `url("${image}")` }
|
||||
})
|
||||
function slideStyle(item: AppBannerDto) {
|
||||
if (!item.imageUrl) return undefined
|
||||
return { '--hero-image': `url("${item.imageUrl}")` }
|
||||
}
|
||||
|
||||
function moveBanner(index: number, dir?: 1 | -1) {
|
||||
const len = banners.value.length
|
||||
if (!len) return
|
||||
const next = ((index % len) + len) % len
|
||||
if (next === bannerIndex.value) return
|
||||
if (dir === 1) heroAnim.value = 'hero-next'
|
||||
else if (dir === -1) heroAnim.value = 'hero-prev'
|
||||
else if (bannerIndex.value === len - 1 && next === 0) heroAnim.value = 'hero-next'
|
||||
else if (bannerIndex.value === 0 && next === len - 1) heroAnim.value = 'hero-prev'
|
||||
else heroAnim.value = next > bannerIndex.value ? 'hero-next' : 'hero-prev'
|
||||
bannerIndex.value = next
|
||||
}
|
||||
|
||||
function startBannerRotation() {
|
||||
stopBannerRotation()
|
||||
if (banners.value.length < 2) return
|
||||
bannerTimer = window.setInterval(() => {
|
||||
bannerIndex.value = (bannerIndex.value + 1) % banners.value.length
|
||||
}, 5000)
|
||||
moveBanner(bannerIndex.value + 1, 1)
|
||||
}, 5500)
|
||||
}
|
||||
|
||||
function stopBannerRotation() {
|
||||
@@ -90,7 +114,7 @@ function stopBannerRotation() {
|
||||
}
|
||||
|
||||
function setBanner(index: number) {
|
||||
bannerIndex.value = index
|
||||
moveBanner(index)
|
||||
startBannerRotation()
|
||||
}
|
||||
|
||||
@@ -166,7 +190,7 @@ async function toggleFavorite(productId: string) {
|
||||
|
||||
<template>
|
||||
<div class="page home-page">
|
||||
<header class="home-header">
|
||||
<header class="home-header mobile-only">
|
||||
<button type="button" class="icon-btn" aria-label="بازگشت" @click="goBack">
|
||||
<IconChevronBack :size="20" />
|
||||
</button>
|
||||
@@ -192,29 +216,45 @@ async function toggleFavorite(productId: string) {
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<header class="home-desk-head desktop-only">
|
||||
<div>
|
||||
<h1 class="home-desk-head__title">خانه</h1>
|
||||
<p class="home-desk-head__sub">
|
||||
سلام {{ displayFirst }} {{ displayLast }} — خوش آمدید
|
||||
</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="page__scroll page__scroll--with-nav home-scroll">
|
||||
<p v-if="error" class="home-error">{{ error }}</p>
|
||||
<PageSkeleton v-else-if="loading" variant="home" />
|
||||
<template v-else>
|
||||
<section
|
||||
class="hero-banner"
|
||||
:aria-label="banner.title"
|
||||
:style="heroStyle"
|
||||
>
|
||||
<div class="hero-banner__content">
|
||||
<h2 class="hero-banner__title">
|
||||
{{ banner.title }}
|
||||
<span v-if="banner.subtitle">{{ banner.subtitle }}</span>
|
||||
</h2>
|
||||
<button
|
||||
v-if="banner.ctaLabel"
|
||||
type="button"
|
||||
class="hero-banner__cta"
|
||||
@click="goBanner"
|
||||
>
|
||||
{{ banner.ctaLabel }}
|
||||
</button>
|
||||
</div>
|
||||
<section class="hero-banner" :aria-label="banner.title">
|
||||
<TransitionGroup :name="heroAnim" tag="div" class="hero-banner__stage">
|
||||
<article :key="banner.id" class="hero-slide" :style="slideStyle(banner)">
|
||||
<div class="hero-slide__media" aria-hidden="true" />
|
||||
<div class="hero-banner__content">
|
||||
<h2 v-if="banner.showTitle !== false" class="hero-banner__title">
|
||||
{{ banner.title }}
|
||||
<span v-if="banner.showSubtitle !== false && banner.subtitle">{{ banner.subtitle }}</span>
|
||||
</h2>
|
||||
<p
|
||||
v-else-if="banner.showSubtitle !== false && banner.subtitle"
|
||||
class="hero-banner__title"
|
||||
>
|
||||
<span>{{ banner.subtitle }}</span>
|
||||
</p>
|
||||
<button
|
||||
v-if="banner.showCta !== false && banner.ctaLabel"
|
||||
type="button"
|
||||
class="hero-banner__cta"
|
||||
@click="goBanner"
|
||||
>
|
||||
{{ banner.ctaLabel }}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</TransitionGroup>
|
||||
<div v-if="banners.length > 1" class="hero-banner__dots" role="tablist" aria-label="بنرها">
|
||||
<button
|
||||
v-for="(item, index) in banners"
|
||||
@@ -238,7 +278,8 @@ async function toggleFavorite(productId: string) {
|
||||
@click="go(action.to)"
|
||||
>
|
||||
<span class="quick-card__icon" aria-hidden="true">
|
||||
<component :is="action.icon" :size="20" />
|
||||
<img v-if="action.image" class="quick-card__image" :src="action.image" alt="" />
|
||||
<component v-else :is="action.icon" :size="20" />
|
||||
</span>
|
||||
<span class="quick-card__label">{{ action.label }}</span>
|
||||
</button>
|
||||
@@ -247,7 +288,14 @@ async function toggleFavorite(productId: string) {
|
||||
<section class="level-card" aria-label="سطح عضویت">
|
||||
<div class="level-card__top">
|
||||
<div class="level-card__identity">
|
||||
<IconMedal :size="48" />
|
||||
<img
|
||||
class="level-card__medal"
|
||||
:src="levelMedalIcon"
|
||||
alt=""
|
||||
width="48"
|
||||
height="48"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<div class="level-card__text">
|
||||
<span class="level-card__eyebrow">سطح شما</span>
|
||||
<strong class="level-card__name">{{ homeLevel.label }}</strong>
|
||||
@@ -415,14 +463,106 @@ async function toggleFavorite(productId: string) {
|
||||
position: relative;
|
||||
min-height: 160px;
|
||||
border-radius: var(--radius-lg);
|
||||
color: #fff;
|
||||
overflow: hidden;
|
||||
isolation: isolate;
|
||||
}
|
||||
|
||||
.hero-banner__stage {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
}
|
||||
|
||||
.hero-slide {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
padding: 20px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.hero-slide__media {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
background:
|
||||
linear-gradient(120deg, rgba(var(--color-accent-navy-rgb), 0.72), rgba(var(--color-primary-rgb), 0.45)),
|
||||
var(--hero-image);
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
color: #fff;
|
||||
padding: 20px;
|
||||
overflow: hidden;
|
||||
var(--hero-image) center / cover no-repeat;
|
||||
}
|
||||
|
||||
.hero-banner__content {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
animation: hero-copy 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
|
||||
}
|
||||
|
||||
.hero-next-enter-active,
|
||||
.hero-next-leave-active,
|
||||
.hero-prev-enter-active,
|
||||
.hero-prev-leave-active {
|
||||
transition:
|
||||
opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
|
||||
transform 0.85s cubic-bezier(0.22, 1, 0.36, 1);
|
||||
}
|
||||
|
||||
.hero-next-leave-active,
|
||||
.hero-prev-leave-active {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.hero-next-enter-active,
|
||||
.hero-prev-enter-active {
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.hero-next-enter-from {
|
||||
opacity: 0;
|
||||
transform: translate3d(-16%, 0, 0);
|
||||
}
|
||||
|
||||
.hero-next-leave-to {
|
||||
opacity: 0;
|
||||
transform: translate3d(12%, 0, 0);
|
||||
}
|
||||
|
||||
.hero-prev-enter-from {
|
||||
opacity: 0;
|
||||
transform: translate3d(16%, 0, 0);
|
||||
}
|
||||
|
||||
.hero-prev-leave-to {
|
||||
opacity: 0;
|
||||
transform: translate3d(-12%, 0, 0);
|
||||
}
|
||||
|
||||
@keyframes hero-copy {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translate3d(0, 12px, 0);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.hero-banner__content,
|
||||
.hero-next-enter-active,
|
||||
.hero-next-leave-active,
|
||||
.hero-prev-enter-active,
|
||||
.hero-prev-leave-active {
|
||||
animation: none;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.hero-next-enter-from,
|
||||
.hero-next-leave-to,
|
||||
.hero-prev-enter-from,
|
||||
.hero-prev-leave-to {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
.hero-banner__title {
|
||||
@@ -456,6 +596,7 @@ async function toggleFavorite(productId: string) {
|
||||
transform: translateX(-50%);
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.dot {
|
||||
@@ -466,6 +607,7 @@ async function toggleFavorite(productId: string) {
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.45);
|
||||
cursor: pointer;
|
||||
transition: width 0.35s ease, background 0.35s ease;
|
||||
}
|
||||
|
||||
.dot--active {
|
||||
@@ -493,18 +635,25 @@ async function toggleFavorite(productId: string) {
|
||||
}
|
||||
|
||||
.quick-card__icon {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
border-radius: 12px;
|
||||
background: var(--color-primary-soft);
|
||||
display: grid;
|
||||
place-items: center;
|
||||
color: var(--color-primary);
|
||||
background: var(--color-surface);
|
||||
box-shadow: 0 2px 12px rgba(16, 24, 40, 0.06);
|
||||
}
|
||||
|
||||
.quick-card__image {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: block;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.quick-card__label {
|
||||
font-weight: bold;
|
||||
font-size: 0.7rem;
|
||||
font-weight: 600;
|
||||
text-align: center;
|
||||
line-height: 1.4;
|
||||
}
|
||||
@@ -531,6 +680,14 @@ async function toggleFavorite(productId: string) {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.level-card__medal {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
flex-shrink: 0;
|
||||
display: block;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.level-card__text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -731,4 +888,96 @@ async function toggleFavorite(productId: string) {
|
||||
.product-card__fav--on {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.home-page {
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.home-desk-head {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 8px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.home-desk-head__title {
|
||||
margin: 0 0 4px;
|
||||
font-size: 1.375rem;
|
||||
font-weight: 700;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.home-desk-head__sub {
|
||||
margin: 0;
|
||||
font-size: 0.875rem;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.home-scroll {
|
||||
gap: 22px;
|
||||
padding: 8px 0 24px;
|
||||
}
|
||||
|
||||
.hero-banner {
|
||||
min-height: 220px;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.hero-slide {
|
||||
padding: 28px 32px;
|
||||
}
|
||||
|
||||
.hero-banner__title {
|
||||
font-size: 1.35rem;
|
||||
max-width: 22rem;
|
||||
}
|
||||
|
||||
.quick-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.quick-card {
|
||||
min-height: 96px;
|
||||
padding: 18px 14px;
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
.level-card {
|
||||
padding: 20px 22px;
|
||||
}
|
||||
|
||||
.product-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
overflow: visible;
|
||||
margin-inline: 0;
|
||||
padding-inline: 0;
|
||||
scroll-snap-type: none;
|
||||
}
|
||||
|
||||
.product-card {
|
||||
flex: none;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.product-card__image {
|
||||
height: 160px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1200px) {
|
||||
.product-row {
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.hero-banner {
|
||||
min-height: 240px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user