Files
nademitex_user/dist/assets/ProductsView-DsX9fDRz.js
T
2026-09-30 22:10:12 +03:30

1 line
14 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{A as e,At as t,F as n,G as r,M as i,Nt as a,Pt as o,R as s,U as c,_ as l,c as u,d,f,g as p,h as ee,i as m,k as te,l as h,nt as g,o as ne,t as re,u as _,ut as v,v as y}from"./_plugin-vue_export-helper-1xMDlcEE.js";import{n as ie,u as b}from"./BasicIcon-ba1FsUKx.js";import{A as ae,C as oe,k as se,r as x,s as ce,u as le}from"./index-CpQ4kL4n.js";import{t as ue}from"./IconFilter-Br-Ixz6t.js";import{t as de}from"./IconDiamond-CCzZ7nPM.js";import{t as fe}from"./PageHeader-BZqQYya4.js";import{t as pe}from"./PageSkeleton-DYdjm4l9.js";import{t as me}from"./crm-BPBlQFWp.js";import{n as he,r as ge,t as _e}from"./useSlotBanners-QlSCiyVh.js";import{t as ve}from"./useTouchSwipe-C8fUyAcQ.js";import"./SearchField-dVDn9y5S.js";import{t as ye}from"./IconHeart-CvzbNH_T.js";import{n as be,t as xe}from"./colorSwatch-CCSfH9o4.js";import{t as S}from"./AppSelect-CYw47n7-.js";var Se={class:`page products-page`},Ce=[`aria-expanded`],we={class:`desktop-page__head desktop-only products-desk-head`},Te={class:`products-desk-head__copy`},Ee={class:`desktop-page__title`},De={class:`desktop-page__subtitle`},Oe={key:0,class:`products-filter-desk desktop-only`},ke={class:`products-filter-sheet products-filter-sheet--desk`},Ae={class:`products-filter-actions products-filter-actions--desk`},je={class:`products-filter-actions`},Me={class:`page__scroll page__scroll--with-nav products-scroll`},Ne={key:0},Pe={class:`cat-banner__content`},Fe={key:0,class:`cat-banner__lead`},Ie={key:1,class:`cat-banner__title-row`},Le={key:0,class:`cat-banner__icon-ring`,"aria-hidden":`true`},Re={key:1,class:`cat-banner__title`},ze={key:2,class:`cat-banner__title`},Be={key:3,class:`cat-banner__tagline`},Ve={key:0,class:`cat-banner__icon-ring cat-banner__icon-ring--aside`,"aria-hidden":`true`},He={key:1,class:`cat-banner__dots`,role:`tablist`,"aria-label":`بنرها`},Ue=[`aria-label`,`aria-selected`,`onClick`],We={key:0,class:`chips-row scroll-x`},Ge=[`aria-label`],Ke=[`onClick`],qe=[`onClick`],Je={class:`list-meta`},Ye=[`aria-label`],Xe={class:`products-list`},Ze=[`onClick`],Qe={class:`product-item__body`},$e={class:`product-item__head`},et={class:`product-item__title`},tt={key:0,class:`new-tag`},nt=[`aria-label`,`aria-pressed`,`onClick`],rt={class:`product-item__specs`},it={class:`swatches`},at=[`onClick`],ot={key:1,class:`empty-list`},C=re(y({__name:`ProductsView`,setup(re){let y=se(),C=ae(),w=me(),T=le(),{banners:E}=_e(`products_hero`),D=g(0);c(E,()=>{D.value=0});let O=u(()=>N.value||F.value?0:E.value.length),k=u(()=>{if(N.value||F.value)return null;let e=E.value;return e.length?e[(D.value%e.length+e.length)%e.length]??null:null});function A(e){let t=E.value.length;t&&(D.value=(e%t+t)%t)}let{onTouchStart:j,onTouchEnd:M}=ve({enabled:()=>O.value>1,onSwipe(e){A(D.value+e)}}),N=u(()=>String(y.query.categoryId??``)),P=u(()=>String(y.query.companyId??``)),F=u(()=>String(y.query.season??``)),st=u(()=>String(y.query.filterAxis??``)),I=u(()=>String(y.query.q??``)),ct=g(String(y.query.q??``)),L=g([]),R=g(!0),z=g(null),B=g(`newest`),V=g(!1),H=g(``),U=g(``),W=u(()=>!0),lt=u(()=>[{value:``,label:`همه دسته‌ها`},...w.usageCategories.map(e=>({value:e.id,label:e.title}))]),ut=u(()=>[{value:``,label:`همه فصول`},...w.seasonCategories.map(e=>({value:e.id,label:e.title}))]),G=u(()=>!!N.value||!!F.value),K=u(()=>N.value?w.usageCategories.find(e=>e.id===N.value)?.title??`محصولات`:F.value?w.seasonCategories.find(e=>e.id===F.value)?.title??`محصولات`:I.value?`جستجو: ${I.value}`:`محصولات`);function dt(e){let t=e.trim();return t.startsWith(`پارچه‌های `)?{lead:`پارچه‌های`,headline:t.slice(10)}:{lead:void 0,headline:t}}function ft(e){return e.icon||(e.id===`summer`?`bolt`:e.id===`winter`?`feather`:`diamond`)}function pt(){let e=q.value.ctaLink?.trim();if(e){if(/^https?:\/\//i.test(e)){window.location.assign(e);return}C.push(e)}}let q=u(()=>{let e=k.value;if(e)return{lead:void 0,headline:e.showTitle===!1?void 0:e.title,tagline:e.showSubtitle===!1?void 0:e.subtitle||void 0,showIcon:!1,ctaLabel:e.showCta===!1?void 0:e.ctaLabel||void 0,ctaLink:e.ctaLink||void 0};if(N.value){let e=w.usageCategories.find(e=>e.id===N.value),t=dt(e?.title??K.value);return{lead:e?.showTitle===!1?void 0:t.lead,headline:e?.showTitle===!1?void 0:t.headline,tagline:e?.showSubtitle===!1?void 0:e?.subtitle,showIcon:e?.showIcon!==!1}}if(F.value){let e=w.seasonCategories.find(e=>e.id===F.value);return{lead:void 0,headline:e?.showTitle===!1?void 0:e?.title??K.value,tagline:e?.showDescription===!1?void 0:e?.description||void 0,showIcon:e?.showIcon!==!1}}return{lead:void 0,headline:K.value,tagline:I.value?`نتایج جستجو`:`مشاهده و ثبت سفارش`,showIcon:!1}}),J=u(()=>{if(k.value||q.value.showIcon===!1)return null;if(N.value){let e=w.usageCategories.find(e=>e.id===N.value);if(e)return he(ge(e),oe)}if(F.value){let e=w.seasonCategories.find(e=>e.id===F.value);if(e)return he(ft(e),de)}return null}),Y=u(()=>{let e=k.value?.imageUrl?.trim();if(e)return e;if(N.value){let e=w.usageCategories.find(e=>e.id===N.value);if(e?.imageUrl)return e.imageUrl}if(F.value){let e=w.seasonCategories.find(e=>e.id===F.value);if(e?.imageUrl)return e.imageUrl}}),mt=u(()=>Y.value?{backgroundImage:`url(${Y.value})`}:void 0);u(()=>!N.value);let ht=u(()=>st.value===`usage`||N.value?`season`:st.value===`season`||F.value?`usage`:`season`),gt=u(()=>ht.value===`season`?`فصل`:`دسته کاربرد`),X=u(()=>{let e=I.value.trim().toLowerCase(),t=[...L.value];return e&&(t=t.filter(t=>t.name.toLowerCase().includes(e)||t.code.toLowerCase().includes(e)||(t.composition||``).toLowerCase().includes(e))),B.value===`name`?t.sort((e,t)=>e.name.localeCompare(t.name,`fa`)):t.sort((e,t)=>Number(t.isNew)-Number(e.isNew)||e.name.localeCompare(t.name,`fa`))});function _t(){B.value=B.value===`newest`?`name`:`newest`}let vt=u(()=>B.value===`newest`?`مرتب‌سازی: جدیدترین`:`مرتب‌سازی: نام`);async function yt(){R.value=!0,z.value=null;try{await w.loadCategories(),L.value=await w.loadBrowseProducts({categoryId:N.value||void 0,season:F.value||void 0,companyId:P.value||void 0})}catch(e){z.value=e instanceof Error?e.message:`بارگذاری محصولات ناموفق بود.`,L.value=[]}finally{R.value=!1}}te(async()=>{await T.hydrate(),await yt()}),c([N,F,P],yt),c(I,e=>{ct.value=e});function bt(e){let t=N.value,n=t?`usage`:e?`season`:void 0;C.replace({path:`/products`,query:{...t?{categoryId:t}:{},...P.value?{companyId:P.value}:{},...e?{season:e}:{},...n?{filterAxis:n}:{},...I.value?{q:I.value}:{}}})}function xt(e){let t=F.value,n=t?`season`:e?`usage`:void 0;C.replace({path:`/products`,query:{...e?{categoryId:e}:{},...P.value?{companyId:P.value}:{},...t?{season:t}:{},...n?{filterAxis:n}:{},...I.value?{q:I.value}:{}}})}function Z(e){C.push({path:`/product`,query:{id:e}})}function St(e){return w.seasonCategories.find(t=>t.id===e)?.title??e}function Ct(e){T.toggle(e)}function wt(){H.value=N.value,U.value=F.value,V.value=!0}function Q(){V.value=!1}function Tt(e,t){if(e)return`usage`;if(t)return`season`}function Et(e,t){let n=Tt(e,t);return{...e?{categoryId:e}:{},...t?{season:t}:{},...n?{filterAxis:n}:{},...P.value?{companyId:P.value}:{},...I.value?{q:I.value}:{}}}function Dt(){C.replace({path:`/products`,query:Et(H.value,U.value)}),Q()}function $(){H.value=``,U.value=``,C.replace({path:`/products`,query:Et(``,``)}),Q()}return c(V,e=>{typeof window<`u`&&window.matchMedia(`(min-width: 768px)`).matches||(document.body.style.overflow=e?`hidden`:``)}),e(()=>{document.body.style.overflow=``}),(e,c)=>(i(),f(`div`,Se,[l(fe,{class:`mobile-only`,title:K.value,"show-back":``,centered:``,onBack:c[0]||=e=>v(C).back()},{trailing:r(()=>[W.value?(i(),f(`button`,{key:0,type:`button`,class:t([`nav-filter`,{"nav-filter--active":G.value}]),"aria-label":`فیلتر محصولات`,"aria-expanded":V.value,onClick:wt},[l(ue,{size:18})],10,Ce)):d(``,!0)]),_:1},8,[`title`]),h(`header`,we,[h(`div`,Te,[h(`h1`,Ee,o(K.value),1),h(`p`,De,o(q.value.tagline||(I.value?`نتایج جستجو`:`مشاهده و ثبت سفارش`)),1)])]),W.value?(i(),f(`div`,Oe,[h(`div`,ke,[c[12]||=h(`header`,{class:`products-filter-sheet__head`},[h(`h2`,null,`فیلتر محصولات`)],-1),l(S,{modelValue:H.value,"onUpdate:modelValue":c[1]||=e=>H.value=e,class:`products-filter-section`,label:`دسته کاربرد`,"aria-label":`دسته کاربرد`,options:lt.value},null,8,[`modelValue`,`options`]),l(S,{modelValue:U.value,"onUpdate:modelValue":c[2]||=e=>U.value=e,class:`products-filter-section`,label:`فصل`,"aria-label":`فصل`,options:ut.value},null,8,[`modelValue`,`options`]),h(`div`,Ae,[l(x,{onClick:Dt},{default:r(()=>[...c[11]||=[p(`اعمال فیلتر`,-1)]]),_:1}),G.value?(i(),f(`button`,{key:0,type:`button`,class:`products-filter-clear`,onClick:$},` پاک کردن فیلترها `)):d(``,!0)])])])):d(``,!0),(i(),_(ne,{to:`body`},[l(ie,{name:`products-filter-sheet`},{default:r(()=>[V.value&&W.value?(i(),f(`div`,{key:0,class:`products-filter-panel mobile-only`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`products-filter-title`,onClick:b(Q,[`self`])},[h(`div`,{class:`products-filter-sheet`,onClick:c[6]||=b(()=>{},[`stop`])},[c[15]||=h(`div`,{class:`products-filter-sheet__handle`,"aria-hidden":`true`},null,-1),h(`header`,{class:`products-filter-sheet__head`},[c[13]||=h(`h2`,{id:`products-filter-title`},`فیلتر محصولات`,-1),h(`button`,{type:`button`,class:`products-filter-sheet__close`,"aria-label":`بستن`,onClick:Q},` × `)]),l(S,{modelValue:H.value,"onUpdate:modelValue":c[3]||=e=>H.value=e,class:`products-filter-section`,label:`دسته کاربرد`,"aria-label":`دسته کاربرد`,options:lt.value},null,8,[`modelValue`,`options`]),l(S,{modelValue:U.value,"onUpdate:modelValue":c[4]||=e=>U.value=e,class:`products-filter-section`,label:`فصل`,"aria-label":`فصل`,options:ut.value},null,8,[`modelValue`,`options`]),h(`div`,je,[l(x,{block:``,onClick:Dt},{default:r(()=>[...c[14]||=[p(`اعمال فیلتر`,-1)]]),_:1}),G.value?(i(),f(`button`,{key:0,type:`button`,class:`products-filter-clear`,onClick:$},` پاک کردن فیلترها `)):d(``,!0),h(`button`,{type:`button`,class:`products-filter-link`,onClick:c[5]||=e=>{v(C).push(`/categories`),Q()}},` مشاهده همه دسته‌بندی‌ها `)])])])):d(``,!0)]),_:1})])),h(`div`,Me,[z.value?(i(),f(`p`,Ne,o(z.value),1)):R.value?(i(),_(pe,{key:1,variant:`grid`})):(i(),f(m,{key:2},[h(`section`,{class:t([`cat-banner`,{"cat-banner--photo":!!Y.value}]),style:a(mt.value),onTouchstartPassive:c[7]||=(...e)=>v(j)&&v(j)(...e),onTouchendPassive:c[8]||=(...e)=>v(M)&&v(M)(...e)},[h(`div`,Pe,[q.value.lead?(i(),f(`p`,Fe,o(q.value.lead),1)):d(``,!0),q.value.headline||J.value&&Y.value?(i(),f(`div`,Ie,[J.value&&Y.value?(i(),f(`span`,Le,[(i(),_(s(J.value),{size:22,color:`#ffffff`}))])):d(``,!0),q.value.headline?(i(),f(`h2`,Re,o(q.value.headline),1)):d(``,!0)])):q.value.headline?(i(),f(`h2`,ze,o(q.value.headline),1)):d(``,!0),q.value.tagline?(i(),f(`p`,Be,o(q.value.tagline),1)):d(``,!0),q.value.ctaLabel?(i(),f(`button`,{key:4,type:`button`,class:`cat-banner__cta`,onClick:pt},o(q.value.ctaLabel),1)):d(``,!0)]),J.value&&!Y.value?(i(),f(`span`,Ve,[(i(),_(s(J.value),{size:26,color:`#ffffff`}))])):d(``,!0),O.value>1?(i(),f(`div`,He,[(i(!0),f(m,null,n(v(E),(e,n)=>(i(),f(`button`,{key:e.id,type:`button`,class:t([`cat-banner__dot`,{"cat-banner__dot--active":n===D.value}]),"aria-label":e.title,"aria-selected":n===D.value,onClick:e=>A(n)},null,10,Ue))),128))])):d(``,!0)],38),W.value?(i(),f(`div`,We,[h(`div`,{class:`chips`,role:`tablist`,"aria-label":gt.value},[ht.value===`season`?(i(),f(m,{key:0},[h(`button`,{type:`button`,class:t([`chip`,{"chip--active":!F.value}]),onClick:c[9]||=e=>bt(``)},` همه `,2),(i(!0),f(m,null,n(v(w).seasonCategories,e=>(i(),f(`button`,{key:e.id,type:`button`,class:t([`chip`,{"chip--active":F.value===e.id}]),onClick:t=>bt(e.id)},o(e.title),11,Ke))),128))],64)):(i(),f(m,{key:1},[h(`button`,{type:`button`,class:t([`chip`,{"chip--active":!N.value}]),onClick:c[10]||=e=>xt(``)},` همه `,2),(i(!0),f(m,null,n(v(w).usageCategories,e=>(i(),f(`button`,{key:e.id,type:`button`,class:t([`chip`,{"chip--active":N.value===e.id}]),onClick:t=>xt(e.id)},o(e.title),11,qe))),128))],64))],8,Ge)])):d(``,!0),h(`div`,Je,[h(`span`,null,`تعداد محصولات: `+o(X.value.length.toLocaleString(`fa-IR`)),1),h(`button`,{type:`button`,class:`list-meta__sort`,"aria-label":vt.value,onClick:_t},[...c[16]||=[ee(`<span class="list-meta__sort-icon" aria-hidden="true" data-v-27f926c1><svg width="15" height="12" viewBox="0 0 15 12" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-27f926c1><path d="M4.5 2.5V9.5" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" data-v-27f926c1></path><path d="M2.5 7.5L4.5 9.5L6.5 7.5" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" data-v-27f926c1></path><path d="M10.5 9.5V2.5" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" data-v-27f926c1></path><path d="M8.5 4.5L10.5 2.5L12.5 4.5" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" data-v-27f926c1></path></svg></span><span class="list-meta__sort-badge" data-v-27f926c1>۱</span><span class="list-meta__sort-label" data-v-27f926c1>مرتب‌سازی</span>`,3)]],8,Ye)]),h(`div`,Xe,[(i(!0),f(m,null,n(X.value,e=>(i(),f(`article`,{key:e.id,class:`product-item`,onClick:t=>Z(e.id)},[h(`div`,{class:`product-item__image`,style:a(e.imageUrl?{backgroundImage:`url(${e.imageUrl})`}:void 0)},null,4),h(`div`,Qe,[h(`div`,$e,[h(`div`,et,[h(`strong`,null,o(e.name),1),e.isNew?(i(),f(`span`,tt,`جدید`)):d(``,!0)]),h(`button`,{type:`button`,class:`bookmark`,"aria-label":v(T).isFavorite(e.id)?`حذف از علاقه‌مندی‌ها`:`افزودن به علاقه‌مندی‌ها`,"aria-pressed":v(T).isFavorite(e.id),onClick:b(t=>Ct(e.id),[`stop`])},[l(ye,{size:18,filled:v(T).isFavorite(e.id),color:v(T).isFavorite(e.id)?`var(--color-primary)`:`#9ca3af`},null,8,[`filled`,`color`])],8,nt)]),h(`ul`,rt,[h(`li`,null,`عرض: `+o(e.widthCm.toLocaleString(`fa-IR`))+` سانتی‌متر`,1),h(`li`,null,`ترکیب: `+o(e.composition||`—`),1),h(`li`,null,`مناسب: `+o(St(e.season)),1)]),h(`div`,it,[(i(!0),f(m,null,n(e.colors.slice(0,6),(t,n)=>(i(),f(`span`,{key:n,class:`swatch`,style:a(v(xe)(t,v(be)(e.colorImages,e.colorVariantImages,n)))},null,4))),128))]),h(`button`,{type:`button`,class:`details-link`,onClick:b(t=>Z(e.id),[`stop`])},[c[17]||=p(` مشاهده جزئیات `,-1),l(ce,{size:14})],8,at)])],8,Ze))),128))]),X.value.length?d(``,!0):(i(),f(`p`,ot,`محصولی در این دسته یافت نشد.`))],64))])]))}}),[[`__scopeId`,`data-v-27f926c1`]]);export{C as default};