2026-09-09 17:08:45 +03:30
|
|
|
|
<script setup lang="ts">
|
2026-09-13 15:36:48 +03:30
|
|
|
|
import { computed, onMounted, ref } from 'vue'
|
2026-09-09 17:08:45 +03:30
|
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
2026-09-13 15:36:48 +03:30
|
|
|
|
import SearchField from '@/components/ui/SearchField.vue'
|
|
|
|
|
|
import IconSearch from '@/components/icons/IconSearch.vue'
|
|
|
|
|
|
import IconChevronBack from '@/components/icons/IconChevronBack.vue'
|
|
|
|
|
|
import AuthThemeToggle from '@/components/ui/AuthThemeToggle.vue'
|
2026-09-09 17:08:45 +03:30
|
|
|
|
import PageSkeleton from '@/components/ui/PageSkeleton.vue'
|
|
|
|
|
|
import { useCatalogStore } from '@/stores/catalog'
|
2026-09-13 15:36:48 +03:30
|
|
|
|
import { useCrmStore } from '@/stores/crm'
|
|
|
|
|
|
import { useGoBack } from '@/composables/useGoBack'
|
2026-09-09 17:08:45 +03:30
|
|
|
|
import type { Catalog } from '@/types'
|
2026-09-13 15:36:48 +03:30
|
|
|
|
import type { CatalogProductCard } from '@/types/crm'
|
|
|
|
|
|
import {
|
|
|
|
|
|
buildCatalogGallery,
|
|
|
|
|
|
filterCatalogGallery,
|
|
|
|
|
|
type CatalogGalleryFilter,
|
|
|
|
|
|
} from '@/utils/catalogGallery'
|
|
|
|
|
|
import { formatNumber } from '@/utils/format'
|
2026-09-09 17:08:45 +03:30
|
|
|
|
|
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
|
const router = useRouter()
|
2026-09-13 15:36:48 +03:30
|
|
|
|
const { goBack } = useGoBack('/')
|
2026-09-09 17:08:45 +03:30
|
|
|
|
const catalogStore = useCatalogStore()
|
2026-09-13 15:36:48 +03:30
|
|
|
|
const crm = useCrmStore()
|
|
|
|
|
|
|
2026-09-09 17:08:45 +03:30
|
|
|
|
const catalogs = ref<Catalog[]>([])
|
2026-09-13 15:36:48 +03:30
|
|
|
|
const products = ref<CatalogProductCard[]>([])
|
2026-09-09 17:08:45 +03:30
|
|
|
|
const loading = ref(true)
|
2026-09-13 15:36:48 +03:30
|
|
|
|
const searchOpen = ref(false)
|
|
|
|
|
|
const search = ref('')
|
|
|
|
|
|
const filter = ref<CatalogGalleryFilter>('all')
|
|
|
|
|
|
|
|
|
|
|
|
const filters: { id: CatalogGalleryFilter; label: string }[] = [
|
|
|
|
|
|
{ id: 'all', label: 'همه' },
|
|
|
|
|
|
{ id: 'newest', label: 'جدیدترین' },
|
|
|
|
|
|
{ id: 'popular', label: 'محبوبترین' },
|
|
|
|
|
|
{ id: 'season', label: 'بر اساس فصل' },
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
const gallery = computed(() => buildCatalogGallery(catalogs.value, products.value))
|
|
|
|
|
|
const cards = computed(() => filterCatalogGallery(gallery.value, filter.value, search.value))
|
2026-09-09 17:08:45 +03:30
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const companies = await catalogStore.loadCompanies()
|
2026-09-13 15:36:48 +03:30
|
|
|
|
const [lists, browse] = await Promise.all([
|
|
|
|
|
|
Promise.all(companies.map((company) => catalogStore.loadCatalogs(company.id))),
|
|
|
|
|
|
crm.loadBrowseProducts().catch(() => [] as CatalogProductCard[]),
|
|
|
|
|
|
])
|
2026-09-09 17:08:45 +03:30
|
|
|
|
catalogs.value = lists.flat()
|
2026-09-13 15:36:48 +03:30
|
|
|
|
products.value = browse
|
2026-09-09 17:08:45 +03:30
|
|
|
|
const focusId = String(route.query.id ?? '')
|
2026-09-13 15:36:48 +03:30
|
|
|
|
if (focusId && catalogs.value.some((item) => item.id === focusId)) {
|
|
|
|
|
|
router.replace({ name: 'catalog-detail', params: { catalogId: focusId } })
|
2026-09-09 17:08:45 +03:30
|
|
|
|
}
|
2026-09-13 15:36:48 +03:30
|
|
|
|
} catch {
|
|
|
|
|
|
catalogs.value = []
|
2026-09-09 17:08:45 +03:30
|
|
|
|
} finally {
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-09-13 15:36:48 +03:30
|
|
|
|
function openCatalog(id: string) {
|
|
|
|
|
|
router.push({ name: 'catalog-detail', params: { catalogId: id } })
|
2026-09-09 17:08:45 +03:30
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-13 15:36:48 +03:30
|
|
|
|
function toggleSearch() {
|
|
|
|
|
|
searchOpen.value = !searchOpen.value
|
|
|
|
|
|
if (!searchOpen.value) search.value = ''
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function metaLine(card: (typeof gallery.value)[number]) {
|
|
|
|
|
|
const extra =
|
|
|
|
|
|
card.season === 'winter'
|
|
|
|
|
|
? 'مناسب زمستان'
|
|
|
|
|
|
: card.season === 'summer'
|
|
|
|
|
|
? 'مناسب تابستان'
|
|
|
|
|
|
: 'مناسب چهار فصل'
|
|
|
|
|
|
return `${formatNumber(card.patternCount)} طرح • ${extra}`
|
2026-09-09 17:08:45 +03:30
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-09-13 15:36:48 +03:30
|
|
|
|
<div class="page calite-hub">
|
|
|
|
|
|
<header class="calite-hub__nav">
|
|
|
|
|
|
<button type="button" class="icon-btn" aria-label="بازگشت" @click="goBack">
|
|
|
|
|
|
<IconChevronBack :size="20" />
|
2026-09-09 17:08:45 +03:30
|
|
|
|
</button>
|
2026-09-13 15:36:48 +03:30
|
|
|
|
<h1>کالیتهها</h1>
|
|
|
|
|
|
<div class="calite-hub__nav-end">
|
|
|
|
|
|
<AuthThemeToggle variant="inline" class="mobile-only" />
|
2026-09-09 17:08:45 +03:30
|
|
|
|
<button
|
2026-09-13 15:36:48 +03:30
|
|
|
|
type="button"
|
|
|
|
|
|
class="icon-btn"
|
|
|
|
|
|
:aria-label="searchOpen ? 'بستن جستجو' : 'جستجو'"
|
|
|
|
|
|
:aria-pressed="searchOpen"
|
|
|
|
|
|
@click="toggleSearch"
|
|
|
|
|
|
>
|
|
|
|
|
|
<IconSearch :size="20" />
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="page__scroll page__scroll--with-nav calite-hub__scroll">
|
|
|
|
|
|
<p class="calite-hub__lead">مجموعهای از بهترین پارچهها، در یک نگاه</p>
|
|
|
|
|
|
|
|
|
|
|
|
<SearchField
|
|
|
|
|
|
v-if="searchOpen"
|
|
|
|
|
|
:model-value="search"
|
|
|
|
|
|
placeholder="جستجوی نام کالیته..."
|
|
|
|
|
|
@update:model-value="search = $event"
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="calite-hub__chips" role="tablist" aria-label="مرتبسازی کالیتهها">
|
|
|
|
|
|
<button
|
|
|
|
|
|
v-for="item in filters"
|
2026-09-09 17:08:45 +03:30
|
|
|
|
:key="item.id"
|
|
|
|
|
|
type="button"
|
2026-09-13 15:36:48 +03:30
|
|
|
|
class="calite-chip"
|
|
|
|
|
|
:class="{ 'is-on': filter === item.id }"
|
|
|
|
|
|
@click="filter = item.id"
|
2026-09-09 17:08:45 +03:30
|
|
|
|
>
|
2026-09-13 15:36:48 +03:30
|
|
|
|
{{ item.label }}
|
2026-09-09 17:08:45 +03:30
|
|
|
|
</button>
|
2026-09-13 15:36:48 +03:30
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<PageSkeleton v-if="loading" variant="cards" :rows="4" />
|
|
|
|
|
|
<p v-else-if="!cards.length" class="calite-hub__empty">کالیتهای یافت نشد.</p>
|
|
|
|
|
|
<div v-else class="calite-hub__list">
|
|
|
|
|
|
<button
|
|
|
|
|
|
v-for="card in cards"
|
|
|
|
|
|
:key="card.id"
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
class="calite-card"
|
|
|
|
|
|
dir="ltr"
|
|
|
|
|
|
@click="openCatalog(card.id)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<span
|
|
|
|
|
|
class="calite-card__photo"
|
|
|
|
|
|
:style="card.imageUrl ? { backgroundImage: `url(${card.imageUrl})` } : undefined"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<span v-if="card.badge" class="calite-card__badge">
|
|
|
|
|
|
{{ card.badge === 'new' ? 'جدید' : 'پرفروش' }}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<div class="calite-card__copy" dir="rtl">
|
|
|
|
|
|
<svg class="calite-card__arrow" width="12" height="16" viewBox="0 0 8 12" fill="none"
|
|
|
|
|
|
aria-hidden="true">
|
|
|
|
|
|
<path
|
|
|
|
|
|
d="M1.5 1.5 6 6l-4.5 4.5"
|
|
|
|
|
|
stroke="#fff"
|
|
|
|
|
|
stroke-width="1.4"
|
|
|
|
|
|
stroke-linecap="round"
|
|
|
|
|
|
stroke-linejoin="round"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</svg>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="mr-4 text-white">
|
|
|
|
|
|
<div class="text-lg font-bold">{{ card.title }}</div>
|
|
|
|
|
|
<div class="text-md">{{ card.subtitle }}</div>
|
|
|
|
|
|
<div class="text-xs mt-4">{{ metaLine(card) }}</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
2026-09-09 17:08:45 +03:30
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2026-09-13 15:36:48 +03:30
|
|
|
|
.calite-hub {
|
|
|
|
|
|
background: #f4f0ed;
|
|
|
|
|
|
color: #2a2622;
|
2026-09-09 17:08:45 +03:30
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-13 15:36:48 +03:30
|
|
|
|
.calite-hub__nav {
|
|
|
|
|
|
display: grid;
|
|
|
|
|
|
grid-template-columns: 40px 1fr auto;
|
2026-09-09 17:08:45 +03:30
|
|
|
|
align-items: center;
|
2026-09-13 15:36:48 +03:30
|
|
|
|
padding: 6px 12px 0;
|
|
|
|
|
|
background: #f4f0ed;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.calite-hub__nav-end {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.calite-hub__nav h1 {
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
font-size: 1.125rem;
|
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.calite-hub__scroll {
|
|
|
|
|
|
padding: 2px 16px 28px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
2026-09-09 17:08:45 +03:30
|
|
|
|
gap: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-13 15:36:48 +03:30
|
|
|
|
.calite-hub__lead {
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
color: #8a847c;
|
|
|
|
|
|
font-size: 0.78rem;
|
|
|
|
|
|
line-height: 1.7;
|
2026-09-09 17:08:45 +03:30
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-13 15:36:48 +03:30
|
|
|
|
.icon-btn {
|
|
|
|
|
|
width: 40px;
|
|
|
|
|
|
height: 40px;
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
background: transparent;
|
|
|
|
|
|
color: inherit;
|
|
|
|
|
|
display: grid;
|
|
|
|
|
|
place-items: center;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.calite-hub__chips {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
padding: 2px 0 4px;
|
|
|
|
|
|
scrollbar-width: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.calite-hub__chips::-webkit-scrollbar {
|
|
|
|
|
|
display: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.calite-chip {
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
height: 36px;
|
|
|
|
|
|
padding: 0 16px;
|
|
|
|
|
|
border: 1px solid #eae6e2;
|
|
|
|
|
|
border-radius: 999px;
|
|
|
|
|
|
background: #eae6e2;
|
|
|
|
|
|
color: #615f5c;
|
|
|
|
|
|
font: inherit;
|
|
|
|
|
|
font-size: 0.78rem;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.calite-chip.is-on {
|
|
|
|
|
|
border-color: var(--color-primary);
|
|
|
|
|
|
background: var(--color-primary);
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.calite-hub__list {
|
2026-09-09 17:08:45 +03:30
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
2026-09-13 15:36:48 +03:30
|
|
|
|
gap: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.calite-card {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
min-height: 132px;
|
|
|
|
|
|
padding: 0;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
border-radius: 22px;
|
|
|
|
|
|
background: #e7ddd4;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
text-align: start;
|
|
|
|
|
|
color: #2c2824;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.calite-card__photo {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
inset: 0;
|
|
|
|
|
|
z-index: 0;
|
|
|
|
|
|
background: linear-gradient(160deg, #c4b7a8, #8a7b6c);
|
|
|
|
|
|
background-size: cover;
|
|
|
|
|
|
background-position: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.calite-card__photo::after {
|
|
|
|
|
|
content: "";
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
inset: 0;
|
|
|
|
|
|
background: linear-gradient(90deg, transparent 28%, rgba(231, 221, 212, 0.42) 58%, rgba(231, 221, 212, 0.88) 100%);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.calite-card__badge {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
z-index: 2;
|
|
|
|
|
|
top: 12px;
|
|
|
|
|
|
left: 12px;
|
|
|
|
|
|
padding: 5px 12px;
|
|
|
|
|
|
border-radius: 999px;
|
|
|
|
|
|
background: #e7ddd4;
|
|
|
|
|
|
color: #000000;
|
|
|
|
|
|
font-size: 1rem;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
line-height: 1.2;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.calite-card__copy {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
z-index: 1;
|
|
|
|
|
|
display: flex;
|
2026-09-09 17:08:45 +03:30
|
|
|
|
gap: 4px;
|
2026-09-13 15:36:48 +03:30
|
|
|
|
min-height: 132px;
|
|
|
|
|
|
padding: 16px 16px 16px 42%;
|
2026-09-09 17:08:45 +03:30
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-13 15:36:48 +03:30
|
|
|
|
.calite-card__copy strong {
|
|
|
|
|
|
font-size: 1.0625rem;
|
2026-09-09 17:08:45 +03:30
|
|
|
|
font-weight: 700;
|
2026-09-13 15:36:48 +03:30
|
|
|
|
line-height: 1.4;
|
|
|
|
|
|
color: #2c2824;
|
2026-09-09 17:08:45 +03:30
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-13 15:36:48 +03:30
|
|
|
|
.calite-card__sub {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: flex-start;
|
|
|
|
|
|
gap: 2px;
|
|
|
|
|
|
color: #5c5752;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.calite-card__arrow {
|
|
|
|
|
|
flex-shrink: 0;
|
2026-09-09 17:08:45 +03:30
|
|
|
|
display: block;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-13 15:36:48 +03:30
|
|
|
|
.calite-card__copy em {
|
|
|
|
|
|
font-style: normal;
|
|
|
|
|
|
font-size: 0.75rem;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
line-height: 1.45;
|
|
|
|
|
|
color: #5c5752;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.calite-card__copy small {
|
|
|
|
|
|
font-size: 0.6875rem;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
line-height: 1.45;
|
|
|
|
|
|
color: #7a746c;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.calite-hub__empty {
|
|
|
|
|
|
margin: 16px 0 0;
|
2026-09-09 17:08:45 +03:30
|
|
|
|
text-align: center;
|
2026-09-13 15:36:48 +03:30
|
|
|
|
color: #8a847c;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
html.dark .calite-hub,
|
|
|
|
|
|
html.dark .calite-hub__nav {
|
|
|
|
|
|
background: #0b0f14;
|
|
|
|
|
|
color: #eef2f8;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
html.dark .calite-hub__lead,
|
|
|
|
|
|
html.dark .calite-hub__empty {
|
|
|
|
|
|
color: #9aa8bc;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
html.dark .calite-chip {
|
|
|
|
|
|
border-color: #2a3444;
|
|
|
|
|
|
background: #1a2230;
|
|
|
|
|
|
color: #c5d0de;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
html.dark .calite-chip.is-on {
|
|
|
|
|
|
border-color: #e8e4df;
|
|
|
|
|
|
background: #e8e4df;
|
|
|
|
|
|
color: #121821;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
html.dark .calite-card {
|
|
|
|
|
|
background: #1a2230;
|
|
|
|
|
|
color: #eef2f8;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
html.dark .calite-card__photo {
|
|
|
|
|
|
background: linear-gradient(160deg, #3a4454, #151b24);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
html.dark .calite-card__photo::after {
|
|
|
|
|
|
background: linear-gradient(
|
|
|
|
|
|
90deg,
|
|
|
|
|
|
transparent 22%,
|
|
|
|
|
|
rgba(11, 15, 20, 0.42) 55%,
|
|
|
|
|
|
rgba(11, 15, 20, 0.88) 100%
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
html.dark .calite-card__badge {
|
|
|
|
|
|
background: #e8e4df;
|
|
|
|
|
|
color: #121821;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
html.dark .calite-card__copy strong,
|
|
|
|
|
|
html.dark .calite-card__sub,
|
|
|
|
|
|
html.dark .calite-card__copy em,
|
|
|
|
|
|
html.dark .calite-card__copy small {
|
|
|
|
|
|
color: #eef2f8;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
html.dark .calite-card__copy small {
|
|
|
|
|
|
color: #c5d0de;
|
2026-09-09 17:08:45 +03:30
|
|
|
|
}
|
|
|
|
|
|
</style>
|