Files
nademitex_user/dist/assets/HomeView-CUsQ-310.js
T
2026-09-19 16:59:15 +03:30

1 line
10 KiB
JavaScript

import{D as e,E as t,Et as n,G as r,J as i,K as a,Kt as o,M as s,N as c,O as l,P as ee,T as u,Xt as d,Yt as f,Z as p,b as m,et as te,g as ne,st as re,t as h,vt as g,w as _}from"./_plugin-vue_export-helper-Bo3WtfwJ.js";import{r as ie,u as ae}from"./BasicIcon-BXxbbWA_.js";import{n as v}from"./http-CYAxBUmC.js";import{o as oe}from"./format-C72AoJ2H.js";import{c as se,i as ce,l as le,o as ue,r as de,s as fe}from"./index-COC09WBR.js";import{t as pe}from"./IconChevronBack-DfGoZJJk.js";import{t as me}from"./PageSkeleton-DHtB6RUa.js";import{n as he,r as ge,t as _e}from"./crm-Cbr1tRzB.js";import{t as ve}from"./useGoBack-TJZZv7or.js";import{t as y}from"./quick-catalog-request-Di7-t6Ua.js";import{t as ye}from"./IconHeart-CdSTZ2ec.js";async function be(){return v(`/suggestions/me`)}var xe=`/assets/level-medal-Avpe4Lqa.webp`,b=`/assets/quick-categories-grid-BcZY1Wu0.webp`,x=`/assets/quick-new-products-DBGxsuVa.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=h(ee({__name:`HomeView`,setup(ee){let h=ne(),{goBack:v}=ve(`/`),M=se(),ct=_e(),N=le(),P=g(!0),F=g(null),I=g([]),L=g([]),R=g(null),z=g(null),lt=[{id:`qa-new`,label:`محصولات جدید`,to:`/products`,image:x},{id:`qa-cat`,label:`دسته بندی`,to:`/categories`,image:b},{id:`qa-club`,label:`آخرین وضعیت سفارش`,to:`/orders/latest-status`,image:`/`},{id:`qa-swatch`,label:`آخرین درخواست کالیته`,to:`/catalog-requests/latest-status`,image:y}],ut=[{id:`qa-new`,label:`محصولات جدید`,to:`/products`,image:x},{id:`qa-cat`,label:`دسته بندی`,to:`/categories`,image:b},{id:`qa-customers`,label:`آخرین وضعیت سفارش`,to:`/orders/latest-status`,image:`/`},{id:`qa-swatch`,label:`آخرین درخواست کالیته`,to:`/catalog-requests/latest-status`,image:y}],dt=_(()=>M.isAgent?ut:lt),B={id:`fallback`,slot:`home_hero`,title:`کالکشن پاییز و زمستان`,subtitle:`جدیدترین پارچه‌ها`,ctaLabel:`مشاهده کالکشن`,ctaLink:`/categories`,imageUrl:``,showTitle:!0,showSubtitle:!0,showCta:!0},V=g([B]),H=g(0),U=g(`hero-next`),W,G=_(()=>V.value[H.value]??B),K=_(()=>{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=_(()=>M.user?.firstName||`کاربر`),Z=_(()=>M.user?.lastName||``),Q=_(()=>{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}});a(Y),r(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}h.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(r,a)=>(i(),l(`div`,Se,[u(`header`,S,[u(`button`,{type:`button`,class:`icon-btn`,"aria-label":`بازگشت`,onClick:a[0]||=(...e)=>n(v)&&n(v)(...e)},[c(pe,{size:20})]),u(`div`,C,[c(de,{class:`home-header__avatar`,src:n(M).user?.avatarUrl,initials:X.value.charAt(0),size:44},null,8,[`src`,`initials`]),u(`div`,null,[u(`p`,w,` سلام، `+d(X.value)+` `+d(Z.value),1),a[4]||=u(`p`,{class:`home-header__welcome`},`خوش آمدید`,-1)])]),u(`div`,T,[c(ce,{variant:`inline`}),u(`button`,{type:`button`,class:`icon-btn`,"aria-label":`اعلان‌ها`,onClick:a[1]||=e=>$(`/profile/notifications`)},[c(fe,{size:20})])])]),u(`header`,E,[u(`div`,null,[a[5]||=u(`h1`,{class:`home-desk-head__title`},`خانه`,-1),u(`p`,D,` سلام `+d(X.value)+` `+d(Z.value)+` — خوش آمدید `,1)])]),u(`div`,O,[F.value?(i(),l(`p`,k,d(F.value),1)):P.value?(i(),t(me,{key:1,variant:`home`})):(i(),l(m,{key:2},[u(`section`,{class:`hero-banner`,"aria-label":G.value.title},[c(ie,{name:U.value,tag:`div`,class:`hero-banner__stage`},{default:re(()=>[(i(),l(`article`,{key:G.value.id,class:o([`hero-slide`,{"hero-slide--copy":K.value}]),style:f(ft(G.value))},[a[6]||=u(`div`,{class:`hero-slide__media`,"aria-hidden":`true`},null,-1),u(`div`,j,[G.value.showTitle===!1?G.value.showSubtitle!==!1&&G.value.subtitle?(i(),l(`p`,Te,[u(`span`,null,d(G.value.subtitle),1)])):e(``,!0):(i(),l(`h2`,Ce,[s(d(G.value.title)+` `,1),G.value.showSubtitle!==!1&&G.value.subtitle?(i(),l(`span`,we,d(G.value.subtitle),1)):e(``,!0)])),G.value.showCta!==!1&&G.value.ctaLabel?(i(),l(`button`,{key:2,type:`button`,class:`hero-banner__cta`,onClick:mt},d(G.value.ctaLabel),1)):e(``,!0)])],6))]),_:1},8,[`name`]),V.value.length>1?(i(),l(`div`,Ee,[(i(!0),l(m,null,p(V.value,(e,t)=>(i(),l(`button`,{key:e.id,type:`button`,class:o([`dot`,{"dot--active":t===H.value}]),"aria-label":e.title,"aria-selected":t===H.value,onClick:e=>pt(t)},null,10,De))),128))])):e(``,!0)],8,A),u(`section`,Oe,[(i(!0),l(m,null,p(dt.value,e=>(i(),l(`button`,{key:e.id,type:`button`,class:`quick-card`,onClick:t=>$(e.to)},[u(`span`,Ae,[e.image?(i(),l(`img`,{key:0,class:`quick-card__image`,src:e.image,alt:``},null,8,je)):(i(),t(te(e.icon),{key:1,size:20}))]),u(`span`,Me,d(e.label),1)],8,ke))),128))]),n(M).isAgent?(i(),l(`section`,Ne,[u(`div`,Pe,[u(`div`,Fe,[u(`img`,{class:`level-card__medal`,src:n(xe),alt:``,width:`48`,height:`48`,"aria-hidden":`true`},null,8,Ie),u(`div`,Le,[a[7]||=u(`span`,{class:`level-card__eyebrow`},`سطح شما`,-1),u(`strong`,Re,d(Q.value.label),1),u(`span`,ze,`تا سطح `+d(Q.value.nextLabel),1)])]),u(`button`,{type:`button`,class:`level-card__details`,onClick:a[2]||=e=>$(`/profile`)},` جزئیات سطح `)]),u(`div`,Be,[u(`div`,{class:`level-card__bar`,role:`progressbar`,"aria-valuenow":Q.value.progressPercent,"aria-valuemin":`0`,"aria-valuemax":`100`},[u(`span`,{class:`level-card__bar-fill`,style:f({width:`${Q.value.progressPercent}%`})},null,4)],8,Ve),u(`span`,He,d(n(oe)(Q.value.pointsRemaining))+` امتیاز دیگر `,1)])])):(i(),l(`section`,Ue,[u(`div`,We,[a[8]||=u(`h3`,{class:`suggest-card__title`},`پیشنهاد اختصاصی ما برای شما`,-1),L.value.length?e(``,!0):(i(),l(`p`,Ge,` هنوز پیشنهاد اختصاصی برای شما ثبت نشده است. `))]),L.value.length?(i(),l(`div`,Ke,[(i(!0),l(m,null,p(L.value,(t,n)=>(i(),l(`article`,{key:t.id,class:`suggest-card__item`,onClick:e=>$(`/product?id=${t.productId}`)},[u(`div`,{class:o([`suggest-card__image`,`suggest-card__image--${n%3}`]),style:f(t.imageUrl?{backgroundImage:`url(${t.imageUrl})`}:void 0)},[t.isNew?(i(),l(`span`,Je,`جدید`)):e(``,!0)],6),u(`div`,Ye,[u(`strong`,Xe,d(t.productName),1),u(`span`,Ze,d(t.subtitle||t.catalogName||t.productCode),1),t.note?(i(),l(`p`,Qe,d(t.note),1)):e(``,!0)])],8,qe))),128))])):e(``,!0)])),u(`section`,$e,[u(`div`,et,[a[10]||=u(`h3`,{class:`section__title`},`جدیدترین محصولات`,-1),u(`button`,{type:`button`,class:`section__link`,onClick:a[3]||=e=>$(`/products`)},[a[9]||=s(` مشاهده همه `,-1),c(ue,{size:14})])]),u(`div`,tt,[(i(!0),l(m,null,p(I.value,(t,r)=>(i(),l(`article`,{key:t.id,class:`product-card`,onClick:e=>$(`/product?id=${t.id}`)},[u(`div`,{class:o([`product-card__image`,`product-card__image--${r%3}`]),style:f(t.imageUrl?{backgroundImage:`url(${t.imageUrl})`}:void 0)},[t.isNew?(i(),l(`span`,rt,`جدید`)):e(``,!0)],6),u(`div`,it,[u(`strong`,at,d(t.name),1),u(`span`,ot,d(t.subtitle),1),u(`button`,{type:`button`,class:o([`product-card__fav`,{"product-card__fav--on":n(N).isFavorite(t.id)}]),"aria-label":n(N).isFavorite(t.id)?`حذف از علاقه‌مندی‌ها`:`افزودن به علاقه‌مندی‌ها`,"aria-pressed":n(N).isFavorite(t.id),onClick:ae(e=>ht(t.id),[`stop`])},[c(ye,{size:16,filled:n(N).isFavorite(t.id),color:n(N).isFavorite(t.id)?`#0a353c`:`#b0b7c0`},null,8,[`filled`,`color`])],10,st)])],8,nt))),128))])])],64))])]))}}),[[`__scopeId`,`data-v-271a708d`]]);export{M as default};