Files
tehran_tala/apps/user-app-v2/dist/assets/CartView-DVTYESIQ.js
T

2 lines
7.4 KiB
JavaScript
Raw Normal View History

import{d as S,M as U,k as M,l as O,f as i,c as r,b as e,m as a,w as A,p as n,I as f,t as v,e as I,N as B,h as z,_ as L,O as Q,o as W,x as j,z as u,J as G,j as R,P as D,C as H,g as V,K as N,i as J,F as K,r as X,B as Y,n as Z,s as tt}from"./index-CMIHv7G_.js";import{P as et}from"./PageBar-CUbj3C6I.js";import{D as st}from"./index-B4nv0el2.js";import{L as F,P as at}from"./index-CV0Ebvxy.js";import{F as ot,T as nt,a as it}from"./index-BRD2PJwl.js";import"./KeyCode-DsBZ8tem.js";import"./classCallCheck-Cz-BRu3c.js";import"./raf-nDFcuFT6.js";import"./FormItemContext-CZ4fTBj4.js";const lt={class:"ci"},rt={class:"ci__art"},ct=["alt"],dt={key:1,class:"ci__artEmpty","aria-hidden":"true"},ut={class:"ci__main"},_t={class:"ci__title"},mt={class:"ci__meta"},pt={class:"ci__weight"},vt={key:0,class:"ci__wage"},yt={class:"ci__row"},ft={class:"ci__qty"},bt=["disabled"],gt={class:"ci__qtyValue"},wt={key:0,class:"ci__noteText"},ht=S({__name:"CartItem",props:{value:{}},emits:["note"],setup(_,{emit:x}){const l=_,c=x,m=U(),y=m.find_index(l.value),b=z(()=>m.maxQty(l.value)),g=z(()=>b.value===null||l.value.qty<b.value),$=()=>{g.value&&m.updateFeild(l.value.qty+1,y,l.value,"qty")},s=()=>{m.updateFeild(l.value.qty-1,y,l.value,"qty")},{image:p,title:k,selectedVariant:P,wage:C}=M(l.value.product,m.variant(l.value)),q=z(()=>{const d=C.value;return d==null?"":d%1===0?String(d):d.toFixed(2)});return(d,t)=>{var h;const w=O("lazy");return i(),r("article",lt,[e("div",rt,[a(p)?A((i(),r("img",{key:0,alt:a(k)},null,8,ct)),[[w,a(p)]]):(i(),r("div",dt,[n(f,{icon:"vuesax-linear:diamonds",size:"20"})]))]),e("div",ut,[e("h3",_t,v(a(k)),1),e("div",mt,[e("span",pt,v((h=a(P))==null?void 0:h.rashWeightGrams)+" گرم",1),a(C)!=null?(i(),r("span",vt,"اجرت "+v(q.value)+"٪",1)):I("",!0)]),e("div",yt,[e("div",ft,[e("button",{type:"button",class:"ci__qtyBtn","aria-label":"افزودن",disabled:!g.value,onClick:$},[n(f,{icon:"vuesax-linear:add",size:"16"})],8,bt),e("span",gt,v(_.value.qty),1),_.value.qty===1?(i(),r("button",{key:0,type:"button",class:"ci__qtyBtn ci__qtyBtn--danger","aria-label":"حذف",onClick:t[0]||(t[0]=o=>a(m).remove(_.value))},[n(f,{icon:"vuesax-linear:trash",size:"16"})])):(i(),r("button",{key:1,type:"button",class:"ci__qtyBtn","aria-label":"کاهش",onClick:s},[n(f,{icon:"vuesax-linear:minus",size:"16"})]))]),e("button",{type:"button",class:"ci__note",onClick:t[1]||(t[1]=o=>c("note",a(y)))},[n(f,{icon:"vuesax-linear:note-text",size:"15"}),B(" "+v(!_.value.note||_.value.note===""?"توضیحات":"ویرایش توضیحات"),1)])]),_.value.note?(i(),r("p",wt,v(_.value.note),1)):I("",!0)])])}}}),xt=L(ht,[["__scopeId","data-v-d4b1ffdf"]]),kt={class:"cart"},Ct={key:1,class:"cart__empty"},It={key:1,class:"cart__done"},$t={class:"cart__doneIcon","aria-hidden":"true"},Pt={class:"cart__doneSub"},qt={key:0,class:"cart__bar"},zt={class:"cart__barInner"},Rt={class:"cart__total"},Vt={class:"cart__totalValue"},Ft={class:"sheet"},Bt={class:"sheet__title"},Dt=60,Nt=S({__name:"CartView",setup(_){let x=!1;const l=H(),c=U(),m=Q(),y=V(!1),b=V(!1),g=V(x);function $(d){return{"--reveal-delay":`${d*Dt}ms`}}const s=N({loadingPage:!1,showPopUp:!1,step:1,notify:!1,orderID:"",tempRowIndex:-1,tempRow:{product:void 0}}),p=N({note:void 0}),k=()=>{c.updateFeild(p.note,s.tempRowIndex,s.tempRow,"note"),s.showPopUp=!1,p.note=void 0,s.tempRow={product:void 0}},P=async()=>{await l.push({name:"ordersList"}),s.step=1},C=async()=>{if(s.notify=!1,!m.isLoggedIn){y.value=!0;return}try{s.loadingPage=!0;const d=await tt.createOrder({customerId:m.customerId??void 0,items:c.items.map(t=>{const w=c.variant(t);return{productVariantId:t.vid,quantity:t.qty,wagePercent:w?parseFloat(w.defaultWagePercent):0}})});s.orderID=d.orderNumber,s.step=2,c.clear()}catch(d){console.log(d)}finally{s.loadingPage=!1}};async function q(){await c.init(),b.value=!1}return W(async()=>{await c.init(),!g.value&&(await j(),requestAnimationFrame(()=>{g.value=!0,x=!0}))}),(d,t)=>{var h;const w=Y("container");return i(),r("div",kt,[n(et,{title:"سبد خرید","back-to":"home"}),n(G,{spinning:s.loadingPage,tip:"د�