Files
nademitex_user/dist/assets/HomeView-dqm__2Hc.js
T
2026-09-30 09:54:04 +03:30

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-C72AoJ2H.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-BPUhS8CY.js";import{t as oe}from"./IconChevronBack-DytWz6TD.js";import{t as se}from"./PageSkeleton-DYdjm4l9.js";import{n as ce,r as le,t as ue}from"./crm-BKPKhzCX.js";import{t as de}from"./useGoBack-BkqOD93C.js";import{t as D}from"./IconBookmark-CQq-TOS-.js";import{t as fe}from"./IconHeart-CvzbNH_T.js";import{n as O,t as k}from"./AddressCompletionModal-BQQfvcHU.js";import{n as A}from"./colorSwatch-BgOH1LE5.js";async function pe(){return C(`/suggestions/me`)}var me=`/assets/level-medal-Avpe4Lqa.webp`,j=`/assets/quick-categories-grid-MFEfEUjL.webp`,he=`/assets/quick-catalog-request-Ck7EqicC.webp`,ge=`/assets/latest-order-status-CfJ1sx5U.webp`,M={class:`suggest-panel`,"aria-label":`پیشنهاد اختصاصی`},N={class:`suggest-panel__head`},P={key:0,class:`suggest-panel__empty`},F={key:1,class:`suggest-panel__row scroll-x`},I=[`onClick`],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`},K={class:`suggest-product__spec-val`},_e={class:`suggest-product__spec`},ve={class:`suggest-product__spec-copy`},q={class:`suggest-product__spec-val`},J=[`disabled`,`onClick`],Y=4,ye=_(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}=O();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 oe(e){await v(re(e))}let se=l(()=>t.items.length>0);function ce(e){return e.composition?.trim()||`—`}function le(e){return e.widthCm?`${S(e.widthCm)} cm`:`—`}return(t,l)=>(i(),d(`section`,M,[h(`header`,N,[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})])]),se.value?(i(),d(`div`,F,[(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(D,{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(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(A)(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(ce(e)),1)])]),l[9]||=h(`div`,{class:`suggest-product__spec-divider`,"aria-hidden":`true`},null,-1),h(`div`,_e,[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`,ve,[l[7]||=h(`span`,{class:`suggest-product__spec-key`},`عرض`,-1),h(`span`,q,o(le(e)),1)])])]),h(`button`,{type:`button`,class:`suggest-product__cta`,disabled:y(m),onClick:x(t=>oe(e),[`stop`])},` درخواست کالیته `,8,J)])],8,I))),128))])):(i(),d(`p`,P,` هنوز پیشنهاد اختصاصی برای شما ثبت نشده است. `)),c(k,{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`]]),be={class:`page home-page`},xe={class:`home-header mobile-only`},Se={class:`home-header__user`},Ce={class:`home-header__hello`},we={class:`home-header__actions`},Te={class:`home-desk-head desktop-only`},Ee={class:`home-desk-head__sub`},De={key:0,class:`home-error`},Oe=[`aria-label`],ke={class:`hero-banner__content`},Ae={key:0,class:`hero-banner__title`},je={key:0},Me={key:1,class:`hero-banner__title`},Ne={key:0,class:`hero-banner__dots`,role:`tablist`,"aria-label":`بنرها`},Pe=[`aria-label`,`aria-selected`,`onClick`],Fe={class:`quick-grid`,"aria-label":`دسترسی سریع`},Ie=[`onClick`],Le={class:`quick-card__icon`,"aria-hidden":`true`},Re=[`src`],ze={class:`quick-card__label`},Be={key:0,class:`level-card`,"aria-label":`سطح عضویت`},Ve={class:`level-card__top`},He={class:`level-card__identity`},Ue=[`src`],We={class:`level-card__text`},Ge={class:`level-card__name`},Ke={class:`level-card__next`},qe={class:`level-card__progress`},Je=[`aria-valuenow`],Ye={class:`level-card__points`},Xe={class:`section`},Ze={class:`section__head`},Qe={class:`product-row scroll-x`},$e=[`onClick`],et={key:0,class:`product-card__badge`},tt={class:`product-card__body`},nt={class:`product-card__name`},rt={class:`product-card__sub`},it=[`aria-label`,`aria-pressed`,`onClick`],X=_(b({__name:`HomeView`,setup(ee){let _=ne(),{goBack:b}=de(`/`),C=ae(),D=ue(),O=E(),k=g(!0),A=g(null),M=g([]),N=g([]),P=g([]),F=g(null),I=g(null),L=[{id:`qa-cat`,label:`دسته بندی`,to:`/categories`,image:j},{id:`qa-club`,label:`وضعیت سفارش`,to:`/orders/latest-status`,image:ge},{id:`qa-swatch`,label:`درخواست کالیته`,to:`/catalog-requests/latest-status`,image:he}],R=[{id:`qa-cat`,label:`دسته بندی`,to:`/categories`,image:j},{id:`qa-customers`,label:`وضعیت سفارش`,to:`/orders/latest-status`,image:ge},{id:`qa-swatch`,label:`درخواست کالیته`,to:`/catalog-requests/latest-status`,image:he}],z=l(()=>C.isAgent?R:L),B=l(()=>{let e=new Map(P.value.map(e=>[e.id,e]));return N.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),_e=l(()=>{let e=K.value;return e.showTitle!==!1&&e.title||e.showSubtitle!==!1&&e.subtitle||e.showCta!==!1&&e.ctaLabel});function ve(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 X(e){q(e),J()}let Z=l(()=>C.user?.firstName||`کاربر`),at=l(()=>C.user?.lastName||``),Q=l(()=>{if(I.value)return I.value;let e=C.user;return{label:e?.levelLabel||`برنزی`,nextLabel:e?.nextLevelLabel||`نقره‌ای`,pointsRemaining:e?.pointsToNext??0,progressPercent:e?.levelProgress??0}});e(Y),m(async()=>{k.value=!0,A.value=null;try{let[e,t]=await Promise.all([D.loadBrowseProducts().then(e=>(P.value=e,e)),le(`home_hero`).catch(()=>[]),O.hydrate()]);if(t.length&&(H.value=t),J(),M.value=e.filter(e=>e.isNew).slice(0,6),M.value.length||(M.value=e.slice(0,6)),C.isAgent)try{let e=await ce();I.value={label:e.levelLabel,nextLabel:e.nextLevelLabel,pointsRemaining:e.pointsToNext,progressPercent:e.levelProgress}}catch{}else try{N.value=await pe()}catch{N.value=[]}}catch(e){A.value=e instanceof Error?e.message:`بارگذاری خانه ناموفق بود.`}finally{k.value=!1}});function $(e){if(/^https?:\/\//i.test(e)){window.location.assign(e);return}_.push(e)}function ot(){$(K.value.ctaLink.trim()||`/categories`)}async function st(e){F.value=null;try{await O.toggle(e)}catch(e){F.value=e instanceof Error?e.message:`ذخیره علاقه‌مندی ناموفق بود.`}}return(e,l)=>(i(),d(`div`,be,[h(`header`,xe,[h(`button`,{type:`button`,class:`icon-btn`,"aria-label":`بازگشت`,onClick:l[0]||=(...e)=>y(b)&&y(b)(...e)},[c(oe,{size:20})]),h(`div`,Se,[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`,Ce,` سلام، `+o(Z.value)+` `+o(at.value),1),l[4]||=h(`p`,{class:`home-header__welcome`},`خوش آمدید`,-1)])]),h(`div`,we,[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`,Te,[h(`div`,null,[l[5]||=h(`h1`,{class:`home-desk-head__title`},`خانه`,-1),h(`p`,Ee,` سلام `+o(Z.value)+` `+o(at.value)+` — خوش آمدید `,1)])]),h(`div`,{class:t([`page__scroll page__scroll--with-nav home-scroll`,{"home-scroll--customer":!y(C).isAgent}])},[A.value?(i(),d(`p`,De,o(A.value),1)):k.value?(i(),v(se,{key:1,variant:`home`})):(i(),d(p,{key:2},[h(`section`,{class:`hero-banner`,"aria-label":K.value.title},[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":_e.value}]),style:a(ve(K.value))},[l[6]||=h(`div`,{class:`hero-slide__media`,"aria-hidden":`true`},null,-1),h(`div`,ke,[K.value.showTitle===!1?K.value.showSubtitle!==!1&&K.value.subtitle?(i(),d(`p`,Me,[h(`span`,null,o(K.value.subtitle),1)])):u(``,!0):(i(),d(`h2`,Ae,[f(o(K.value.title)+` `,1),K.value.showSubtitle!==!1&&K.value.subtitle?(i(),d(`span`,je,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:ot},o(K.value.ctaLabel),1)):u(``,!0)])],6))]),_:1},8,[`name`]),H.value.length>1?(i(),d(`div`,Ne,[(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=>X(n)},null,10,Pe))),128))])):u(``,!0)],8,Oe),h(`section`,Fe,[(i(!0),d(p,null,n(z.value,e=>(i(),d(`button`,{key:e.id,type:`button`,class:`quick-card`,onClick:t=>$(e.to)},[h(`span`,Le,[e.image?(i(),d(`img`,{key:0,class:`quick-card__image`,src:e.image,alt:``},null,8,Re)):(i(),v(s(e.icon),{key:1,size:20}))]),h(`span`,ze,o(e.label),1)],8,Ie))),128))]),y(C).isAgent?(i(),d(`section`,Be,[h(`div`,Ve,[h(`div`,He,[h(`img`,{class:`level-card__medal`,src:y(me),alt:``,width:`48`,height:`48`,"aria-hidden":`true`},null,8,Ue),h(`div`,We,[l[7]||=h(`span`,{class:`level-card__eyebrow`},`سطح شما`,-1),h(`strong`,Ge,o(Q.value.label),1),h(`span`,Ke,`تا سطح `+o(Q.value.nextLabel),1)])]),h(`button`,{type:`button`,class:`level-card__details`,onClick:l[2]||=e=>$(`/profile`)},` جزئیات سطح `)]),h(`div`,qe,[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,Je),h(`span`,Ye,o(y(S)(Q.value.pointsRemaining))+` امتیاز دیگر `,1)])])):u(``,!0),y(C).isAgent?u(``,!0):(i(),v(ye,{key:1,class:`home-suggestions`,items:B.value},null,8,[`items`])),h(`section`,Xe,[h(`div`,Ze,[l[9]||=h(`h3`,{class:`section__title`},`جدیدترین محصولات`,-1),h(`button`,{type:`button`,class:`section__link`,onClick:l[3]||=e=>$(`/products`)},[l[8]||=f(` مشاهده همه `,-1),c(T,{size:14})])]),h(`div`,Qe,[(i(!0),d(p,null,n(M.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`,et,`جدید`)):u(``,!0)],6),h(`div`,tt,[h(`strong`,nt,o(e.name),1),h(`span`,rt,o(e.subtitle),1),h(`button`,{type:`button`,class:t([`product-card__fav`,{"product-card__fav--on":y(O).isFavorite(e.id)}]),"aria-label":y(O).isFavorite(e.id)?`حذف از علاقه‌مندی‌ها`:`افزودن به علاقه‌مندی‌ها`,"aria-pressed":y(O).isFavorite(e.id),onClick:x(t=>st(e.id),[`stop`])},[c(fe,{size:16,filled:y(O).isFavorite(e.id),color:y(O).isFavorite(e.id)?`var(--color-primary)`:`#b0b7c0`},null,8,[`filled`,`color`])],10,it)])],8,$e))),128))])])],64))],2)]))}}),[[`__scopeId`,`data-v-85931340`]]);export{X as default};