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