Files
tehran_taj/apps/user-app/dist/assets/CartView-H0iYRYXh.js
T
2026-09-10 12:17:47 +03:30

2 lines
7.9 KiB
JavaScript

import{d as B,a as W,o as i,f as p,e as z,u as o,b as e,t as c,i as b,n as E,g as r,I as h,c as w,w as l,F as D,l as v,k as T,B as G,z as L,q as U,C as N,p as M,s as A,j as H,r as J}from"./index-ZjGZzoKB.js";import{l as K}from"./dialogEmpty1-E3h_JfwQ.js";import{_ as Q}from"./AppHeader.vue_vue_type_style_index_0_lang-C_jQO-H_.js";import{_ as X}from"./Spinner.vue_vue_type_style_index_0_lang-0BQFuTHt.js";import{_ as Y}from"./EmptyState.vue_vue_type_style_index_0_lang-DINchSBE.js";import{_ as j}from"./DialogVant.vue_vue_type_style_index_0_lang-C6e-tl37.js";import{a as O,u as Z}from"./cartStore-blSKCzji.js";import{B as C}from"./index-SbKM5uBm.js";import{a as tt}from"./client-WIBW0tF5.js";import{D as et}from"./index-DB0pzJXM.js";import{F as st,T as ot,a as at}from"./index-DN_annhc.js";import"./classCallCheck-DqWZIipa.js";import"./PortalWrapper-CrHC4WVo.js";import"./isEqual-ee78UXO0.js";import"./styleChecker-B_Bohueb.js";import"./FormItemContext-Dm4oYcf1.js";const nt="/assets/cartEmpty-Dhs1GzzF.svg",lt="/assets/dialogEmpty4-CVum_Uqr.svg",it={class:"border border-solid border-[#E5E7EB] bg-[#F9F9F9] block w-full rounded-[10px] p-[8px] flex"},rt={class:"w-[70px] h-[70px] m-auto"},dt={class:"flex-1"},ut={class:"font-bold mb-2"},mt={class:"flex justify-between text-center mb-4"},pt={class:"flex-col justify-start"},ct={class:"text-secondary text-[14px] font-bold"},ft={key:0,class:"mb-2 text-[11px]"},vt={key:2,class:"text-[14px] font-bold text-danger"},xt={class:"flex justify-between"},yt={class:"flex"},wt={class:"mx-[16px]"},gt=B({__name:"CartItem",props:{value:{}},emits:["note"],setup(f,{emit:k}){const n=f,_=k,d=O(),s=d.find_index(n.value),u=()=>{d.updateFeild(n.value.qty+1,s,n.value,"qty")},$=()=>{d.updateFeild(n.value.qty-1,s,n.value,"qty")},{image:F,title:x,selectedVariant:t,wage:y,hasDiscountWage:g}=Z(n.value.product,d.variant(n.value)),a=T(()=>!1);return(I,m)=>{var q,P,R;const V=W("lazy");return i(),p("div",it,[z(e("img",rt,null,512),[[V,o(F)]]),e("div",dt,[e("h6",ut,c(o(x)),1),e("div",mt,[e("div",pt,[m[2]||(m[2]=e("div",{class:"mb-2 text-[11px]"},"وزن حدودی",-1)),e("div",ct,c((q=o(t))==null?void 0:q.rashWeightGrams)+" گرم",1)]),e("div",null,[a.value?(i(),p("div",ft,"اجرت")):b("",!0),a.value?(i(),p("div",{key:1,class:E({"text-[14px] font-bold text-secondary":!0,"line-through decoration-inherit ml-4":o(g)})},c((P=o(y))==null?void 0:P.toFixed(2))+"% اجرت ",3)):b("",!0),a.value?(i(),p("div",vt,c((R=o(g))==null?void 0:R.toFixed(2))+"% اجرت",1)):b("",!0)])]),e("div",xt,[m[3]||(m[3]=e("div",{class:"mb-4"},"تعداد",-1)),e("div",yt,[r(h,{icon:"vuesax-linear:add-square",class:"cursor-pointer text-secondary",size:"20",onClick:u}),e("span",wt,c(f.value.qty),1),f.value.qty===1?(i(),w(h,{key:0,icon:"vuesax-linear:trash",onClick:m[0]||(m[0]=S=>o(d).remove(f.value)),class:"cursor-pointer text-danger",size:"20"})):(i(),w(h,{key:1,icon:"vuesax-linear:minus-square",onClick:$,class:"cursor-pointer text-secondary",size:"20"}))])]),r(o(C),{class:"w-full",type:"primary",onClick:m[1]||(m[1]=S=>_("note",o(s)))},{default:l(()=>[!f.value.note||f.value.note===""?(i(),p(D,{key:0},[v("ثبت توضیحات")],64)):(i(),p(D,{key:1},[v("ویرایش توضیحات")],64))]),_:1})])])}}}),bt={class:"fixed top-0 z-10 w-full"},kt={class:"flex justify-center items-center"},_t={class:"flex mb-0 items-center h-[19px]"},ht={class:"h-full flex justify-center items-center flex-col"},Ct={class:"mb-2 text-secondary"},$t={class:"mb-2 font-semibold"},Ft=["src"],zt=["src"],Dt={key:1,class:"shadowset flex flex-row-reverse p-[16px] pb-[75px] justify-between fixed bottom-0 w-full bg-white z-[2] items-center border-t border-solid border-primary/10 shadow-md"},It={class:"text-[16px]"},qt={class:"font-bold"},Ht=B({__name:"CartView",setup(f){const k=A(),n=O(),_=G(),d=H(!1),s=U({loadingPage:!1,showPopUp:!1,step:1,notify:!1,orderID:"",tempRowIndex:-1,tempRow:{product:void 0}}),u=U({note:void 0}),$=()=>{n.updateFeild(u.note,s.tempRowIndex,s.tempRow,"note"),s.showPopUp=!1,u.note=void 0,s.tempRow={product:void 0}},F=async()=>{if(s.notify=!1,!_.customerId){d.value=!0;return}try{s.loadingPage=!0;const x=await tt.createOrder({customerId:_.customerId,items:n.items.map(t=>{const y=n.variant(t);return{productVariantId:t.vid,quantity:t.qty,wagePercent:y?parseFloat(y.defaultWagePercent):0}})});s.orderID=x.orderNumber,s.step=2,n.clear()}catch(x){console.log(x)}finally{s.loadingPage=!1}};return L(async()=>{await n.init()}),(x,t)=>{const y=J("container");return i(),w(X,{spinning:s.loadingPage,tip:"درحال دریافت اطلاعات"},{default:l(()=>{var g;return[e("div",bt,[r(Q,null,{default:l(()=>[e("nav",kt,[e("div",_t,[r(h,{icon:"vuesax-linear:bag-happy",class:"ml-2 text-white",size:"19"}),t[9]||(t[9]=e("h4",{class:"bold mb-0 text-white"},"سبد خرید",-1))]),t[10]||(t[10]=e("span",null,null,-1))])]),_:1})]),t[20]||(t[20]=e("div",{class:"h-16"},null,-1)),r(y,{class:"overflow-y-scroll pt-4"},{default:l(()=>[z(e("div",null,[o(n).items.length===0?(i(),w(Y,{key:0,image:o(nt)},null,8,["image"])):(i(!0),p(D,{key:1},M(o(n).items,a=>(i(),w(gt,{value:a,key:a.pid+a.vid,class:"mb-4",onNote:I=>{s.tempRow=a,s.showPopUp=!0,s.tempRowIndex=I,u.note=a.note??void 0}},null,8,["value","onNote"]))),128))],512),[[N,s.step===1]]),z(e("div",ht,[t[12]||(t[12]=e("h4",{class:"text-primary"},"اطلاعات سفارش با موفقیت ثبت شد",-1)),e("div",Ct,"شماره سفارش "+c(s.orderID),1),t[13]||(t[13]=e("small",{class:"mb-2 text-secondary"},"برای بررسی وضعیت سفارش خود روی لیست سفارشات کلیک کنید",-1)),r(o(C),{type:"primary",onClick:t[0]||(t[0]=async()=>{await o(k).push({name:"home"}),s.step=1})},{default:l(()=>[...t[11]||(t[11]=[v(" لیست سفارشات ",-1)])]),_:1})],512),[[N,s.step===2]])]),_:1}),(g=s.tempRow)!=null&&g.product?(i(),w(o(et),{key:0,visible:s.showPopUp,"onUpdate:visible":t[2]||(t[2]=a=>s.showPopUp=a),placement:"bottom",closable:!1,height:"280px",class:E(["henza-rounded-drawer rtl","bg-white","text-primary"])},{default:l(()=>[e("div",$t,"توضیح برای محصول "+c(s.tempRow.product.title),1),r(o(at),{model:u,name:"noteForm",layout:"vertical",autocomplete:"off",onFinish:$,class:"henza-form bg-primaryLighten"},{default:l(()=>[r(o(st),{"has-feedback":"",name:"note"},{default:l(()=>[r(o(ot),{value:u.note,"onUpdate:value":t[1]||(t[1]=a=>u.note=a),rows:5},null,8,["value"])]),_:1}),r(o(C),{class:"btn-px-double w-full",type:"primary",size:"large","html-type":"submit"},{default:l(()=>[...t[14]||(t[14]=[v("ثبت",-1)])]),_:1})]),_:1},8,["model"])]),_:1},8,["visible"])):b("",!0),r(j,{timeOut:-1,show:s.notify,"onUpdate:show":t[4]||(t[4]=a=>s.notify=a),closeOnClickOverlay:!0},{img:l(()=>[e("img",{src:o(lt),alt:"",class:"opacity-70"},null,8,Ft)]),title:l(()=>[...t[15]||(t[15]=[v("آیا مطمئن به ثبت سفارش هستید ؟",-1)])]),button:l(()=>[e("div",{class:"text-center text-[#1C2D56]",onClick:F},"بله"),e("div",{class:"text-center text-[#6b7280]",onClick:t[3]||(t[3]=a=>s.notify=!1)},"بی خیال")]),_:1},8,["show"]),r(j,{timeOut:-1,show:d.value,"onUpdate:show":t[7]||(t[7]=a=>d.value=a),closeOnClickOverlay:!0},{img:l(()=>[e("img",{src:o(K),alt:"",class:"opacity-80"},null,8,zt)]),title:l(()=>[...t[16]||(t[16]=[e("div",{class:"p-8 text-justify"},"برای ثبت سفارش ابتدا باید وارد حساب کاربری خود شوید.",-1)])]),button:l(()=>[e("div",{class:"text-center text-[#1C2D56]",onClick:t[5]||(t[5]=a=>o(k).push({name:"login"}))},"ورود/ثبت نام"),e("div",{class:"text-center text-danger",onClick:t[6]||(t[6]=a=>d.value=!1)},"بیخیال")]),_:1},8,["show"]),t[21]||(t[21]=e("div",{class:"h-36"},null,-1)),o(n).items.length>0&&s.step===1?(i(),p("div",Dt,[e("div",It,[t[17]||(t[17]=v(" جمع وزن : ",-1)),e("span",qt,c(o(n).total()),1),t[18]||(t[18]=e("span",{class:"pr-1"},"گرم",-1))]),r(o(C),{class:"w-1/2",type:"primary",onClick:t[8]||(t[8]=a=>s.notify=!0)},{default:l(()=>[...t[19]||(t[19]=[v("ثبت نهایی سفارش",-1)])]),_:1})])):b("",!0)]}),_:1},8,["spinning"])}}});export{Ht as default};