1 line
10 KiB
JavaScript
1 line
10 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 ee,_ as s,c,d as l,f as u,g as d,i as f,k as te,l as p,nt as m,t as ne,u as h,ut as g,v as _}from"./_plugin-vue_export-helper-1xMDlcEE.js";import{r as re,u as ie}from"./BasicIcon-Bzeb0Iwd.js";import{o as ae}from"./format-C72AoJ2H.js";import{n as v}from"./http-CU_N-R2R.js";import{M as oe,c as se,i as ce,l as le,o as ue,r as de,s as fe}from"./index-WUDoJ6iF.js";import{t as pe}from"./IconChevronBack-CDeN0Cbu.js";import{t as me}from"./PageSkeleton-DYdjm4l9.js";import{n as he,r as ge,t as _e}from"./crm-Bj4T2PId.js";import{t as ve}from"./useGoBack-LfBY_1QL.js";import{t as y}from"./quick-catalog-request-DKA752sk.js";import{t as ye}from"./IconHeart-CvzbNH_T.js";async function be(){return v(`/suggestions/me`)}var xe=`/assets/level-medal-Avpe4Lqa.webp`,b=`/assets/quick-categories-grid-MFEfEUjL.webp`,x=`/assets/latest-order-status-CfJ1sx5U.webp`,Se={class:`page home-page`},S={class:`home-header mobile-only`},C={class:`home-header__user`},w={class:`home-header__hello`},T={class:`home-header__actions`},E={class:`home-desk-head desktop-only`},D={class:`home-desk-head__sub`},O={class:`page__scroll page__scroll--with-nav home-scroll`},k={key:0,class:`home-error`},A=[`aria-label`],j={class:`hero-banner__content`},Ce={key:0,class:`hero-banner__title`},we={key:0},Te={key:1,class:`hero-banner__title`},Ee={key:0,class:`hero-banner__dots`,role:`tablist`,"aria-label":`بنرها`},De=[`aria-label`,`aria-selected`,`onClick`],Oe={class:`quick-grid`,"aria-label":`دسترسی سریع`},ke=[`onClick`],Ae={class:`quick-card__icon`,"aria-hidden":`true`},je=[`src`],Me={class:`quick-card__label`},Ne={key:0,class:`level-card`,"aria-label":`سطح عضویت`},Pe={class:`level-card__top`},Fe={class:`level-card__identity`},Ie=[`src`],Le={class:`level-card__text`},Re={class:`level-card__name`},ze={class:`level-card__next`},Be={class:`level-card__progress`},Ve=[`aria-valuenow`],He={class:`level-card__points`},Ue={key:1,class:`suggest-card`,"aria-label":`پیشنهاد اختصاصی`},We={class:`suggest-card__head`},Ge={key:0,class:`suggest-card__empty`},Ke={key:0,class:`suggest-card__row scroll-x`},qe=[`onClick`],Je={key:0,class:`suggest-card__badge`},Ye={class:`suggest-card__body`},Xe={class:`suggest-card__name`},Ze={class:`suggest-card__sub`},Qe={key:0,class:`suggest-card__note`},$e={class:`section`},et={class:`section__head`},tt={class:`product-row scroll-x`},nt=[`onClick`],rt={key:0,class:`product-card__badge`},it={class:`product-card__body`},at={class:`product-card__name`},ot={class:`product-card__sub`},st=[`aria-label`,`aria-pressed`,`onClick`],M=ne(_({__name:`HomeView`,setup(ne){let _=oe(),{goBack:v}=ve(`/`),M=se(),ct=_e(),N=le(),P=m(!0),F=m(null),I=m([]),L=m([]),R=m(null),z=m(null),lt=[{id:`qa-cat`,label:`دسته بندی`,to:`/categories`,image:b},{id:`qa-club`,label:`وضعیت سفارش`,to:`/orders/latest-status`,image:x},{id:`qa-swatch`,label:`درخواست کالیته`,to:`/catalog-requests/latest-status`,image:y}],ut=[{id:`qa-cat`,label:`دسته بندی`,to:`/categories`,image:b},{id:`qa-customers`,label:`وضعیت سفارش`,to:`/orders/latest-status`,image:x},{id:`qa-swatch`,label:`درخواست کالیته`,to:`/catalog-requests/latest-status`,image:y}],dt=c(()=>M.isAgent?ut:lt),B={id:`fallback`,slot:`home_hero`,title:`کالکشن پاییز و زمستان`,subtitle:`جدیدترین پارچهها`,ctaLabel:`مشاهده کالکشن`,ctaLink:`/categories`,imageUrl:``,showTitle:!0,showSubtitle:!0,showCta:!0},V=m([B]),H=m(0),U=m(`hero-next`),W,G=c(()=>V.value[H.value]??B),K=c(()=>{let e=G.value;return e.showTitle!==!1&&e.title||e.showSubtitle!==!1&&e.subtitle||e.showCta!==!1&&e.ctaLabel});function ft(e){if(e.imageUrl)return{"--hero-image":`url("${e.imageUrl}")`}}function q(e,t){let n=V.value.length;if(!n)return;let r=(e%n+n)%n;r!==H.value&&(t===1?U.value=`hero-next`:t===-1?U.value=`hero-prev`:H.value===n-1&&r===0?U.value=`hero-next`:H.value===0&&r===n-1?U.value=`hero-prev`:U.value=r>H.value?`hero-next`:`hero-prev`,H.value=r)}function J(){Y(),!(V.value.length<2)&&(W=window.setInterval(()=>{q(H.value+1,1)},5500))}function Y(){W&&window.clearInterval(W),W=void 0}function pt(e){q(e),J()}let X=c(()=>M.user?.firstName||`کاربر`),Z=c(()=>M.user?.lastName||``),Q=c(()=>{if(z.value)return z.value;let e=M.user;return{label:e?.levelLabel||`برنزی`,nextLabel:e?.nextLevelLabel||`نقرهای`,pointsRemaining:e?.pointsToNext??0,progressPercent:e?.levelProgress??0}});e(Y),te(async()=>{P.value=!0,F.value=null;try{let[e,t]=await Promise.all([ct.loadBrowseProducts(),ge(`home_hero`).catch(()=>[]),N.hydrate()]);if(t.length&&(V.value=t),J(),I.value=e.filter(e=>e.isNew).slice(0,6),I.value.length||(I.value=e.slice(0,6)),M.isAgent)try{let e=await he();z.value={label:e.levelLabel,nextLabel:e.nextLevelLabel,pointsRemaining:e.pointsToNext,progressPercent:e.levelProgress}}catch{}else try{L.value=await be()}catch{L.value=[]}}catch(e){F.value=e instanceof Error?e.message:`بارگذاری خانه ناموفق بود.`}finally{P.value=!1}});function $(e){if(/^https?:\/\//i.test(e)){window.location.assign(e);return}_.push(e)}function mt(){$(G.value.ctaLink.trim()||`/categories`)}async function ht(e){R.value=null;try{await N.toggle(e)}catch(e){R.value=e instanceof Error?e.message:`ذخیره علاقهمندی ناموفق بود.`}}return(e,c)=>(i(),u(`div`,Se,[p(`header`,S,[p(`button`,{type:`button`,class:`icon-btn`,"aria-label":`بازگشت`,onClick:c[0]||=(...e)=>g(v)&&g(v)(...e)},[s(pe,{size:20})]),p(`div`,C,[s(de,{class:`home-header__avatar`,src:g(M).user?.avatarUrl,initials:X.value.charAt(0),size:44},null,8,[`src`,`initials`]),p(`div`,null,[p(`p`,w,` سلام، `+o(X.value)+` `+o(Z.value),1),c[4]||=p(`p`,{class:`home-header__welcome`},`خوش آمدید`,-1)])]),p(`div`,T,[s(ce,{variant:`inline`}),p(`button`,{type:`button`,class:`icon-btn`,"aria-label":`اعلانها`,onClick:c[1]||=e=>$(`/profile/notifications`)},[s(fe,{size:20})])])]),p(`header`,E,[p(`div`,null,[c[5]||=p(`h1`,{class:`home-desk-head__title`},`خانه`,-1),p(`p`,D,` سلام `+o(X.value)+` `+o(Z.value)+` — خوش آمدید `,1)])]),p(`div`,O,[F.value?(i(),u(`p`,k,o(F.value),1)):P.value?(i(),h(me,{key:1,variant:`home`})):(i(),u(f,{key:2},[p(`section`,{class:`hero-banner`,"aria-label":G.value.title},[s(re,{name:U.value,tag:`div`,class:`hero-banner__stage`},{default:r(()=>[(i(),u(`article`,{key:G.value.id,class:t([`hero-slide`,{"hero-slide--copy":K.value}]),style:a(ft(G.value))},[c[6]||=p(`div`,{class:`hero-slide__media`,"aria-hidden":`true`},null,-1),p(`div`,j,[G.value.showTitle===!1?G.value.showSubtitle!==!1&&G.value.subtitle?(i(),u(`p`,Te,[p(`span`,null,o(G.value.subtitle),1)])):l(``,!0):(i(),u(`h2`,Ce,[d(o(G.value.title)+` `,1),G.value.showSubtitle!==!1&&G.value.subtitle?(i(),u(`span`,we,o(G.value.subtitle),1)):l(``,!0)])),G.value.showCta!==!1&&G.value.ctaLabel?(i(),u(`button`,{key:2,type:`button`,class:`hero-banner__cta`,onClick:mt},o(G.value.ctaLabel),1)):l(``,!0)])],6))]),_:1},8,[`name`]),V.value.length>1?(i(),u(`div`,Ee,[(i(!0),u(f,null,n(V.value,(e,n)=>(i(),u(`button`,{key:e.id,type:`button`,class:t([`dot`,{"dot--active":n===H.value}]),"aria-label":e.title,"aria-selected":n===H.value,onClick:e=>pt(n)},null,10,De))),128))])):l(``,!0)],8,A),p(`section`,Oe,[(i(!0),u(f,null,n(dt.value,e=>(i(),u(`button`,{key:e.id,type:`button`,class:`quick-card`,onClick:t=>$(e.to)},[p(`span`,Ae,[e.image?(i(),u(`img`,{key:0,class:`quick-card__image`,src:e.image,alt:``},null,8,je)):(i(),h(ee(e.icon),{key:1,size:20}))]),p(`span`,Me,o(e.label),1)],8,ke))),128))]),g(M).isAgent?(i(),u(`section`,Ne,[p(`div`,Pe,[p(`div`,Fe,[p(`img`,{class:`level-card__medal`,src:g(xe),alt:``,width:`48`,height:`48`,"aria-hidden":`true`},null,8,Ie),p(`div`,Le,[c[7]||=p(`span`,{class:`level-card__eyebrow`},`سطح شما`,-1),p(`strong`,Re,o(Q.value.label),1),p(`span`,ze,`تا سطح `+o(Q.value.nextLabel),1)])]),p(`button`,{type:`button`,class:`level-card__details`,onClick:c[2]||=e=>$(`/profile`)},` جزئیات سطح `)]),p(`div`,Be,[p(`div`,{class:`level-card__bar`,role:`progressbar`,"aria-valuenow":Q.value.progressPercent,"aria-valuemin":`0`,"aria-valuemax":`100`},[p(`span`,{class:`level-card__bar-fill`,style:a({width:`${Q.value.progressPercent}%`})},null,4)],8,Ve),p(`span`,He,o(g(ae)(Q.value.pointsRemaining))+` امتیاز دیگر `,1)])])):(i(),u(`section`,Ue,[p(`div`,We,[c[8]||=p(`h3`,{class:`suggest-card__title`},`پیشنهاد اختصاصی ما برای شما`,-1),L.value.length?l(``,!0):(i(),u(`p`,Ge,` هنوز پیشنهاد اختصاصی برای شما ثبت نشده است. `))]),L.value.length?(i(),u(`div`,Ke,[(i(!0),u(f,null,n(L.value,(e,n)=>(i(),u(`article`,{key:e.id,class:`suggest-card__item`,onClick:t=>$(`/product?id=${e.productId}`)},[p(`div`,{class:t([`suggest-card__image`,`suggest-card__image--${n%3}`]),style:a(e.imageUrl?{backgroundImage:`url(${e.imageUrl})`}:void 0)},[e.isNew?(i(),u(`span`,Je,`جدید`)):l(``,!0)],6),p(`div`,Ye,[p(`strong`,Xe,o(e.productName),1),p(`span`,Ze,o(e.subtitle||e.catalogName||e.productCode),1),e.note?(i(),u(`p`,Qe,o(e.note),1)):l(``,!0)])],8,qe))),128))])):l(``,!0)])),p(`section`,$e,[p(`div`,et,[c[10]||=p(`h3`,{class:`section__title`},`جدیدترین محصولات`,-1),p(`button`,{type:`button`,class:`section__link`,onClick:c[3]||=e=>$(`/products`)},[c[9]||=d(` مشاهده همه `,-1),s(ue,{size:14})])]),p(`div`,tt,[(i(!0),u(f,null,n(I.value,(e,n)=>(i(),u(`article`,{key:e.id,class:`product-card`,onClick:t=>$(`/product?id=${e.id}`)},[p(`div`,{class:t([`product-card__image`,`product-card__image--${n%3}`]),style:a(e.imageUrl?{backgroundImage:`url(${e.imageUrl})`}:void 0)},[e.isNew?(i(),u(`span`,rt,`جدید`)):l(``,!0)],6),p(`div`,it,[p(`strong`,at,o(e.name),1),p(`span`,ot,o(e.subtitle),1),p(`button`,{type:`button`,class:t([`product-card__fav`,{"product-card__fav--on":g(N).isFavorite(e.id)}]),"aria-label":g(N).isFavorite(e.id)?`حذف از علاقهمندیها`:`افزودن به علاقهمندیها`,"aria-pressed":g(N).isFavorite(e.id),onClick:ie(t=>ht(e.id),[`stop`])},[s(ye,{size:16,filled:g(N).isFavorite(e.id),color:g(N).isFavorite(e.id)?`var(--color-primary)`:`#b0b7c0`},null,8,[`filled`,`color`])],10,st)])],8,nt))),128))])])],64))])]))}}),[[`__scopeId`,`data-v-0781cdf2`]]);export{M as default}; |