1 line
16 KiB
JavaScript
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{l as x,r as te}from"./BasicIcon-DPmc0iaK.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,a as ie,c as ae,i as oe,l as se,o as ce,s as w}from"./index-DYwnTikp.js";import{t as T}from"./IconChevronBack-BsHmfODG.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-DnRfwA4b.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-DV8NqYZ8.js";import{n as O,t as ve}from"./productAvailability-B5nVr_sJ.js";async function ye(){return C(`/suggestions/me`)}var be=`/assets/level-medal-Avpe4Lqa.webp`,xe=`/assets/quick-categories-grid-MFEfEUjL.webp`,Se=`/assets/quick-catalog-request-Ck7EqicC.webp`,Ce=`/assets/latest-order-status-CfJ1sx5U.webp`,k={class:`suggest-panel`,"aria-label":`پیشنهاد اختصاصی`},A={class:`suggest-panel__head`},j={key:0,class:`suggest-panel__empty`},M={key:1,class:`suggest-panel__row scroll-x`},N=[`onClick`],P={key:0,class:`suggest-product__chip suggest-product__chip--oos`},F={key:1,class:`suggest-product__chip`},I=[`aria-label`,`aria-pressed`,`onClick`],L={class:`suggest-product__body`},R={class:`suggest-product__name`},z={class:`suggest-product__desc`},B={key:0,class:`suggest-product__swatches`},V={key:0,class:`suggest-product__swatch suggest-product__swatch--more`},H={class:`suggest-product__specs`},U={class:`suggest-product__spec`},W={class:`suggest-product__spec-copy`},we={class:`suggest-product__spec-val`},Te={class:`suggest-product__spec`},G={class:`suggest-product__spec-copy`},K={class:`suggest-product__spec-val`},q={class:`suggest-product__spec`},Ee={class:`suggest-product__spec-copy`},J={class:`suggest-product__spec-val`},Y=[`disabled`,`onClick`],X=4,De=_(b({__name:`HomeSuggestionsSection`,props:{items:{}},setup(e){let t=e,r=re(),s=se(),{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>X?t-X:0}function ie(e){return{id:e.productId,name:e.productName,code:e.productCode,categoryId:``,season:`all_season`,widthCm:e.widthCm??0,composition:e.composition??``,weightGrams:e.weightGrams,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 ae(e){r.push({path:`/product`,query:{id:e.productId}})}async function oe(e){await s.toggle(e)}async function w(e){await v(ie(e))}let T=l(()=>t.items.length>0);function le(e){return e.composition?.trim()||`—`}function ue(e){return e.widthCm?`${S(e.widthCm)} cm`:`—`}function de(e){return e.weightGrams?`${S(e.weightGrams)} گرم`:`—`}return(t,l)=>(i(),d(`section`,k,[h(`header`,A,[l[3]||=ee(`<div class="suggest-panel__titles" data-v-58849343><h3 class="suggest-panel__title" data-v-58849343><span class="suggest-panel__sparkles" aria-hidden="true" data-v-58849343><svg width="18" height="18" viewBox="0 0 24 24" fill="none" data-v-58849343><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-58849343></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-58849343></path></svg></span> پیشنهادهای اختصاصی برای شما </h3><p class="suggest-panel__sub" data-v-58849343>بر اساس خریدهای قبلی و علاقهمندیهای شما</p></div>`,1),h(`button`,{type:`button`,class:`suggest-panel__all`,onClick:l[0]||=e=>y(r).push(`/products`)},[l[2]||=f(` مشاهده همه `,-1),c(ce,{size:14})])]),T.value?(i(),d(`div`,M,[(i(!0),d(p,null,n(e.items,e=>(i(),d(`article`,{key:e.id,class:`suggest-product`,onClick:t=>ae(e)},[h(`div`,{class:`suggest-product__media`,style:a(e.imageUrl?{backgroundImage:`url(${e.imageUrl})`}:void 0)},[y(ve)({isActive:e.productIsActive})?(i(),d(`span`,P,`ناموجود`)):(i(),d(`span`,F,`کالیته پیشنهادی`)),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=>oe(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,I)],4),h(`div`,L,[h(`h4`,R,o(e.productName),1),h(`p`,z,o(ne(e)),1),e.colors?.length?(i(),d(`div`,B,[(i(!0),d(p,null,n(e.colors.slice(0,X),(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`,V,` +`+o(y(S)(C(e))),1)):u(``,!0)])):u(``,!0),h(`div`,H,[h(`div`,U,[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`,W,[l[4]||=h(`span`,{class:`suggest-product__spec-key`},`جنس`,-1),h(`span`,we,o(le(e)),1)])]),l[10]||=h(`div`,{class:`suggest-product__spec-divider`,"aria-hidden":`true`},null,-1),h(`div`,Te,[l[7]||=ee(`<span class="suggest-product__spec-icon" aria-hidden="true" data-v-58849343><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" data-v-58849343><path d="M12 3v18" stroke-linecap="round" data-v-58849343></path><path d="M8 7h8l-1.2 10.2a2 2 0 0 1-2 1.8h-1.6a2 2 0 0 1-2-1.8L8 7Z" stroke-linejoin="round" data-v-58849343></path><path d="M7 7h10" stroke-linecap="round" data-v-58849343></path></svg></span>`,1),h(`span`,G,[l[6]||=h(`span`,{class:`suggest-product__spec-key`},`وزن`,-1),h(`span`,K,o(de(e)),1)])]),l[11]||=h(`div`,{class:`suggest-product__spec-divider`,"aria-hidden":`true`},null,-1),h(`div`,q,[l[9]||=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`,Ee,[l[8]||=h(`span`,{class:`suggest-product__spec-key`},`عرض`,-1),h(`span`,J,o(ue(e)),1)])])]),h(`button`,{type:`button`,class:`suggest-product__cta`,disabled:y(m),onClick:x(t=>w(e),[`stop`])},` درخواست کالیته `,8,Y)])],8,N))),128))])):(i(),d(`p`,j,` هنوز پیشنهاد اختصاصی برای شما ثبت نشده است. `)),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-58849343`]]),Oe={class:`page home-page`},ke={class:`home-header mobile-only`},Ae={class:`home-header__user`},je={class:`home-header__text`},Me={class:`home-header__hello`},Ne={class:`home-header__actions`},Pe={class:`home-desk-head desktop-only`},Fe={class:`home-desk-head__sub`},Ie={key:0,class:`home-error`},Le=[`aria-label`],Re={class:`hero-banner__content`},ze={key:0,class:`hero-banner__title`},Be={key:0},Ve={key:1,class:`hero-banner__title`},He={key:0,class:`hero-banner__dots`,role:`tablist`,"aria-label":`بنرها`},Ue=[`aria-label`,`aria-selected`,`onClick`],We={class:`quick-grid`,"aria-label":`دسترسی سریع`},Ge=[`onClick`],Ke={class:`quick-card__icon`,"aria-hidden":`true`},qe=[`src`],Je={class:`quick-card__label`},Ye={key:0,class:`level-card`,"aria-label":`سطح عضویت`},Xe={class:`level-card__top`},Ze={class:`level-card__identity`},Qe=[`src`],$e={class:`level-card__text`},et={class:`level-card__name`},tt={class:`level-card__next`},nt={class:`level-card__progress`},rt=[`aria-valuenow`],it={class:`level-card__points`},at={class:`section`},ot={class:`section__head`},st={class:`product-row scroll-x`},ct=[`onClick`],lt={key:0,class:`product-card__badge product-card__badge--oos`},ut={key:1,class:`product-card__badge`},dt={class:`product-card__body`},ft={class:`product-card__name`},pt={class:`product-card__sub`},mt=[`aria-label`,`aria-pressed`,`onClick`],Z=_(b({__name:`HomeView`,setup(ee){let _=re(),{goBack:b}=pe(`/`),C=ae(),ge=fe(),E=se(),D=g(!0),O=g(null),k=g([]),A=g([]),j=g([]),M=g(null),N=g(null),P=[{id:`qa-cat`,label:`دسته بندی`,to:`/categories`,image:xe},{id:`qa-club`,label:`وضعیت سفارش`,to:`/orders/latest-status`,image:Ce},{id:`qa-swatch`,label:`درخواست کالیته`,to:`/catalog-requests/latest-status`,image:Se}],F=[{id:`qa-cat`,label:`دسته بندی`,to:`/categories`,image:xe},{id:`qa-customers`,label:`وضعیت سفارش`,to:`/orders/latest-status`,image:Ce},{id:`qa-swatch`,label:`درخواست کالیته`,to:`/catalog-requests/latest-status`,image:Se}],I=l(()=>C.isAgent?F:P),L=l(()=>{let e=new Map(j.value.map(e=>[e.id,e]));return A.value.map(t=>{let n=e.get(t.productId);return{...t,composition:t.composition?.trim()||n?.composition?.trim()||``,widthCm:t.widthCm??n?.widthCm,weightGrams:t.weightGrams??n?.weightGrams,colors:t.colors?.length?t.colors:n?.colors??[],colorImages:t.colorImages?.some(Boolean)?t.colorImages:n?.colorImages,productIsActive:t.productIsActive??n?.isActive}})}),R={id:`fallback`,slot:`home_hero`,title:`کالکشن پاییز و زمستان`,subtitle:`جدیدترین پارچهها`,ctaLabel:`مشاهده کالکشن`,ctaLink:`/categories`,imageUrl:``,showTitle:!0,showSubtitle:!0,showCta:!0},z=g([R]),B=g(0),V=g(`hero-next`),H,U=l(()=>z.value[B.value]??R),W=l(()=>U.value.bannerLink?.trim()||``),we=l(()=>{let e=U.value;return e.showTitle!==!1&&e.title||e.showSubtitle!==!1&&e.subtitle||e.showCta!==!1&&e.ctaLabel});function Te(e){if(e.imageUrl)return{"--hero-image":`url("${e.imageUrl}")`}}function G(e,t){let n=z.value.length;if(!n)return;let r=(e%n+n)%n;r!==B.value&&(t===1?V.value=`hero-next`:t===-1?V.value=`hero-prev`:B.value===n-1&&r===0?V.value=`hero-next`:B.value===0&&r===n-1?V.value=`hero-prev`:V.value=r>B.value?`hero-next`:`hero-prev`,B.value=r)}function K(){q(),!(z.value.length<2)&&(H=window.setInterval(()=>{G(B.value+1,1)},5500))}function q(){H&&window.clearInterval(H),H=void 0}function Ee(e){G(e),K()}let{onTouchStart:J,onTouchEnd:Y}=me({enabled:()=>z.value.length>1,onSwipe(e){G(B.value+e,e),K()}}),X=l(()=>C.user?.firstName||`کاربر`),Z=l(()=>C.user?.lastName||``),ht=ne(`(max-width: 467px)`),gt=l(()=>ht.value?36:44),_t=l(()=>ht.value?X.value:`${X.value} ${Z.value}`.trim()),Q=l(()=>{if(N.value)return N.value;let e=C.user;return{label:e?.levelLabel||`برنزی`,nextLabel:e?.nextLevelLabel||`نقرهای`,pointsRemaining:e?.pointsToNext??0,progressPercent:e?.levelProgress??0}});e(q),m(async()=>{D.value=!0,O.value=null;try{let[e,t]=await Promise.all([ge.loadBrowseProducts().then(e=>(j.value=e,e)),de(`home_hero`).catch(()=>[]),E.hydrate()]);if(t.length&&(z.value=t),K(),k.value=e.filter(e=>e.isNew).slice(0,6),k.value.length||(k.value=e.slice(0,6)),C.isAgent)try{let e=await ue();N.value={label:e.levelLabel,nextLabel:e.nextLevelLabel,pointsRemaining:e.pointsToNext,progressPercent:e.levelProgress}}catch{}else try{A.value=await ye()}catch{A.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(){$(U.value.ctaLink.trim()||`/categories`)}function yt(e){W.value&&(e.target.closest(`.hero-banner__cta, .hero-banner__dots`)||he(W.value,_))}async function bt(e){M.value=null;try{await E.toggle(e)}catch(e){M.value=e instanceof Error?e.message:`ذخیره علاقهمندی ناموفق بود.`}}return(e,l)=>(i(),d(`div`,Oe,[h(`header`,ke,[h(`button`,{type:`button`,class:`icon-btn`,"aria-label":`بازگشت`,onClick:l[0]||=(...e)=>y(b)&&y(b)(...e)},[c(T,{size:20})]),h(`div`,Ae,[c(oe,{class:`home-header__avatar`,src:y(C).user?.avatarUrl,initials:X.value.charAt(0),size:gt.value},null,8,[`src`,`initials`,`size`]),h(`div`,je,[h(`p`,Me,` سلام، `+o(_t.value),1),l[6]||=h(`p`,{class:`home-header__welcome`},`خوش آمدید`,-1)])]),h(`div`,Ne,[c(ie,{variant:`inline`}),h(`button`,{type:`button`,class:`icon-btn`,"aria-label":`اعلانها`,onClick:l[1]||=e=>$(`/profile/notifications`)},[c(w,{size:20})])])]),h(`header`,Pe,[h(`div`,null,[l[7]||=h(`h1`,{class:`home-desk-head__title`},`خانه`,-1),h(`p`,Fe,` سلام `+o(X.value)+` `+o(Z.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`,Ie,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":!!W.value}]),"aria-label":U.value.title,onClick:yt,onTouchstartPassive:l[2]||=(...e)=>y(J)&&y(J)(...e),onTouchendPassive:l[3]||=(...e)=>y(Y)&&y(Y)(...e)},[c(te,{name:V.value,tag:`div`,class:`hero-banner__stage`},{default:r(()=>[(i(),d(`article`,{key:U.value.id,class:t([`hero-slide`,{"hero-slide--copy":we.value}]),style:a(Te(U.value))},[l[8]||=h(`div`,{class:`hero-slide__media`,"aria-hidden":`true`},null,-1),h(`div`,Re,[U.value.showTitle===!1?U.value.showSubtitle!==!1&&U.value.subtitle?(i(),d(`p`,Ve,[h(`span`,null,o(U.value.subtitle),1)])):u(``,!0):(i(),d(`h2`,ze,[f(o(U.value.title)+` `,1),U.value.showSubtitle!==!1&&U.value.subtitle?(i(),d(`span`,Be,o(U.value.subtitle),1)):u(``,!0)])),U.value.showCta!==!1&&U.value.ctaLabel?(i(),d(`button`,{key:2,type:`button`,class:`hero-banner__cta`,onClick:x(vt,[`stop`])},o(U.value.ctaLabel),1)):u(``,!0)])],6))]),_:1},8,[`name`]),z.value.length>1?(i(),d(`div`,He,[(i(!0),d(p,null,n(z.value,(e,n)=>(i(),d(`button`,{key:e.id,type:`button`,class:t([`dot`,{"dot--active":n===B.value}]),"aria-label":e.title,"aria-selected":n===B.value,onClick:x(e=>Ee(n),[`stop`])},null,10,Ue))),128))])):u(``,!0)],42,Le),h(`section`,We,[(i(!0),d(p,null,n(I.value,e=>(i(),d(`button`,{key:e.id,type:`button`,class:`quick-card`,onClick:t=>$(e.to)},[h(`span`,Ke,[e.image?(i(),d(`img`,{key:0,class:`quick-card__image`,src:e.image,alt:``},null,8,qe)):(i(),v(s(e.icon),{key:1,size:20}))]),h(`span`,Je,o(e.label),1)],8,Ge))),128))]),y(C).isAgent?(i(),d(`section`,Ye,[h(`div`,Xe,[h(`div`,Ze,[h(`img`,{class:`level-card__medal`,src:y(be),alt:``,width:`48`,height:`48`,"aria-hidden":`true`},null,8,Qe),h(`div`,$e,[l[9]||=h(`span`,{class:`level-card__eyebrow`},`سطح شما`,-1),h(`strong`,et,o(Q.value.label),1),h(`span`,tt,`تا سطح `+o(Q.value.nextLabel),1)])]),h(`button`,{type:`button`,class:`level-card__details`,onClick:l[4]||=e=>$(`/profile`)},` جزئیات سطح `)]),h(`div`,nt,[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,rt),h(`span`,it,o(y(S)(Q.value.pointsRemaining))+` امتیاز دیگر `,1)])])):u(``,!0),y(C).isAgent?u(``,!0):(i(),v(De,{key:1,class:`home-suggestions`,items:L.value},null,8,[`items`])),h(`section`,at,[h(`div`,ot,[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(ce,{size:14})])]),h(`div`,st,[(i(!0),d(p,null,n(k.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(ve)(e)?(i(),d(`span`,lt,`ناموجود`)):e.isNew?(i(),d(`span`,ut,`جدید`)):u(``,!0)],6),h(`div`,dt,[h(`strong`,ft,o(e.name),1),h(`span`,pt,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,mt)])],8,ct))),128))])])],64))],2)]))}}),[[`__scopeId`,`data-v-dc4738e7`]]);export{Z as default}; |