2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
import{_ as ue}from"./DuPMz_WY.js";import{d1 as ie,d0 as ae,d2 as ce,d3 as de,cH as V,af as pe,a0 as G,aq as ve,cC as fe,r as m,l as k,d as F,H as j,o as X,z as w,G as K,E as h,B as r,D as d,A as U,a1 as L,a2 as Y,F as P,C as q,K as l,R as _e,a3 as Q,d4 as le,u as me,aB as Z,J as ge,a5 as ye,S as E,aj as he,a6 as xe,T as ee}from"./KS4UnPp1.js";import{l as te}from"./CerdNv64.js";import{_ as be}from"./eX8jIZ2S.js";import{g as we}from"./nGkaSJ5i.js";import{u as H}from"./DFZRasLX.js";import{u as oe,B as W}from"./BNlaDX0r.js";import{B as D}from"./BmFSBrvv.js";import{B as ne}from"./Bmkys-MA.js";import{M as Se,_ as Ce}from"./DJJLnL3I.js";import{_ as ke}from"./BgR2E6gQ.js";import{_ as $e,C as Be}from"./Ccq6ItqB.js";import{I as J}from"./CQa5JqAZ.js";import{C as qe,a as Re}from"./B-3C7SqN.js";import{g as Ue}from"./CExOuO1n.js";import{g as ze,a as Ke}from"./DQZX4uVc.js";import{_ as Pe}from"./B3t8nYPL.js";import{u as De}from"./BHo-I8CD.js";const T=new WeakMap;function Fe(y,c,a={}){const{mode:i="replace",route:s=ie(),router:e=ae(),transform:o}=a;let x=_=>_,p=_=>_;typeof o=="function"?x=o:o&&(o.get&&(x=o.get),o.set&&(p=o.set)),T.has(e)||T.set(e,new Map);const v=T.get(e);let t=s.query[y];ce(()=>{t=void 0});let f;const b=de((_,$)=>(f=$,{get(){return _(),x(t!==void 0?t:V(c))},set(S){S=p(S),t!==S&&(t=S===V(c)?void 0:S,v.set(y,S===V(c)?void 0:S),$(),pe(()=>{if(v.size===0)return;const z=Object.fromEntries(v.entries());v.clear();const{params:R,query:O,hash:n}=s;e[V(i)]({params:R,query:{...O,...z},hash:n})}))}}));return G(()=>s.query[y],_=>{t!==x(_)&&(t=_,f())},{flush:"sync"}),b}async function Oe(){return await ve.get("/site/collection/menu")}const re=fe("category",()=>{const y=m([]),c=k(()=>y.value.sort((e,o)=>e.position-o.position));async function a(){y.value=await Oe()}const i=e=>c.value.filter(o=>e.includes(o.parent_id)),s=k(()=>c.value.filter(e=>!e.parent_id));return{_category:y,category:c,getCategory:a,getCategorySubs:i,categoryWithoutSub:s}}),je={class:"overflow-y-auto px-2 mt3"},Ae={class:"pb-5"},Ie=F({__name:"SortProductSheet",props:{open:{type:Boolean,default:!1},value:{}},emits:["update:open","update:value","success"],setup(y,{emit:c}){const a=j(),i=y,s=c,e=k({get(){return i.value},set(t){s("update:value",t)}}),o=k({get(){return i.open},set(t){s("update:open",t)}});async function x(t){e.value=t,p(),s("success")}function p(){o.value=!1}const v=m([{title:a.useString("newest"),order:"-created_at"},{title:a.useString("popular"),order:"-count_fav"},{title:a.useString("bestSeller"),order:"-count_order"},{title:a.useString("mostVisited"),order:"-count_view"},{title:a.useString("cheapest"),order:"+price"},{title:a.useString("mostExpensive"),order:"-price"}]);return X(()=>{e.value=v.value[0]}),(t,f)=>{const b=Ce,_=Se;return w(),K(ne,{"close-on-click-overlay":"",show:o.value,"onUpdate:show":f[0]||(f[0]=$=>o.value=$),onClose:p},{default:h(()=>[r("div",je,[r("div",Ae,[d(_,{selectedKeys:[e.value?.order],class:"!border-none select-none"},{default:h(()=>[(w(!0),U(L,null,Y(v.value,($,S)=>(w(),K(b,{key:$.order,onClick:z=>x($)},{default:h(()=>[P(q($.title),1)]),_:2},1032,["onClick"]))),128))]),_:1},8,["selectedKeys"])])]),d(D,{block:"",danger:"",onClick:p},{default:h(()=>[P(q(l(a).useString("cancel")),1)]),_:1})]),_:1},8,["show"])}}}),Ve=F({__name:"CollapsePanel",setup(y){return(c,a)=>(w(),K(l($e),null,{default:h(()=>[_e(c.$slots,"default")]),_:3}))}}),Le=["alt"],Me={class:"max-h-60 mt-4 overflow-y-auto w-full px-2"},Ne={class:"flex flex-col gap-4 font-medium !text-gray-600"},Ee={class:"truncate w-10rem"},se=F({__name:"CollapsePanelFilter",props:{options:{default:()=>[]},value:{default:()=>[]}},emits:["update:value"],setup(y,{emit:c}){const a=y,i=j(),s=m(""),{prefixCls:e}=oe("collapse-filter"),o=c,x=k({set:v=>{o("update:value",v)},get:()=>a.value}),p=k(()=>s.value?a.options.filter(v=>v.label?.includes(s.value)):a.options);return(v,t)=>{const f=J;return w(),K(Ve,{class:Q([l(e)])},{default:h(()=>[d(f,{value:s.value,"onUpdate:value":t[0]||(t[0]=b=>s.value=b),bordered:!1,size:"large",placeholder:l(i).useString("search"),class:"input-search myCustomCollapseSearch"},{prefix:h(()=>[r("img",{src:ke,alt:l(i).appName.en,class:"w-4"},null,8,Le)]),_:1},8,["value","placeholder"]),r("div",Me,[d(l(qe),{value:x.value,"onUpdate:value":t[1]||(t[1]=b=>x.value=b)},{default:h(()=>[r("div",Ne,[(w(!0),U(L,null,Y(p.value,(b,_)=>(w(),K(l(Re),{key:_,value:b.value},{default:h(()=>[r("div",Ee,q(b.label),1)]),_:2},1032,["value"]))),128))])]),_:1},8,["value"])])]),_:1},8,["class"])}}}),Te={class:"p-4"},Ge={class:"bottom-divider"},Qe={class:"flex items-center justify-between"},He={class:"text-gray-600 text-lg"},We=F({__name:"Filters",props:{price:{default:()=>[]},selectedBrand:{default:()=>[]},selectedCollection:{default:()=>[]}},emits:["update:price","update:selectedBrand","update:selectedCollection","change"],setup(y,{emit:c}){re();const a=m([0]),i=m(0),s=m([0,0]),e=j(),o=m([]),x=m([]),p=y,{prefixCls:v}=oe("shop-filter"),t=c;G(()=>p.price,()=>{p.price.length>0?s.value=p.price:s.value=[1e4,i.value]});const f=k(()=>o.value.map(n=>({label:n.title,value:n.id}))),b=k(()=>x.value.map(n=>({label:n.title,value:n.id}))),_=k({set:n=>{t("update:selectedCollection",n),t("change")},get:()=>p.selectedCollection});function $(n){t("update:price",n),t("change")}const S=k({set:n=>{t("update:selectedBrand",n),t("change")},get:()=>p.selectedBrand});X(async()=>{o.value=await Ue(),x.value=await ze(),i.value=e.sellerConfig?.store.max_price_product??1e5,s.value=[1e3,i.value]});const z=ae(),R=m("");G(()=>z.currentRoute,()=>{z.currentRoute.value.query.search&&(R.value=z.currentRoute.value.query.search)},{immediate:!0});function O(){z.push({name:"shop",query:{search:R.value}})}return le(R,()=>{O()},{debounce:300}),(n,B)=>(w(),U("div",{class:Q([[l(v)],"overflow-y-auto pb-5 max-h-60vh"])},[d(l(Be),{activeKey:a.value,"onUpdate:activeKey":B[3]||(B[3]=C=>a.value=C),accordion:"",bordered:!1,"expand-icon-position":"end",class:"filter-collapse select-none"},{expandIcon:h(({isActive:C})=>[r("div",null,[d(W,{icon:"vuesax-linear:arrow-left-1",class:Q(["!text-gray-400 transition-all",[{"rotate--90":C}]]),size:"18"},null,8,["class"])])]),default:h(()=>[r("div",Te,[P(q(l(e).useString("price"))+" ",1),r("div",Ge,[d(l(Pe),{value:s.value,"onUpdate:value":B[0]||(B[0]=C=>s.value=C),max:i.value,min:1e4,step:1e4,range:"",reverse:"",onAfterChange:$},null,8,["value","max"]),r("div",Qe,[d(l(J),{value:l(H)(s.value[0],!0,""),class:"w-20",readonly:""},null,8,["value"]),r("span",He,q(l(e).priceUnit),1),d(l(J),{value:l(H)(s.value[1],!0,""),class:"w-20",readonly:""},null,8,["value"])])])]),d(se,{value:_.value,"onUpdate:value":B[1]||(B[1]=C=>_.value=C),header:l(e).useString("category"),options:b.value,class:"bottom-divider"},null,8,["value","header","options"]),d(se,{value:S.value,"onUpdate:value":B[2]||(B[2]=C=>S.value=C),header:l(e).useString("brand"),options:f.value},null,8,["value","header","options"])]),_:1},8,["activeKey"])],2))}}),Je={class:"overflow-y-auto"},Xe={class:"flex gap-3 bg-white pb-5"},Ye=F({__name:"FilterProductSheet",props:{open:{type:Boolean,default:!1},value:{}},emits:["update:open","update:value","success"],setup(y,{emit:c}){const a=j(),i=y,s=c,e=k({get(){return i.value},set(v){s("update:value",v)}}),o=k({get(){return i.open},set(v){s("update:open",v)}}),x=async()=>{e.value.brand=[],e.value.collection=[],e.value.price=[],await s("success")};function p(){o.value=!1}return m([{title:a.useString("newest"),order:"-created_at"},{title:a.useString("popular"),order:"-count_fav"},{title:a.useString("bestSeller"),order:"-count_order"},{title:a.useString("mostVisited"),order:"-count_view"},{title:a.useString("cheapest"),order:"+price"},{title:a.useString("mostExpensive"),order:"-price"}]),(v,t)=>(w(),K(ne,{"close-on-click-overlay":"",show:o.value,"onUpdate:show":t[4]||(t[4]=f=>o.value=f),onClose:p},{default:h(()=>[r("div",Je,[d(We,{price:e.value.price,"onUpdate:price":t[0]||(t[0]=f=>e.value.price=f),"selected-brand":e.value.brand,"onUpdate:selectedBrand":t[1]||(t[1]=f=>e.value.brand=f),"selected-collection":e.value.collection,"onUpdate:selectedCollection":t[2]||(t[2]=f=>e.value.collection=f)},null,8,["price","selected-brand","selected-collection"])]),r("div",Xe,[d(D,{class:"w-2/3 bg-primary",size:"large",type:"primary",onClick:t[3]||(t[3]=f=>s("success"))},{default:h(()=>[P(q(l(a).useString("filter")),1)]),_:1}),d(D,{class:"w-1/3",size:"large",onClick:x},{default:h(()=>[P(q(l(a).useString("reset")),1)]),_:1})]),d(D,{block:"",danger:"",onClick:p},{default:h(()=>[P(q(l(a).useString("cancel")),1)]),_:1})]),_:1},8,["show"]))}}),Ze={class:"flex justify-between items-center px4 pt-4"},et={class:"flex gap-2 lg:hidden"},tt={class:"flex gap-2 items-center"},st={class:"font-bold"},at={class:"text-xs text-gray-400"},lt={key:0,class:"w-full grid grid-cols-3 sm:grid-cols-5 mt-2 gap-2px"},ot=["onClick"],nt=["alt"],rt={key:1,class:"relative w-full h-full"},ut=["src"],it=["src"],Rt=F({__name:"ProductSearchList",props:{search:{},dataKey:{}},async setup(y){let c,a;const i=me(),s=j(),e=y,o=m([]),x=m(0),p=m(!1),v=e.dataKey?m(""):Fe("search",""),t=m({}),f=k(()=>s.sellerConfig?.store),b=m(),_=m({limit:30,page:0}),$=Z(_.value),S=m(!1),z=m([]),R=m(!1),O=re(),n=ge({brand:[],collection:[],price:[]});if(e.dataKey)X(()=>C());else{const{data:A}=([c,a]=ye(()=>De("productSearch",C)),c=await c,a(),c)}async function B(){S.value=!1,_.value=Z($),z.value=[],R.value=!1,await C()}async function C(){const A=e.dataKey?p:E;try{A.value=!0;const u=[];if((n.brand.length>0||i.currentRoute.value?.query?.brand?.length)&&u.push({field:"brand_id",op:"in",value:n.brand?.length?n.brand:[i.currentRoute.value?.query?.brand]}),n.collection.length>0||i.currentRoute.value?.query?.category?.length){const M=await Ke(i.currentRoute.value?.query?.category);u.push({field:"collection_id",op:"in",value:n.collection?.length?n.collection:M});const g=O.category.find(N=>N.id==n.collection[0])}n.price.length>0&&u.push({field:"price",op:"eq",value:n.price}),e.search?.length&&u.push({field:"title_fa",op:"like",value:e.search}),Object.assign(_.value,{filters:u,text_search:v.value,order:b.value?.order});const I=await we(f.value?.user_id,_.value);return o.value=I?.rows??[],x.value=I?.query?.total??0,o.value}catch(u){console.error(u)}finally{const u=e.dataKey?p:E;u.value=!1}}return le(()=>e.search,()=>{B()},{debounce:300}),(A,u)=>{const I=ue,M=he("lazy");return w(),U("div",null,[r("div",Ze,[d(I,null,{default:h(()=>[r("div",et,[d(D,{class:"flex gap-1 items-center text-xs",type:"text",size:"small",onClick:u[0]||(u[0]=g=>R.value=!0)},{default:h(()=>[r("span",null,q(l(s).useString("filterProducts")),1),d(W,{icon:"vuesax-linear:filter",size:"16"})]),_:1}),d(D,{class:"flex gap-1 items-center text-xs",type:"text",size:"small",onClick:u[1]||(u[1]=g=>S.value=!0)},{default:h(()=>[r("span",null,q(b.value?.title),1),d(W,{icon:"vuesax-linear:sort",size:"16"})]),_:1})])]),_:1}),r("div",tt,[r("span",st,q(l(H)(x.value??0,!0,"")),1),r("span",at,q(l(s).useString("countProducts")),1)])]),(A.dataKey?p.value:l(E))?(w(),K(be,{key:1})):(w(),U("div",lt,[(w(!0),U(L,null,Y(o.value,(g,N)=>(w(),U("div",{key:N,class:"w-full aspect-square relative",onClick:ct=>l(i).push({name:"product_detail-id",params:{id:g.id}})},[g.files?.length?(w(),U(L,{key:0},[g.files[0].type==="image"?xe((w(),U("img",{key:0,class:"w-full h-full object-cover",alt:l(s).appName.en},null,8,nt)),[[M,{src:l(s).useDataStorage(g.files[0].url),loading:l(te),error:l(te)}]]):g.files[0].type==="video"?(w(),U("div",rt,[r("video",{ref_for:!0,ref:"videoRefs",src:g.files[0].url,class:"hidden"},null,8,ut),r("img",{src:t.value[g.files[0].url],class:"w-full h-full object-cover",alt:"Video Thumbnail"},null,8,it),u[6]||(u[6]=r("div",{class:"absolute inset-0 flex items-center justify-center bg-black bg-opacity-30"},[r("svg",{class:"w-12 h-12 text-white",fill:"currentColor",viewBox:"0 0 24 24"},[r("path",{d:"M8 5v14l11-7z"})])],-1))])):ee("",!0)],64)):ee("",!0)],8,ot))),128))])),d(Ie,{open:S.value,"onUpdate:open":u[2]||(u[2]=g=>S.value=g),value:b.value,"onUpdate:value":u[3]||(u[3]=g=>b.value=g),onSuccess:B},null,8,["open","value"]),d(Ye,{open:R.value,"onUpdate:open":u[4]||(u[4]=g=>R.value=g),value:n,"onUpdate:value":u[5]||(u[5]=g=>n=g),onSuccess:B},null,8,["open","value"])])}}});export{Rt as _};
|