2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
import{d as q,u as ue,o as oe,a as de,b as s,c as a,e as i,F as T,r as L,n as B,f as D,g as x,h as $,i as w,_ as j,j as X,t as N,I as Z,k as _e,l as ve,w as pe,m as R,p as M,q as fe,s as K,v as Q,x as me,y as ge,K as J,z as he,A as ye,B as ke,C as ee,D as $e,E as be,G as Ce,H as Pe}from"./index-D8rImuYS.js";import{A as Ie}from"./AppPullRefresh-CRlsXY5y.js";import{R as Se}from"./RateStrip-D2_9D2Dh.js";import{P as we,a as xe}from"./ProductCard-wMhee5ps.js";import{u as Ee}from"./catalogStore-Cm5jo55F.js";import"./filters-DFCzE8sv.js";const Re={key:0,class:"hero"},Me=["onClick"],Te=["src"],Ae={key:1,class:"hero__artFallback","aria-hidden":"true"},He={key:0,class:"hero__dots"},Oe=["aria-label","onClick"],te=46,Be=.76,Le=36.6,De=.75,Ue=q({__name:"HeroCarousel",props:{slides:{},autoplay:{type:Boolean,default:!0}},setup(_){const h=_,p=$(0),P=$(null),v=$(!1),o=$(0);let u=0,f=null,y;const k=ue(),r=w(()=>h.slides.length);function m(e){let t=e-p.value;r.value>2&&(t>r.value/2&&(t-=r.value),t<-r.value/2&&(t+=r.value));const n=v.value?o.value:0,d=Math.abs(t),I=t*Le+n,F=t===0?1:Be,G=d>1?0:d===0?1:De;return{transform:`translate3d(${I}%, 0, 0) scale(${F})`,opacity:String(G),zIndex:String(10-d),pointerEvents:d>1?"none":"auto",transition:v.value?"none":"transform .42s cubic-bezier(.22,.61,.36,1), opacity .42s ease"}}function S(e){p.value=(e%r.value+r.value)%r.value,O()}function b(){S(p.value+1)}function E(){S(p.value-1)}function C(e){var t,n;r.value<2||(v.value=!0,u=e.clientX,o.value=0,f=e.pointerId,(n=(t=e.currentTarget).setPointerCapture)==null||n.call(t,e.pointerId),H())}function A(e){var n;if(!v.value||e.pointerId!==f)return;const t=((n=P.value)==null?void 0:n.clientWidth)||1;o.value=(e.clientX-u)/t*100}function U(e){if(!v.value)return;const t=e.clientX-u;v.value=!1,o.value=0,f=null,t>te?E():t<-te?b():O()}function z(e){Math.abs(o.value)>1||e!==p.value&&S(e)}function H(){y&&clearInterval(y),y=void 0}function O(){H(),h.autoplay&&!k.isReducedMotion&&r.value>1&&(y=setInterval(b,6e3))}return oe(O),de(H),(e,t)=>_.slides.length?(s(),a("section",Re,[i("div",{class:"hero__stage",ref_key:"stage",ref:P,onPointerdown:C,onPointermove:A,onPointerup:U,onPointercancel:U},[(s(!0),a(T,null,L(_.slides,(n,d)=>(s(),a("article",{key:n.key,class:D(["hero__card",{"is-active":d===p.value}]),style:B(m(d)),onClick:I=>z(d)},[n.image?(s(),a("img",{key:0,src:n.image,alt:"",class:"hero__art",draggable:"false"},null,8,Te)):(s(),a("div",Ae))],14,Me))),128))],544),_.slides.length>1?(s(),a("div",He,[(s(!0),a(T,null,L(_.slides,(n,d)=>(s(),a("button",{key:n.key,type:"button",class:D(["hero__dot",{"is-active":d===p.value}]),"aria-label":`اسلاید ${d+1}`,onClick:I=>S(d)},null,10,Oe))),128))])):x("",!0)])):x("",!0)}}),ze=j(Ue,[["__scopeId","data-v-ddde804b"]]),Ge={class:"cats no-scrollbar"},Ne=["onClick"],Fe={class:"cats__mark","aria-hidden":"true"},Ve=["src"],Xe={class:"cats__title"},qe=q({__name:"CategoryGrid",props:{categories:{},activeId:{}},emits:["select"],setup(_,{emit:h}){const p=h;return(P,v)=>(s(),a("div",Ge,[(s(!0),a(T,null,L(_.categories,o=>{var u;return s(),a("button",{key:o.id,type:"button",class:D(["cats__tile",{"is-active":o.id===_.activeId}]),onClick:f=>p("select",o)},[i("span",Fe,[(u=o.icon)!=null&&u.image?(s(),a("img",{key:0,src:o.icon.image,alt:""},null,8,Ve)):(s(),X(Z,{key:1,icon:"vuesax-linear:3d-cube-scan",size:"27"}))]),i("span",Xe,N(o.title),1)],10,Ne)}),128))]))}}),je=j(qe,[["__scopeId","data-v-155beefb"]]),We={class:"panel__art"},Ye=["alt"],Ke={class:"panel__title"},Qe={class:"panel__meta"},Ze={class:"panel__weight"},Je={key:0,class:"panel__wageOld"},et={class:"panel__wage"},tt=q({__name:"ProductPanel",props:{value:{},wageBefore:{}},emits:["open"],setup(_,{emit:h}){const p=_,P=h,{image:v,title:o,min_gram:u,wage:f}=_e(p.value);function y(k){return k%1===0?String(k):k.toFixed(2)}return(k,r)=>{const m=ve("lazy");return s(),a("article",{class:"panel","data-product-origin":"",onClick:r[0]||(r[0]=S=>P("open",_.value))},[i("div",We,[pe(i("img",{alt:R(o)},null,8,Ye),[[m,R(v)]]),M(we,{tags:_.value.tags,class:"panel__tags"},null,8,["tags"])]),i("h3",Ke,N(R(o)),1),i("div",Qe,[i("span",Ze,N(R(u))+" گرم",1),R(f)!=null?(s(),a(T,{key:0},[r[1]||(r[1]=i("span",{class:"panel__sep","aria-hidden":"true"},null,-1)),_.wageBefore!=null?(s(),a("span",Je,"اجرت "+N(y(_.wageBefore))+"٪",1)):x("",!0),i("span",et,N(y(R(f)))+"٪ اجرت",1)],64)):x("",!0)])])}}}),ie=j(tt,[["__scopeId","data-v-6cfb1820"]]),st={class:"reel"},at=["onClick"],nt={class:"reel__allMark","aria-hidden":"true"},se=46,lt=.78,ae=92.5,ot=.62,it=q({__name:"ProductCarousel",props:{products:{}},emits:["open","all"],setup(_,{emit:h}){const p=_,P=h,v=$(0),o=$(null),u=$(!1),f=$(0);let y=0,k=null;const r=w(()=>[...p.products.map(e=>({key:e.id,kind:"product",product:e})),{key:"__all__",kind:"all"}]),m=w(()=>r.value.length);function S(e){let t=e-v.value;m.value>2&&(t>m.value/2&&(t-=m.value),t<-m.value/2&&(t+=m.value));const n=u.value?f.value:0,d=t*ae+n,I=Math.min(Math.abs(t+n/ae),1),F=1-(1-lt)*I,G=1-(1-ot)*I,l=Math.abs(t)<=1,c=l?G:0;return{transform:`translate3d(${d}%, 0, 0) scale(${F})`,opacity:String(c),zIndex:String(10-Math.abs(t)),pointerEvents:l?"auto":"none",transition:u.value?"none":"transform .55s cubic-bezier(.21,1.02,.36,1), opacity .45s ease"}}function b(e){v.value=(e%m.value+m.value)%m.value}function E(){b(v.value+1)}function C(){b(v.value-1)}function A(e){var t,n;m.value<2||(u.value=!0,y=e.clientX,f.value=0,k=e.pointerId,(n=(t=e.currentTarget).setPointerCapture)==null||n.call(t,e.pointerId))}function U(e){var n;if(!u.value||e.pointerId!==k)return;const t=((n=o.value)==null?void 0:n.clientWidth)||1;f.value=(e.clientX-y)/t*100}function z(e){if(!u.value)return;const t=e.clientX-y;u.value=!1,f.value=0,k=null,t>se?C():t<-se&&E()}function H(e,t){if(!(Math.abs(f.value)>1)){if(e!==v.value){b(e);return}P("open",t)}}function O(e){if(!(Math.abs(f.value)>1)){if(e!==v.value){b(e);return}P("all")}}return(e,t)=>(s(),a("section",st,[i("div",{class:"reel__stage",ref_key:"stage",ref:o,onPointerdown:A,onPointermove:U,onPointerup:z,onPointercancel:z},[(s(!0),a(T,null,L(r.value,(n,d)=>(s(),a("div",{key:n.key,class:D(["reel__cell",{"is-active":d===v.value}]),style:B(S(d))},[n.kind==="product"?(s(),X(ie,{key:0,value:n.product,onOpen:I=>H(d,I)},null,8,["value","onOpen"])):(s(),a("button",{key:1,type:"button",class:"reel__all",onClick:I=>O(d)},[i("span",nt,[M(Z,{icon:"vuesax-linear:arrow-left-1",size:"26"})]),t[0]||(t[0]=i("span",{class:"reel__allText"},"مشاهده همه محصولات جدید",-1))],8,at))],6))),128))],544)]))}}),rt=j(it,[["__scopeId","data-v-1df7c763"]]),ct="/assets/shipping-and-delivery-CyUGL93q.png",ut="/assets/sports-and-competition-ao926_SX.png",re="/assets/brand-logo-Q_YZU76j.png",dt=[{type:"popup",src:ct,text:"ارسال سریع و مطمئن سفارشهای شما به سراسر کشور.",link:void 0},{type:"popup",src:ut,text:`جدیدترین محصولات ${K.name} را در بخش محصولات جدید ببینید.`,link:void 0},{type:"popup",src:re,text:`${K.name}، همراه شما در خرید و فروش طلا.`,link:void 0}],_t=fe("config",{state:()=>({config:{main_slider:dt},cats:[],loaded:!1}),actions:{setCats(_){this.cats=_},async init(_=!1){try{const{categories:h}=await Q.getCatalogFacets();this.cats=h.map(p=>({...p,icon:{image:re}})),this.loaded=!0}catch(h){console.log(h)}}}}),vt={class:"home"},pt={class:"home__bar"},ft={class:"home__barInner"},mt=["alt"],gt={key:0,class:"home__chips no-scrollbar"},ht=["onClick"],yt={class:"home__rail no-scrollbar"},kt={class:"home__list"},$t={key:4,class:"home__empty"},bt=70,ne=6,le=4,Ct=100,Pt=q({__name:"HomeView",setup(_){let h=!1;const p=$e(),P=_t(),v=me(),o=Ee(),u=ge(),f=$(!o.loaded),y=$(!1),k=w(()=>o.products),r=$(u.peek(J.goldPrice)??null),m=$(u.peek(J.homeSlider)??null),S=$(h);function b(l){return{"--reveal-delay":`${l*bt}ms`}}const E=$([]),C=$(null),A=w(()=>[...new Set(E.value.flatMap(l=>l.tags??[]))]),U=w(()=>C.value?E.value.filter(l=>{var c;return(c=l.tags)==null?void 0:c.includes(C.value)}):E.value),z=w(()=>k.value),H=w(()=>k.value.slice(0,ne)),O=w(()=>k.value.slice(0,le)),e=w(()=>(m.value??[]).filter(l=>l.image).map((l,c)=>({key:`${c}-${l.image}`,image:Pe(l.image,1200)})));function t(l){Ce(l)}function n(l){v.query.cats=[l.id],p.push({name:"search"})}function d(){p.push({name:"newestProduct"})}async function I(l=!1){const[c,W,g,V,Y]=await Promise.allSettled([(async()=>{l&&o.invalidate();const ce=await Q.listProductsPaged({page:1,limit:Math.max(ne,le),sort:"newest"});o.replace(ce.rows)})(),P.init(l),u.goldPrice({force:l}),u.homeSlider({force:l}),Q.listProductsPaged({page:1,limit:Ct,tagged:!0,sort:"newest"})]);Y.status==="fulfilled"?(E.value=Y.value.rows,C.value&&!A.value.includes(C.value)&&(C.value=null)):console.log(Y.reason),c.status==="rejected"&&console.log(c.reason),W.status==="rejected"&&console.log(W.reason),r.value=g.status==="fulfilled"?g.value:null,m.value=V.status==="fulfilled"?V.value:null}async function F(){try{await I(!0)}finally{y.value=!1}}oe(async()=>{await I(),f.value=!1,!S.value&&(await he(),requestAnimationFrame(()=>{S.value=!0,h=!0}))});let G=!1;return ye(async()=>{if(!G){G=!0;return}try{r.value=await u.goldPrice({force:!0})}catch(l){console.log(l)}}),(l,c)=>{const W=be("container");return s(),a("div",vt,[i("header",pt,[i("div",ft,[i("img",{src:ke,alt:R(K).name,class:"home__logo"},null,8,mt),M(Se,{quote:r.value,compact:"",class:"home__rate"},null,8,["quote"])])]),M(Ie,{modelValue:y.value,"onUpdate:modelValue":c[1]||(c[1]=g=>y.value=g),onRefresh:F},{default:ee(()=>[M(W,{class:D(["home__body",{"is-revealed":S.value}])},{default:ee(()=>[e.value.length?(s(),X(ze,{key:0,slides:e.value,class:"home__hero home__reveal",style:B(b(0))},null,8,["slides","style"])):x("",!0),R(P).cats.length?(s(),a("section",{key:1,class:"home__section home__reveal",style:B(b(1))},[c[2]||(c[2]=i("h2",{class:"home__heading"},"دسته بندی ها",-1)),M(je,{categories:R(P).cats,"active-id":null,onSelect:n},null,8,["categories"])],4)):x("",!0),E.value.length?(s(),a("section",{key:2,class:"home__section home__reveal",style:B(b(2))},[c[3]||(c[3]=i("h2",{class:"home__heading"},"ویژهها",-1)),A.value.length>1?(s(),a("div",gt,[i("button",{type:"button",class:D(["home__chip",{"is-on":C.value===null}]),onClick:c[0]||(c[0]=g=>C.value=null)}," همه ",2),(s(!0),a(T,null,L(A.value,g=>(s(),a("button",{key:g,type:"button",class:D(["home__chip",{"is-on":C.value===g}]),onClick:V=>C.value=g},N(g),11,ht))),128))])):x("",!0),i("div",yt,[(s(!0),a(T,null,L(U.value,g=>(s(),X(xe,{key:g.id,value:g,class:"home__railCard"},null,8,["value"]))),128))])],4)):x("",!0),z.value.length?(s(),a("section",{key:3,class:"home__section home__reveal",style:B(b(2))},[c[4]||(c[4]=i("h2",{class:"home__heading"},"محصولات جدید",-1)),M(rt,{products:H.value,onOpen:t,onAll:d},null,8,["products"]),i("div",kt,[(s(!0),a(T,null,L(O.value,(g,V)=>(s(),X(ie,{key:g.id,value:g,class:"home__reveal",style:B(b(3+V)),onOpen:t},null,8,["value","style"]))),128))])],4)):x("",!0),!f.value&&!k.value.length?(s(),a("section",$t,[M(Z,{icon:"vuesax-linear:box",size:"26"}),c[5]||(c[5]=i("p",null,"هنوز محصولی در مجموعه ثبت نشده است.",-1))])):x("",!0)]),_:1},8,["class"])]),_:1},8,["modelValue"])])}}}),Mt=j(Pt,[["__scopeId","data-v-396278ce"]]);export{Mt as default};
|