2 lines
9.8 KiB
JavaScript
2 lines
9.8 KiB
JavaScript
import{j as m,p as ve,d as _e,G as pe,E as ge,u as y,x as M,w as P,f as i,g as a,b as t,e as d,n as R,I as r,c as o,t as n,F as Y,r as Z,i as _,y as fe,l,s as ye,_ as me}from"./index-DwiPBFwz.js";import{_ as be}from"./Spinner.vue_vue_type_style_index_0_lang-CUH4rvg2.js";import{_ as ke}from"./NotifyVant.vue_vue_type_script_setup_true_lang-DQxZKmXi.js";import{_ as he}from"./DialogVant.vue_vue_type_style_index_0_lang-BEUJbKFK.js";import{a as xe,u as Ce}from"./cartStore-1H7MkaXq.js";import{a as we}from"./client-WIBW0tF5.js";import{l as ze}from"./dialogEmpty1-E3h_JfwQ.js";function Pe(g){const f=m(!1),b=m(!1),$=m(!1),k=m(null);return{loading:f,flag:b,notFound:$,productRef:k,load:async()=>{f.value=!0;try{const I=(await we.listProducts()).find(S=>S.id===g)??null;k.value=I,$.value=!I,b.value=!0}catch(p){console.log(p)}finally{f.value=!1}}}}const Se=ve("favorites",{state:()=>({ids:[]}),actions:{toggle(g){const f=this.ids.indexOf(g);f===-1?this.ids.push(g):this.ids.splice(f,1)},isFavorite(g){return this.ids.includes(g)}}});function Ve(){return localStorage.getItem("appToken")}const qe={class:"pd"},Re={class:"pd__gallery"},$e={key:0,class:"pd__stage"},Fe=["src","alt"],Ie={key:0,class:"pd__counter"},Te={key:1,class:"pd__dots"},Oe=["aria-label","onClick"],Be={key:1,class:"pd__stage pd__stage--empty"},Le={class:"pd__sheet"},De={class:"pd__head"},Ne={class:"pd__headMain"},Ue={class:"pd__title"},je={class:"pd__sub"},Me={key:0,class:"pd__code"},Ae={key:1,class:"pd__dotSep"},Ee={key:2},Ge={class:"pd__figures"},We={class:"pd__figure"},Qe={class:"pd__figureValue"},He={key:0,class:"pd__figure"},Je={class:"pd__figureValue"},Ke={key:0,class:"pd__block"},Xe={class:"pd__variants no-scrollbar"},Ye=["onClick"],Ze={class:"pd__variantTitle"},et={class:"pd__variantWeight"},tt={class:"pd__block"},st={class:"pd__specs"},at={class:"pd__spec"},lt={key:0,class:"pd__spec"},ot={key:1,class:"pd__spec"},nt={key:2,class:"pd__spec"},it={key:3,class:"pd__spec"},ut={key:1,class:"pd__block"},dt={class:"pd__trust"},rt={class:"pd__bar"},ct={key:0,class:"pd__qty"},vt={class:"pd__qtyValue"},_t=["aria-label"],pt=["disabled"],gt=["src"],ft=_e({__name:"SingleProduct",props:{id:{}},emits:["closeDrawer"],setup(g,{emit:f}){const b=g,$=f,k=fe(),F=Se(),p=xe(),I=()=>{$("closeDrawer"),k.currentRoute.value.name==="singleProduct"&&k.back()},S=m(!1),T=m(!1),h=m(0),O=m(!1),c=Pe(b.id),ee=c.loading,te=c.flag,A={id:b.id,title:"",description:null,variants:[],images:[],category:null,brand:null,collections:[]},v=l(()=>Ce(c.productRef.value??A)),E=l(()=>v.value.id.value),G=l(()=>v.value.title.value),W=l(()=>v.value.productCode.value),L=l(()=>v.value.variants.value),V=l({get:()=>v.value.selectedVariant.value,set:s=>v.value.selectedVariant.value=s}),Q=l(()=>v.value.min_gram.value),D=l(()=>v.value.wage.value),N=l(()=>v.value.qty.value),H=l(()=>v.value.isPreOrder.value),U=l(()=>v.value.is_exist.value),j=l(()=>{var s;return((s=c.productRef.value)==null?void 0:s.description)??""}),se=l(()=>j.value.length>120),q=l(()=>{var s,e;return((e=(s=c.productRef.value)==null?void 0:s.category)==null?void 0:e.title)??""}),J=l(()=>{var s,e;return((e=(s=c.productRef.value)==null?void 0:s.brand)==null?void 0:e.title)??""}),ae=l(()=>{var s;return(((s=c.productRef.value)==null?void 0:s.images.length)??0)>0}),x=l(()=>{var s;return((s=c.productRef.value)==null?void 0:s.images.map(e=>e.url))??[]});pe(x,s=>{h.value>s.length-1&&(h.value=0)});const K=l(()=>{const s=D.value;return s==null?"":s%1===0?String(s):s.toFixed(2)}),le=l(()=>N.value>0?`${N.value} عدد موجود`:H.value?"پیشسفارش":"ناموجود"),oe=l(()=>N.value>0?"is-in":H.value?"is-pre":"is-out"),C=l(()=>{var s,e;return{vid:((s=V.value)==null?void 0:s.id)??"",note:null,pid:((e=c.productRef.value)==null?void 0:e.id)??b.id,product:c.productRef.value??A,qty:1}}),X=l(()=>p.isInCart(C.value)),B=l(()=>p.find_index(C.value)),w=l(()=>B.value>-1?p.items[B.value].qty:0),ne=()=>p.updateFeild(w.value+1,B.value,C.value,"qty"),ie=()=>{if(w.value<=1){p.remove(C.value);return}p.updateFeild(w.value-1,B.value,C.value,"qty")},ue=()=>{p.addToCart(C.value),S.val
|