1 line
8.0 KiB
JavaScript
1 line
8.0 KiB
JavaScript
import{A as e,Ct as t,E as n,F as r,G as ee,I as i,K as a,L as o,M as s,O as c,P as l,Q as te,T as ne,Y as u,_ as re,bt as d,ft as f,j as p,k as m,n as h,q as g,wt as _,xt as v}from"./BasicIcon-CjTTsi6o.js";import{o as ie}from"./format-BHJptHdF.js";import{b as y,c as ae,i as oe,l as se,o as ce,r as le,s as b,x}from"./index-BQQA5ZX-.js";import{t as ue}from"./IconChevronBack-B10eZjCQ.js";import{t as S}from"./IconLayoutGrid-fpJ_H2ee.js";import{t as de}from"./IconDiamond-Yhg3u2_R.js";import{t as fe}from"./PageSkeleton-CyATkHE1.js";import{n as pe,r as me,t as he}from"./crm-DPw1h61_.js";import{t as ge}from"./useGoBack-D3aJ73Q-.js";import{t as _e}from"./IconHeart-BmvFB3Xr.js";var C=[`width`,`height`],ve=o({__name:`IconMedal`,props:{size:{default:44}},setup(e){return(t,n)=>(g(),s(`svg`,{class:`icon-medal`,width:e.size,height:e.size,viewBox:`0 0 48 48`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`},[...n[0]||=[l(`<path d="M18 28.5L14 44l10-5 10 5-4-15.5" fill="#C0C7D1"></path><path d="M18 28.5L14 44l10-5V28.5H18Z" fill="#A8B0BC"></path><circle cx="24" cy="18" r="14" fill="#D8DEE6"></circle><circle cx="24" cy="18" r="11" fill="#F3F5F8" stroke="#B8C0CB" stroke-width="1.5"></circle><path d="M24 10.5l2.2 4.5 5 .7-3.6 3.5.9 5L24 21.8 19.5 24l.9-5-3.6-3.5 5-.7L24 10.5Z" fill="#8B95A5"></path>`,5)]],8,C))}}),w={class:`page home-page`},T={class:`home-header`},E={class:`home-header__user`},D={class:`home-header__hello`},O={class:`home-header__actions`},k={class:`page__scroll page__scroll--with-nav home-scroll`},A={key:0,class:`home-error`},j=[`aria-label`],M={class:`hero-banner__content`},N={class:`hero-banner__title`},P={key:0},F={key:0,class:`hero-banner__dots`,role:`tablist`,"aria-label":`بنرها`},ye=[`aria-label`,`aria-selected`,`onClick`],be={class:`quick-grid`,"aria-label":`دسترسی سریع`},xe=[`onClick`],Se={class:`quick-card__icon`,"aria-hidden":`true`},Ce={class:`quick-card__label`},we={class:`level-card`,"aria-label":`سطح عضویت`},Te={class:`level-card__top`},Ee={class:`level-card__identity`},De={class:`level-card__text`},Oe={class:`level-card__name`},ke={class:`level-card__next`},Ae={class:`level-card__progress`},je=[`aria-valuenow`],Me={class:`level-card__points`},I={class:`section`},Ne={class:`section__head`},Pe={class:`product-row`},Fe=[`onClick`],Ie={key:0,class:`product-card__badge`},Le={class:`product-card__body`},Re={class:`product-card__name`},ze={class:`product-card__sub`},Be=[`aria-label`,`aria-pressed`,`onClick`],L=h(o({__name:`HomeView`,setup(o){let l=re(),{goBack:h}=ge(`/`),C=ae(),L=he(),R=se(),z=f(!0),B=f(null),V=f([]),H=f(null),U=f(null),Ve=[{id:`qa-club`,label:`باشگاه مشتریان`,to:`/profile`,icon:x},{id:`qa-cat`,label:`دسته بندی`,to:`/categories`,icon:S},{id:`qa-new`,label:`محصولات جدید`,to:`/products`,icon:de},{id:`qa-swatch`,label:`درخواست کالیته`,to:`/catalog-request`,icon:y}],He=[{id:`qa-customers`,label:`مشتریان من`,to:`/customers`,icon:x},{id:`qa-reminders`,label:`یادآورها`,to:`/reminders`,icon:b},{id:`qa-cat`,label:`دسته بندی`,to:`/categories`,icon:S},{id:`qa-swatch`,label:`درخواست کالیته`,to:`/catalog-request`,icon:y}],Ue=c(()=>C.isAgent?He:Ve),W={id:`fallback`,slot:`home_hero`,title:`کالکشن پاییز و زمستان`,subtitle:`جدیدترین پارچهها`,ctaLabel:`مشاهده کالکشن`,ctaLink:`/categories`,imageUrl:``},G=f([W]),K=f(0),q,J=c(()=>G.value[K.value]??W),We=c(()=>{let e=J.value.imageUrl;if(e)return{"--hero-image":`url("${e}")`}});function Y(){X(),!(G.value.length<2)&&(q=window.setInterval(()=>{K.value=(K.value+1)%G.value.length},5e3))}function X(){q&&window.clearInterval(q),q=void 0}function Ge(e){K.value=e,Y()}let Z=c(()=>C.user?.firstName||`کاربر`),Ke=c(()=>C.user?.lastName||``),Q=c(()=>{if(U.value)return U.value;let e=C.user;return{label:e?.levelLabel||`برنزی`,nextLabel:e?.nextLevelLabel||`نقرهای`,pointsRemaining:e?.pointsToNext??0,progressPercent:e?.levelProgress??0}});a(X),ee(async()=>{z.value=!0,B.value=null;try{let[e,t]=await Promise.all([L.loadBrowseProducts(),me(`home_hero`).catch(()=>[]),R.hydrate()]);if(t.length&&(G.value=t),Y(),V.value=e.filter(e=>e.isNew).slice(0,6),V.value.length||(V.value=e.slice(0,6)),C.isAgent)try{let e=await pe();U.value={label:e.levelLabel,nextLabel:e.nextLevelLabel,pointsRemaining:e.pointsToNext,progressPercent:e.levelProgress}}catch{}}catch(e){B.value=e instanceof Error?e.message:`بارگذاری خانه ناموفق بود.`}finally{z.value=!1}});function $(e){if(/^https?:\/\//i.test(e)){window.location.assign(e);return}l.push(e)}function qe(){$(J.value.ctaLink.trim()||`/categories`)}async function Je(e){H.value=null;try{await R.toggle(e)}catch(e){H.value=e instanceof Error?e.message:`ذخیره علاقهمندی ناموفق بود.`}}return(ee,a)=>(g(),s(`div`,w,[m(`header`,T,[m(`button`,{type:`button`,class:`icon-btn`,"aria-label":`بازگشت`,onClick:a[0]||=(...e)=>d(h)&&d(h)(...e)},[i(ue,{size:20})]),m(`div`,E,[i(le,{class:`home-header__avatar`,src:d(C).user?.avatarUrl,initials:Z.value.charAt(0),size:44},null,8,[`src`,`initials`]),m(`div`,null,[m(`p`,D,` سلام، `+_(Z.value)+` `+_(Ke.value),1),a[4]||=m(`p`,{class:`home-header__welcome`},`خوش آمدید`,-1)])]),m(`div`,O,[i(oe,{variant:`inline`}),m(`button`,{type:`button`,class:`icon-btn`,"aria-label":`اعلانها`,onClick:a[1]||=e=>$(`/profile/notifications`)},[i(b,{size:20})])])]),m(`div`,k,[B.value?(g(),s(`p`,A,_(B.value),1)):z.value?(g(),e(fe,{key:1,variant:`home`})):(g(),s(n,{key:2},[m(`section`,{class:`hero-banner`,"aria-label":J.value.title,style:t(We.value)},[m(`div`,M,[m(`h2`,N,[r(_(J.value.title)+` `,1),J.value.subtitle?(g(),s(`span`,P,_(J.value.subtitle),1)):p(``,!0)]),J.value.ctaLabel?(g(),s(`button`,{key:0,type:`button`,class:`hero-banner__cta`,onClick:qe},_(J.value.ctaLabel),1)):p(``,!0)]),G.value.length>1?(g(),s(`div`,F,[(g(!0),s(n,null,u(G.value,(e,t)=>(g(),s(`button`,{key:e.id,type:`button`,class:v([`dot`,{"dot--active":t===K.value}]),"aria-label":e.title,"aria-selected":t===K.value,onClick:e=>Ge(t)},null,10,ye))),128))])):p(``,!0)],12,j),m(`section`,be,[(g(!0),s(n,null,u(Ue.value,t=>(g(),s(`button`,{key:t.id,type:`button`,class:`quick-card`,onClick:e=>$(t.to)},[m(`span`,Se,[(g(),e(te(t.icon),{size:20}))]),m(`span`,Ce,_(t.label),1)],8,xe))),128))]),m(`section`,we,[m(`div`,Te,[m(`div`,Ee,[i(ve,{size:48}),m(`div`,De,[a[5]||=m(`span`,{class:`level-card__eyebrow`},`سطح شما`,-1),m(`strong`,Oe,_(Q.value.label),1),m(`span`,ke,`تا سطح `+_(Q.value.nextLabel),1)])]),m(`button`,{type:`button`,class:`level-card__details`,onClick:a[2]||=e=>$(`/profile`)},` جزئیات سطح `)]),m(`div`,Ae,[m(`div`,{class:`level-card__bar`,role:`progressbar`,"aria-valuenow":Q.value.progressPercent,"aria-valuemin":`0`,"aria-valuemax":`100`},[m(`span`,{class:`level-card__bar-fill`,style:t({width:`${Q.value.progressPercent}%`})},null,4)],8,je),m(`span`,Me,_(d(ie)(Q.value.pointsRemaining))+` امتیاز دیگر `,1)])]),m(`section`,I,[m(`div`,Ne,[a[7]||=m(`h3`,{class:`section__title`},`جدیدترین محصولات`,-1),m(`button`,{type:`button`,class:`section__link`,onClick:a[3]||=e=>$(`/products`)},[a[6]||=r(` مشاهده همه `,-1),i(ce,{size:14})])]),m(`div`,Pe,[(g(!0),s(n,null,u(V.value,(e,n)=>(g(),s(`article`,{key:e.id,class:`product-card`,onClick:t=>$(`/product?id=${e.id}`)},[m(`div`,{class:v([`product-card__image`,`product-card__image--${n%3}`]),style:t(e.imageUrl?{backgroundImage:`url(${e.imageUrl})`}:void 0)},[e.isNew?(g(),s(`span`,Ie,`جدید`)):p(``,!0)],6),m(`div`,Le,[m(`strong`,Re,_(e.name),1),m(`span`,ze,_(e.subtitle),1),m(`button`,{type:`button`,class:v([`product-card__fav`,{"product-card__fav--on":d(R).isFavorite(e.id)}]),"aria-label":d(R).isFavorite(e.id)?`حذف از علاقهمندیها`:`افزودن به علاقهمندیها`,"aria-pressed":d(R).isFavorite(e.id),onClick:ne(t=>Je(e.id),[`stop`])},[i(_e,{size:16,filled:d(R).isFavorite(e.id),color:d(R).isFavorite(e.id)?`#0a353c`:`#b0b7c0`},null,8,[`filled`,`color`])],10,Be)])],8,Fe))),128))])])],64))])]))}}),[[`__scopeId`,`data-v-d4c90ca0`]]);export{L as default}; |