1 line
13 KiB
JavaScript
1 line
13 KiB
JavaScript
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-BSpFi5xB.js";import{t as ue}from"./IconFilter-Br-Ixz6t.js";import{t as de}from"./IconDiamond-CCzZ7nPM.js";import{t as fe}from"./PageHeader-DpR4Zxvt.js";import"./SearchField-dVDn9y5S.js";import{t as pe}from"./PageSkeleton-DYdjm4l9.js";import{t as me}from"./crm-Bj4T2PId.js";import{n as he,t as S}from"./categoryIcons-D22MgodO.js";import{t as ge}from"./IconHeart-CvzbNH_T.js";import{n as _e}from"./colorSwatch-BgOH1LE5.js";import{t as C}from"./AppSelect-CYw47n7-.js";var ve={class:`page products-page`},ye=[`aria-expanded`],be={class:`desktop-page__head desktop-only products-desk-head`},xe={class:`products-desk-head__copy`},Se={class:`desktop-page__title`},Ce={class:`desktop-page__subtitle`},we={key:0,class:`products-filter-desk desktop-only`},Te={class:`products-filter-sheet products-filter-sheet--desk`},Ee={class:`products-filter-actions products-filter-actions--desk`},De={class:`products-filter-actions`},Oe={class:`page__scroll page__scroll--with-nav products-scroll`},ke={key:0},Ae={class:`cat-banner__content`},je={key:0,class:`cat-banner__lead`},Me={key:1,class:`cat-banner__title-row`},Ne={key:0,class:`cat-banner__icon-ring`,"aria-hidden":`true`},Pe={key:1,class:`cat-banner__title`},Fe={key:2,class:`cat-banner__title`},Ie={key:3,class:`cat-banner__tagline`},Le={key:0,class:`cat-banner__icon-ring cat-banner__icon-ring--aside`,"aria-hidden":`true`},Re={key:0,class:`chips-row scroll-x`},ze=[`aria-label`],Be=[`onClick`],Ve=[`onClick`],He={class:`list-meta`},Ue=[`aria-label`],We={class:`products-list`},Ge=[`onClick`],Ke={class:`product-item__body`},qe={class:`product-item__head`},Je={class:`product-item__title`},Ye={key:0,class:`new-tag`},Xe=[`aria-label`,`aria-pressed`,`onClick`],Ze={class:`product-item__specs`},Qe={class:`swatches`},$e=[`onClick`],et={key:1,class:`empty-list`},w=re(y({__name:`ProductsView`,setup(re){let y=se(),w=ae(),T=me(),E=le(),D=u(()=>String(y.query.categoryId??``)),O=u(()=>String(y.query.catalogId??``)),k=u(()=>String(y.query.companyId??``)),A=u(()=>String(y.query.season??``)),j=u(()=>String(y.query.filterAxis??``)),M=u(()=>String(y.query.q??``)),tt=g(String(y.query.q??``)),N=g([]),P=g(``),F=g(!0),I=g(null),L=g(`newest`),R=g(!1),z=g(``),B=g(``),V=u(()=>!O.value),H=u(()=>[{value:``,label:`همه دستهها`},...T.usageCategories.map(e=>({value:e.id,label:e.title}))]),nt=u(()=>[{value:``,label:`همه فصول`},...T.seasonCategories.map(e=>({value:e.id,label:e.title}))]),U=u(()=>!!D.value||!!A.value),W=u(()=>O.value&&P.value?P.value:D.value?T.usageCategories.find(e=>e.id===D.value)?.title??`محصولات`:A.value?T.seasonCategories.find(e=>e.id===A.value)?.title??`محصولات`:M.value?`جستجو: ${M.value}`:`محصولات`);function rt(e){let t=e.trim();return t.startsWith(`پارچههای `)?{lead:`پارچههای`,headline:t.slice(10)}:{lead:void 0,headline:t}}function it(e){return e.icon||(e.id===`summer`?`bolt`:e.id===`winter`?`feather`:`diamond`)}let G=u(()=>{if(D.value){let e=T.usageCategories.find(e=>e.id===D.value),t=rt(e?.title??W.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(A.value){let e=T.seasonCategories.find(e=>e.id===A.value);return{lead:void 0,headline:e?.showTitle===!1?void 0:e?.title??W.value,tagline:e?.showDescription===!1?void 0:e?.description||void 0,showIcon:e?.showIcon!==!1}}return O.value?{lead:`کالیته`,headline:P.value||W.value,tagline:`انتخاب محصول از کالیته`,showIcon:!0}:{lead:void 0,headline:W.value,tagline:M.value?`نتایج جستجو`:`مشاهده و ثبت سفارش`,showIcon:!1}}),K=u(()=>{if(G.value.showIcon===!1)return null;if(D.value){let e=T.usageCategories.find(e=>e.id===D.value);if(e)return S(he(e),oe)}if(A.value){let e=T.seasonCategories.find(e=>e.id===A.value);if(e)return S(it(e),de)}return null}),q=u(()=>{if(D.value){let e=T.usageCategories.find(e=>e.id===D.value);if(e?.imageUrl)return e.imageUrl}if(A.value){let e=T.seasonCategories.find(e=>e.id===A.value);if(e?.imageUrl)return e.imageUrl}if(O.value)return N.value.find(e=>e.imageUrl)?.imageUrl}),at=u(()=>q.value?{backgroundImage:`url(${q.value})`}:void 0);u(()=>!D.value&&!O.value);let J=u(()=>j.value===`usage`||D.value?`season`:j.value===`season`||A.value?`usage`:`season`),ot=u(()=>J.value===`season`?`فصل`:`دسته کاربرد`),Y=u(()=>{let e=M.value.trim().toLowerCase(),t=[...N.value];return e&&(t=t.filter(t=>t.name.toLowerCase().includes(e)||t.code.toLowerCase().includes(e)||(t.composition||``).toLowerCase().includes(e))),L.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 st(){L.value=L.value===`newest`?`name`:`newest`}let ct=u(()=>L.value===`newest`?`مرتبسازی: جدیدترین`:`مرتبسازی: نام`);async function X(){F.value=!0,I.value=null;try{await T.loadCategories(),N.value=await T.loadBrowseProducts({categoryId:D.value||void 0,season:A.value||void 0,catalogId:O.value||void 0,companyId:k.value||void 0});let e=N.value[0];P.value=e?.catalogName||e?.catalogCode||``}catch(e){I.value=e instanceof Error?e.message:`بارگذاری محصولات ناموفق بود.`,N.value=[]}finally{F.value=!1}}te(async()=>{await E.hydrate(),await X()}),c([D,A,O,k],X),c(M,e=>{tt.value=e});function Z(e){let t=D.value,n=t?`usage`:e?`season`:void 0;w.replace({path:`/products`,query:{...t?{categoryId:t}:{},...O.value?{catalogId:O.value}:{},...k.value?{companyId:k.value}:{},...e?{season:e}:{},...n?{filterAxis:n}:{},...M.value?{q:M.value}:{}}})}function Q(e){let t=A.value,n=t?`season`:e?`usage`:void 0;w.replace({path:`/products`,query:{...e?{categoryId:e}:{},...O.value?{catalogId:O.value}:{},...k.value?{companyId:k.value}:{},...t?{season:t}:{},...n?{filterAxis:n}:{},...M.value?{q:M.value}:{}}})}function lt(e){w.push({path:`/product`,query:{id:e}})}function ut(e){return T.seasonCategories.find(t=>t.id===e)?.title??e}function dt(e){E.toggle(e)}function ft(){z.value=D.value,B.value=A.value,R.value=!0}function $(){R.value=!1}function pt(e,t){if(e)return`usage`;if(t)return`season`}function mt(e,t){let n=pt(e,t);return{...e?{categoryId:e}:{},...t?{season:t}:{},...n?{filterAxis:n}:{},...k.value?{companyId:k.value}:{},...M.value?{q:M.value}:{}}}function ht(){w.replace({path:`/products`,query:mt(z.value,B.value)}),$()}function gt(){z.value=``,B.value=``,w.replace({path:`/products`,query:mt(``,``)}),$()}return c(R,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`,ve,[l(fe,{class:`mobile-only`,title:W.value,"show-back":``,centered:``,onBack:c[0]||=e=>v(w).back()},{trailing:r(()=>[V.value?(i(),f(`button`,{key:0,type:`button`,class:t([`nav-filter`,{"nav-filter--active":U.value}]),"aria-label":`فیلتر محصولات`,"aria-expanded":R.value,onClick:ft},[l(ue,{size:18})],10,ye)):d(``,!0)]),_:1},8,[`title`]),h(`header`,be,[h(`div`,xe,[h(`h1`,Se,o(W.value),1),h(`p`,Ce,o(G.value.tagline||(M.value?`نتایج جستجو`:`مشاهده و ثبت سفارش`)),1)])]),V.value?(i(),f(`div`,we,[h(`div`,Te,[c[10]||=h(`header`,{class:`products-filter-sheet__head`},[h(`h2`,null,`فیلتر محصولات`)],-1),l(C,{modelValue:z.value,"onUpdate:modelValue":c[1]||=e=>z.value=e,class:`products-filter-section`,label:`دسته کاربرد`,"aria-label":`دسته کاربرد`,options:H.value},null,8,[`modelValue`,`options`]),l(C,{modelValue:B.value,"onUpdate:modelValue":c[2]||=e=>B.value=e,class:`products-filter-section`,label:`فصل`,"aria-label":`فصل`,options:nt.value},null,8,[`modelValue`,`options`]),h(`div`,Ee,[l(x,{onClick:ht},{default:r(()=>[...c[9]||=[p(`اعمال فیلتر`,-1)]]),_:1}),U.value?(i(),f(`button`,{key:0,type:`button`,class:`products-filter-clear`,onClick:gt},` پاک کردن فیلترها `)):d(``,!0)])])])):d(``,!0),(i(),_(ne,{to:`body`},[l(ie,{name:`products-filter-sheet`},{default:r(()=>[R.value&&V.value?(i(),f(`div`,{key:0,class:`products-filter-panel mobile-only`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`products-filter-title`,onClick:b($,[`self`])},[h(`div`,{class:`products-filter-sheet`,onClick:c[6]||=b(()=>{},[`stop`])},[c[13]||=h(`div`,{class:`products-filter-sheet__handle`,"aria-hidden":`true`},null,-1),h(`header`,{class:`products-filter-sheet__head`},[c[11]||=h(`h2`,{id:`products-filter-title`},`فیلتر محصولات`,-1),h(`button`,{type:`button`,class:`products-filter-sheet__close`,"aria-label":`بستن`,onClick:$},` × `)]),l(C,{modelValue:z.value,"onUpdate:modelValue":c[3]||=e=>z.value=e,class:`products-filter-section`,label:`دسته کاربرد`,"aria-label":`دسته کاربرد`,options:H.value},null,8,[`modelValue`,`options`]),l(C,{modelValue:B.value,"onUpdate:modelValue":c[4]||=e=>B.value=e,class:`products-filter-section`,label:`فصل`,"aria-label":`فصل`,options:nt.value},null,8,[`modelValue`,`options`]),h(`div`,De,[l(x,{block:``,onClick:ht},{default:r(()=>[...c[12]||=[p(`اعمال فیلتر`,-1)]]),_:1}),U.value?(i(),f(`button`,{key:0,type:`button`,class:`products-filter-clear`,onClick:gt},` پاک کردن فیلترها `)):d(``,!0),h(`button`,{type:`button`,class:`products-filter-link`,onClick:c[5]||=e=>{v(w).push(`/categories`),$()}},` مشاهده همه دستهبندیها `)])])])):d(``,!0)]),_:1})])),h(`div`,Oe,[I.value?(i(),f(`p`,ke,o(I.value),1)):F.value?(i(),_(pe,{key:1,variant:`grid`})):(i(),f(m,{key:2},[h(`section`,{class:t([`cat-banner`,{"cat-banner--photo":!!q.value}]),style:a(at.value)},[h(`div`,Ae,[G.value.lead?(i(),f(`p`,je,o(G.value.lead),1)):d(``,!0),G.value.headline||K.value&&q.value?(i(),f(`div`,Me,[K.value&&q.value?(i(),f(`span`,Ne,[(i(),_(s(K.value),{size:22,color:`#ffffff`}))])):d(``,!0),G.value.headline?(i(),f(`h2`,Pe,o(G.value.headline),1)):d(``,!0)])):G.value.headline?(i(),f(`h2`,Fe,o(G.value.headline),1)):d(``,!0),G.value.tagline?(i(),f(`p`,Ie,o(G.value.tagline),1)):d(``,!0)]),K.value&&!q.value?(i(),f(`span`,Le,[(i(),_(s(K.value),{size:26,color:`#ffffff`}))])):d(``,!0)],6),V.value?(i(),f(`div`,Re,[h(`div`,{class:`chips`,role:`tablist`,"aria-label":ot.value},[J.value===`season`?(i(),f(m,{key:0},[h(`button`,{type:`button`,class:t([`chip`,{"chip--active":!A.value}]),onClick:c[7]||=e=>Z(``)},` همه `,2),(i(!0),f(m,null,n(v(T).seasonCategories,e=>(i(),f(`button`,{key:e.id,type:`button`,class:t([`chip`,{"chip--active":A.value===e.id}]),onClick:t=>Z(e.id)},o(e.title),11,Be))),128))],64)):(i(),f(m,{key:1},[h(`button`,{type:`button`,class:t([`chip`,{"chip--active":!D.value}]),onClick:c[8]||=e=>Q(``)},` همه `,2),(i(!0),f(m,null,n(v(T).usageCategories,e=>(i(),f(`button`,{key:e.id,type:`button`,class:t([`chip`,{"chip--active":D.value===e.id}]),onClick:t=>Q(e.id)},o(e.title),11,Ve))),128))],64))],8,ze)])):d(``,!0),h(`div`,He,[h(`span`,null,`تعداد محصولات: `+o(Y.value.length.toLocaleString(`fa-IR`)),1),h(`button`,{type:`button`,class:`list-meta__sort`,"aria-label":ct.value,onClick:st},[...c[14]||=[ee(`<span class="list-meta__sort-icon" aria-hidden="true" data-v-082ad547><svg width="15" height="12" viewBox="0 0 15 12" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-082ad547><path d="M4.5 2.5V9.5" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" data-v-082ad547></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-082ad547></path><path d="M10.5 9.5V2.5" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" data-v-082ad547></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-082ad547></path></svg></span><span class="list-meta__sort-badge" data-v-082ad547>۱</span><span class="list-meta__sort-label" data-v-082ad547>مرتبسازی</span>`,3)]],8,Ue)]),h(`div`,We,[(i(!0),f(m,null,n(Y.value,e=>(i(),f(`article`,{key:e.id,class:`product-item`,onClick:t=>lt(e.id)},[h(`div`,{class:`product-item__image`,style:a(e.imageUrl?{backgroundImage:`url(${e.imageUrl})`}:void 0)},null,4),h(`div`,Ke,[h(`div`,qe,[h(`div`,Je,[h(`strong`,null,o(e.name),1),e.isNew?(i(),f(`span`,Ye,`جدید`)):d(``,!0)]),h(`button`,{type:`button`,class:`bookmark`,"aria-label":v(E).isFavorite(e.id)?`حذف از علاقهمندیها`:`افزودن به علاقهمندیها`,"aria-pressed":v(E).isFavorite(e.id),onClick:b(t=>dt(e.id),[`stop`])},[l(ge,{size:18,filled:v(E).isFavorite(e.id),color:v(E).isFavorite(e.id)?`var(--color-primary)`:`#9ca3af`},null,8,[`filled`,`color`])],8,Xe)]),h(`ul`,Ze,[h(`li`,null,`عرض: `+o(e.widthCm.toLocaleString(`fa-IR`))+` سانتیمتر`,1),h(`li`,null,`ترکیب: `+o(e.composition||`—`),1),h(`li`,null,`مناسب: `+o(ut(e.season)),1)]),h(`div`,Qe,[(i(!0),f(m,null,n(e.colors.slice(0,6),(t,n)=>(i(),f(`span`,{key:n,class:`swatch`,style:a(v(_e)(t,e.colorImages?.[n]||e.imageUrls?.[n]))},null,4))),128))]),h(`button`,{type:`button`,class:`details-link`,onClick:b(t=>lt(e.id),[`stop`])},[c[15]||=p(` مشاهده جزئیات `,-1),l(ce,{size:14})],8,$e)])],8,Ge))),128))]),Y.value.length?d(``,!0):(i(),f(`p`,et,`محصولی در این دسته یافت نشد.`))],64))])]))}}),[[`__scopeId`,`data-v-082ad547`]]);export{w as default}; |