Files
nademitex_user/dist/assets/HomeView-BaCeq3_m.js
T

1 line
16 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,_ as c,c as l,d as u,f as d,g as f,h as ee,i as p,k as m,l as h,nt as g,t as _,u as v,ut as y,v as b}from"./_plugin-vue_export-helper-1xMDlcEE.js";import{r as te,u as x}from"./BasicIcon-ba1FsUKx.js";import{n as ne}from"./dist-Bc4P4ngC.js";import{o as S}from"./format-C72AoJ2H.js";import{n as C}from"./http-CU_N-R2R.js";import{c as re,d as ie,l as ae,o as oe,s as se,u as w,w as T}from"./index-CON313Q2.js";import{t as ce}from"./IconChevronBack-DytWz6TD.js";import{t as le}from"./PageSkeleton-DYdjm4l9.js";import{n as ue,r as de,t as fe}from"./crm-CgnSby61.js";import{t as pe}from"./useGoBack-B1rclh3v.js";import{t as me}from"./useTouchSwipe-C8fUyAcQ.js";import{t as he}from"./bannerLink-BW8t2Oqp.js";import{t as ge}from"./IconBookmark-CQq-TOS-.js";import{t as _e}from"./IconHeart-CvzbNH_T.js";import{n as E,t as D}from"./AddressCompletionModal-BuNBCK1j.js";import{n as O,t as k}from"./productAvailability-B5nVr_sJ.js";async function ve(){return C(`/suggestions/me`)}var ye=`/assets/level-medal-Avpe4Lqa.webp`,A=`/assets/quick-categories-grid-MFEfEUjL.webp`,be=`/assets/quick-catalog-request-Ck7EqicC.webp`,xe=`/assets/latest-order-status-CfJ1sx5U.webp`,j={class:`suggest-panel`,"aria-label":`پیشنهاد اختصاصی`},M={class:`suggest-panel__head`},N={key:0,class:`suggest-panel__empty`},P={key:1,class:`suggest-panel__row scroll-x`},F=[`onClick`],Se={key:0,class:`suggest-product__chip suggest-product__chip--oos`},I={key:1,class:`suggest-product__chip`},L=[`aria-label`,`aria-pressed`,`onClick`],R={class:`suggest-product__body`},z={class:`suggest-product__name`},B={class:`suggest-product__desc`},V={key:0,class:`suggest-product__swatches`},H={key:0,class:`suggest-product__swatch suggest-product__swatch--more`},U={class:`suggest-product__specs`},W={class:`suggest-product__spec`},G={class:`suggest-product__spec-copy`},Ce={class:`suggest-product__spec-val`},we={class:`suggest-product__spec`},K={class:`suggest-product__spec-copy`},q={class:`suggest-product__spec-val`},J=[`disabled`,`onClick`],Y=4,Te=_(b({__name:`HomeSuggestionsSection`,props:{items:{}},setup(e){let t=e,r=T(),s=ie(),{requesting:m,addressModalOpen:g,addressError:_,requestCatalog:v,submitAddressAndRequest:b,closeAddressModal:te}=E();function ne(e){return e.note?.trim()||e.subtitle?.trim()||`مشابه خریدهای قبلی شما`}function C(e){let t=e.colors?.length??0;return t>Y?t-Y:0}function ae(e){return{id:e.productId,name:e.productName,code:e.productCode,categoryId:``,season:`all_season`,widthCm:e.widthCm??0,composition:e.composition??``,colors:e.colors??(e.color?[e.color]:[]),colorImages:e.colorImages,tags:[],isNew:!!e.isNew,imageUrl:e.imageUrl,subtitle:e.subtitle,rollMeters:1,catalogName:e.catalogName,catalogCode:e.catalogCode,color:e.color,isActive:e.productIsActive!==!1}}function oe(e){r.push({path:`/product`,query:{id:e.productId}})}async function se(e){await s.toggle(e)}async function w(e){await v(ae(e))}let ce=l(()=>t.items.length>0);function le(e){return e.composition?.trim()||`—`}function ue(e){return e.widthCm?`${S(e.widthCm)} cm`:`—`}return(t,l)=>(i(),d(`section`,j,[h(`header`,M,[l[3]||=ee(`<div class="suggest-panel__titles" data-v-b0ad0afd><h3 class="suggest-panel__title" data-v-b0ad0afd><span class="suggest-panel__sparkles" aria-hidden="true" data-v-b0ad0afd><svg width="18" height="18" viewBox="0 0 24 24" fill="none" data-v-b0ad0afd><path d="M12 2l1.2 4.2L17.5 8 13.2 9.2 12 13.5 10.8 9.2 6.5 8l4.3-1.8L12 2Z" fill="#c9a227" data-v-b0ad0afd></path><path d="M19 14l.7 2.4 2.4.7-2.4.7-.7 2.4-.7-2.4-2.4-.7 2.4-.7.7-2.4Z" fill="#d4af37" data-v-b0ad0afd></path></svg></span> پیشنهادهای اختصاصی برای شما </h3><p class="suggest-panel__sub" data-v-b0ad0afd>بر اساس خریدهای قبلی و علاقه‌مندی‌های شما</p></div>`,1),h(`button`,{type:`button`,class:`suggest-panel__all`,onClick:l[0]||=e=>y(r).push(`/products`)},[l[2]||=f(` مشاهده همه `,-1),c(re,{size:14})])]),ce.value?(i(),d(`div`,P,[(i(!0),d(p,null,n(e.items,e=>(i(),d(`article`,{key:e.id,class:`suggest-product`,onClick:t=>oe(e)},[h(`div`,{class:`suggest-product__media`,style:a(e.imageUrl?{backgroundImage:`url(${e.imageUrl})`}:void 0)},[y(k)({isActive:e.productIsActive})?(i(),d(`span`,Se,`ناموجود`)):(i(),d(`span`,I,`کالیته پیشنهادی`)),h(`button`,{type:`button`,class:`suggest-product__save`,"aria-label":y(s).isFavorite(e.productId)?`حذف از علاقه‌مندی‌ها`:`افزودن به علاقه‌مندی‌ها`,"aria-pressed":y(s).isFavorite(e.productId),onClick:x(t=>se(e.productId),[`stop`])},[c(ge,{size:18,filled:y(s).isFavorite(e.productId),color:y(s).isFavorite(e.productId)?`var(--color-primary)`:`#1f2937`},null,8,[`filled`,`color`])],8,L)],4),h(`div`,R,[h(`h4`,z,o(e.productName),1),h(`p`,B,o(ne(e)),1),e.colors?.length?(i(),d(`div`,V,[(i(!0),d(p,null,n(e.colors.slice(0,Y),(t,n)=>(i(),d(`span`,{key:`${e.id}-${n}`,class:`suggest-product__swatch`,style:a(y(O)(t,e.colorImages?.[n]))},null,4))),128)),C(e)?(i(),d(`span`,H,` +`+o(y(S)(C(e))),1)):u(``,!0)])):u(``,!0),h(`div`,U,[h(`div`,W,[l[5]||=h(`span`,{class:`suggest-product__spec-icon`,"aria-hidden":`true`},[h(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`},[h(`path`,{d:`M12 4 20 8v8l-8 4-8-4V8l8-4Z`,"stroke-linejoin":`round`}),h(`path`,{d:`M4 10l8 4 8-4`,"stroke-linecap":`round`,"stroke-linejoin":`round`})])],-1),h(`span`,G,[l[4]||=h(`span`,{class:`suggest-product__spec-key`},`جنس`,-1),h(`span`,Ce,o(le(e)),1)])]),l[8]||=h(`div`,{class:`suggest-product__spec-divider`,"aria-hidden":`true`},null,-1),h(`div`,we,[l[7]||=h(`span`,{class:`suggest-product__spec-icon`,"aria-hidden":`true`},[h(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`},[h(`path`,{d:`M6 4h12v16H6z`,"stroke-linejoin":`round`}),h(`path`,{d:`M9 8h6M9 12h4`,"stroke-linecap":`round`})])],-1),h(`span`,K,[l[6]||=h(`span`,{class:`suggest-product__spec-key`},`عرض`,-1),h(`span`,q,o(ue(e)),1)])])]),h(`button`,{type:`button`,class:`suggest-product__cta`,disabled:y(m),onClick:x(t=>w(e),[`stop`])},` درخواست کالیته `,8,J)])],8,F))),128))])):(i(),d(`p`,N,` هنوز پیشنهاد اختصاصی برای شما ثبت نشده است. `)),c(D,{open:y(g),error:y(_),loading:y(m),onClose:l[1]||=e=>y(te)(),onSubmit:y(b)},null,8,[`open`,`error`,`loading`,`onSubmit`])]))}}),[[`__scopeId`,`data-v-b0ad0afd`]]),Ee={class:`page home-page`},De={class:`home-header mobile-only`},Oe={class:`home-header__user`},ke={class:`home-header__text`},Ae={class:`home-header__hello`},je={class:`home-header__actions`},Me={class:`home-desk-head desktop-only`},Ne={class:`home-desk-head__sub`},Pe={key:0,class:`home-error`},Fe=[`aria-label`],Ie={class:`hero-banner__content`},Le={key:0,class:`hero-banner__title`},Re={key:0},ze={key:1,class:`hero-banner__title`},Be={key:0,class:`hero-banner__dots`,role:`tablist`,"aria-label":`بنرها`},Ve=[`aria-label`,`aria-selected`,`onClick`],He={class:`quick-grid`,"aria-label":`دسترسی سریع`},Ue=[`onClick`],We={class:`quick-card__icon`,"aria-hidden":`true`},Ge=[`src`],Ke={class:`quick-card__label`},qe={key:0,class:`level-card`,"aria-label":`سطح عضویت`},Je={class:`level-card__top`},Ye={class:`level-card__identity`},Xe=[`src`],Ze={class:`level-card__text`},Qe={class:`level-card__name`},$e={class:`level-card__next`},et={class:`level-card__progress`},tt=[`aria-valuenow`],nt={class:`level-card__points`},rt={class:`section`},it={class:`section__head`},at={class:`product-row scroll-x`},ot=[`onClick`],st={key:0,class:`product-card__badge product-card__badge--oos`},ct={key:1,class:`product-card__badge`},lt={class:`product-card__body`},ut={class:`product-card__name`},dt={class:`product-card__sub`},ft=[`aria-label`,`aria-pressed`,`onClick`],X=_(b({__name:`HomeView`,setup(ee){let _=T(),{goBack:b}=pe(`/`),C=w(),ge=fe(),E=ie(),D=g(!0),O=g(null),j=g([]),M=g([]),N=g([]),P=g(null),F=g(null),Se=[{id:`qa-cat`,label:`دسته بندی`,to:`/categories`,image:A},{id:`qa-club`,label:`وضعیت سفارش`,to:`/orders/latest-status`,image:xe},{id:`qa-swatch`,label:`درخواست کالیته`,to:`/catalog-requests/latest-status`,image:be}],I=[{id:`qa-cat`,label:`دسته بندی`,to:`/categories`,image:A},{id:`qa-customers`,label:`وضعیت سفارش`,to:`/orders/latest-status`,image:xe},{id:`qa-swatch`,label:`درخواست کالیته`,to:`/catalog-requests/latest-status`,image:be}],L=l(()=>C.isAgent?I:Se),R=l(()=>{let e=new Map(N.value.map(e=>[e.id,e]));return M.value.map(t=>{let n=e.get(t.productId);return{...t,composition:t.composition?.trim()||n?.composition?.trim()||``,widthCm:t.widthCm??n?.widthCm,colors:t.colors?.length?t.colors:n?.colors??[],colorImages:t.colorImages?.some(Boolean)?t.colorImages:n?.colorImages,productIsActive:t.productIsActive??n?.isActive}})}),z={id:`fallback`,slot:`home_hero`,title:`کالکشن پاییز و زمستان`,subtitle:`جدیدترین پارچه‌ها`,ctaLabel:`مشاهده کالکشن`,ctaLink:`/categories`,imageUrl:``,showTitle:!0,showSubtitle:!0,showCta:!0},B=g([z]),V=g(0),H=g(`hero-next`),U,W=l(()=>B.value[V.value]??z),G=l(()=>W.value.bannerLink?.trim()||``),Ce=l(()=>{let e=W.value;return e.showTitle!==!1&&e.title||e.showSubtitle!==!1&&e.subtitle||e.showCta!==!1&&e.ctaLabel});function we(e){if(e.imageUrl)return{"--hero-image":`url("${e.imageUrl}")`}}function K(e,t){let n=B.value.length;if(!n)return;let r=(e%n+n)%n;r!==V.value&&(t===1?H.value=`hero-next`:t===-1?H.value=`hero-prev`:V.value===n-1&&r===0?H.value=`hero-next`:V.value===0&&r===n-1?H.value=`hero-prev`:H.value=r>V.value?`hero-next`:`hero-prev`,V.value=r)}function q(){J(),!(B.value.length<2)&&(U=window.setInterval(()=>{K(V.value+1,1)},5500))}function J(){U&&window.clearInterval(U),U=void 0}function Y(e){K(e),q()}let{onTouchStart:X,onTouchEnd:pt}=me({enabled:()=>B.value.length>1,onSwipe(e){K(V.value+e,e),q()}}),Z=l(()=>C.user?.firstName||`کاربر`),mt=l(()=>C.user?.lastName||``),ht=ne(`(max-width: 467px)`),gt=l(()=>ht.value?36:44),_t=l(()=>ht.value?Z.value:`${Z.value} ${mt.value}`.trim()),Q=l(()=>{if(F.value)return F.value;let e=C.user;return{label:e?.levelLabel||`برنزی`,nextLabel:e?.nextLevelLabel||`نقره‌ای`,pointsRemaining:e?.pointsToNext??0,progressPercent:e?.levelProgress??0}});e(J),m(async()=>{D.value=!0,O.value=null;try{let[e,t]=await Promise.all([ge.loadBrowseProducts().then(e=>(N.value=e,e)),de(`home_hero`).catch(()=>[]),E.hydrate()]);if(t.length&&(B.value=t),q(),j.value=e.filter(e=>e.isNew).slice(0,6),j.value.length||(j.value=e.slice(0,6)),C.isAgent)try{let e=await ue();F.value={label:e.levelLabel,nextLabel:e.nextLevelLabel,pointsRemaining:e.pointsToNext,progressPercent:e.levelProgress}}catch{}else try{M.value=await ve()}catch{M.value=[]}}catch(e){O.value=e instanceof Error?e.message:`بارگذاری خانه ناموفق بود.`}finally{D.value=!1}});function $(e){if(/^https?:\/\//i.test(e)){window.location.assign(e);return}_.push(e)}function vt(){$(W.value.ctaLink.trim()||`/categories`)}function yt(e){G.value&&(e.target.closest(`.hero-banner__cta, .hero-banner__dots`)||he(G.value,_))}async function bt(e){P.value=null;try{await E.toggle(e)}catch(e){P.value=e instanceof Error?e.message:`ذخیره علاقه‌مندی ناموفق بود.`}}return(e,l)=>(i(),d(`div`,Ee,[h(`header`,De,[h(`button`,{type:`button`,class:`icon-btn`,"aria-label":`بازگشت`,onClick:l[0]||=(...e)=>y(b)&&y(b)(...e)},[c(ce,{size:20})]),h(`div`,Oe,[c(oe,{class:`home-header__avatar`,src:y(C).user?.avatarUrl,initials:Z.value.charAt(0),size:gt.value},null,8,[`src`,`initials`,`size`]),h(`div`,ke,[h(`p`,Ae,` سلام، `+o(_t.value),1),l[6]||=h(`p`,{class:`home-header__welcome`},`خوش آمدید`,-1)])]),h(`div`,je,[c(se,{variant:`inline`}),h(`button`,{type:`button`,class:`icon-btn`,"aria-label":`اعلان‌ها`,onClick:l[1]||=e=>$(`/profile/notifications`)},[c(ae,{size:20})])])]),h(`header`,Me,[h(`div`,null,[l[7]||=h(`h1`,{class:`home-desk-head__title`},`خانه`,-1),h(`p`,Ne,` سلام `+o(Z.value)+` `+o(mt.value)+` — خوش آمدید `,1)])]),h(`div`,{class:t([`page__scroll page__scroll--with-nav home-scroll`,{"home-scroll--customer":!y(C).isAgent}])},[O.value?(i(),d(`p`,Pe,o(O.value),1)):D.value?(i(),v(le,{key:1,variant:`home`})):(i(),d(p,{key:2},[h(`section`,{class:t([`hero-banner`,{"hero-banner--linked":!!G.value}]),"aria-label":W.value.title,onClick:yt,onTouchstartPassive:l[2]||=(...e)=>y(X)&&y(X)(...e),onTouchendPassive:l[3]||=(...e)=>y(pt)&&y(pt)(...e)},[c(te,{name:H.value,tag:`div`,class:`hero-banner__stage`},{default:r(()=>[(i(),d(`article`,{key:W.value.id,class:t([`hero-slide`,{"hero-slide--copy":Ce.value}]),style:a(we(W.value))},[l[8]||=h(`div`,{class:`hero-slide__media`,"aria-hidden":`true`},null,-1),h(`div`,Ie,[W.value.showTitle===!1?W.value.showSubtitle!==!1&&W.value.subtitle?(i(),d(`p`,ze,[h(`span`,null,o(W.value.subtitle),1)])):u(``,!0):(i(),d(`h2`,Le,[f(o(W.value.title)+` `,1),W.value.showSubtitle!==!1&&W.value.subtitle?(i(),d(`span`,Re,o(W.value.subtitle),1)):u(``,!0)])),W.value.showCta!==!1&&W.value.ctaLabel?(i(),d(`button`,{key:2,type:`button`,class:`hero-banner__cta`,onClick:x(vt,[`stop`])},o(W.value.ctaLabel),1)):u(``,!0)])],6))]),_:1},8,[`name`]),B.value.length>1?(i(),d(`div`,Be,[(i(!0),d(p,null,n(B.value,(e,n)=>(i(),d(`button`,{key:e.id,type:`button`,class:t([`dot`,{"dot--active":n===V.value}]),"aria-label":e.title,"aria-selected":n===V.value,onClick:x(e=>Y(n),[`stop`])},null,10,Ve))),128))])):u(``,!0)],42,Fe),h(`section`,He,[(i(!0),d(p,null,n(L.value,e=>(i(),d(`button`,{key:e.id,type:`button`,class:`quick-card`,onClick:t=>$(e.to)},[h(`span`,We,[e.image?(i(),d(`img`,{key:0,class:`quick-card__image`,src:e.image,alt:``},null,8,Ge)):(i(),v(s(e.icon),{key:1,size:20}))]),h(`span`,Ke,o(e.label),1)],8,Ue))),128))]),y(C).isAgent?(i(),d(`section`,qe,[h(`div`,Je,[h(`div`,Ye,[h(`img`,{class:`level-card__medal`,src:y(ye),alt:``,width:`48`,height:`48`,"aria-hidden":`true`},null,8,Xe),h(`div`,Ze,[l[9]||=h(`span`,{class:`level-card__eyebrow`},`سطح شما`,-1),h(`strong`,Qe,o(Q.value.label),1),h(`span`,$e,`تا سطح `+o(Q.value.nextLabel),1)])]),h(`button`,{type:`button`,class:`level-card__details`,onClick:l[4]||=e=>$(`/profile`)},` جزئیات سطح `)]),h(`div`,et,[h(`div`,{class:`level-card__bar`,role:`progressbar`,"aria-valuenow":Q.value.progressPercent,"aria-valuemin":`0`,"aria-valuemax":`100`},[h(`span`,{class:`level-card__bar-fill`,style:a({width:`${Q.value.progressPercent}%`})},null,4)],8,tt),h(`span`,nt,o(y(S)(Q.value.pointsRemaining))+` امتیاز دیگر `,1)])])):u(``,!0),y(C).isAgent?u(``,!0):(i(),v(Te,{key:1,class:`home-suggestions`,items:R.value},null,8,[`items`])),h(`section`,rt,[h(`div`,it,[l[11]||=h(`h3`,{class:`section__title`},`جدیدترین محصولات`,-1),h(`button`,{type:`button`,class:`section__link`,onClick:l[5]||=e=>$(`/products`)},[l[10]||=f(` مشاهده همه `,-1),c(re,{size:14})])]),h(`div`,at,[(i(!0),d(p,null,n(j.value,(e,n)=>(i(),d(`article`,{key:e.id,class:`product-card`,onClick:t=>$(`/product?id=${e.id}`)},[h(`div`,{class:t([`product-card__image`,`product-card__image--${n%3}`]),style:a(e.imageUrl?{backgroundImage:`url(${e.imageUrl})`}:void 0)},[y(k)(e)?(i(),d(`span`,st,`ناموجود`)):e.isNew?(i(),d(`span`,ct,`جدید`)):u(``,!0)],6),h(`div`,lt,[h(`strong`,ut,o(e.name),1),h(`span`,dt,o(e.subtitle),1),h(`button`,{type:`button`,class:t([`product-card__fav`,{"product-card__fav--on":y(E).isFavorite(e.id)}]),"aria-label":y(E).isFavorite(e.id)?`حذف از علاقه‌مندی‌ها`:`افزودن به علاقه‌مندی‌ها`,"aria-pressed":y(E).isFavorite(e.id),onClick:x(t=>bt(e.id),[`stop`])},[c(_e,{size:16,filled:y(E).isFavorite(e.id),color:y(E).isFavorite(e.id)?`var(--color-primary)`:`#b0b7c0`},null,8,[`filled`,`color`])],10,ft)])],8,ot))),128))])])],64))],2)]))}}),[[`__scopeId`,`data-v-9ed2d4b1`]]);export{X as default};