import{d as L,l as c,u as T,m as b,aB as N,h as O,_ as R,k as V,a as t,aA as U,y as q,C as k,ay as w,j as h,P as F,F as M,T as C}from"./vendor.cd162bf7.js";/* empty css               *//* empty css                *//* empty css                *//* empty css              *//* empty css               *//* empty css                */import{c as o,f as _}from"./cart.c528d3d4.js";import{s as n}from"./index.module.0e920025.js";import{A as G}from"./index.17e81428.js";import{r as I,l as D,q as H,o as v,C as $,s as P,p as g}from"./index.a9c80450.js";import{C as z}from"./index.affad28a.js";import{P as E}from"./index.3b7edb7c.js";import{C as J}from"./index.de3e7139.js";import{U as K}from"./index.f53294d4.js";import{U as Q}from"./index.04b62793.js";/* empty css                *//* empty css                */import"./icon_checkbox_default.2fe5d57e.js";import"./index.d3c070ae.js";/* empty css               *//* empty css               */import"./orderStatus.86d72629.js";import"./index.339fc024.js";import"./index.fd2af93d.js";/* empty css               *//* empty css               */import"./item.08c576cb.js";var Pe=L({name:"cartConfirm",setup(){const p=c(!0),A=T(),l=c();b(async()=>{if(p.value=!0,A.query.cartIds)try{let{code:e,data:a}=await I.post("/api-mall-portal/order/generateConfirmOrder",{params:{cartIds:A.query.cartIds}});e===200&&(o.calcAmount=a.calcAmount,o.cartPromotionItemList=a.cartPromotionItemList,o.memberReceiveAddressList=a.memberReceiveAddressList)}catch{}if(p.value=!1,o.memberReceiveAddressList.length){const e=o.memberReceiveAddressList.find(a=>a.defaultStatus)||o.memberReceiveAddressList[0];e&&(l.value=e)}});const x=e=>{l.value=e};b(()=>{D("getAddress",e=>{x((e==null?void 0:e.content)||{})})}),N(()=>{H("getAddress",()=>{})});const f=c(!1),d=c(!1),i=c(!1),u=O({orderNo:"",actualPrice:0,couponId:""});R(i,(e,a)=>{i.value?g({api:"setBarStatus",content:{status:0}}):g({api:"setBarStatus",content:{status:1}})});const y=()=>{var a;if(!((a=l.value)==null?void 0:a.id)){C("\u8BF7\u9009\u62E9\u6536\u8D27\u5730\u5740");return}if(!f.value){C("\u8BF7\u5148\u9605\u8BFB\u5E76\u540C\u610F\u300A\u9177\u4E50\u79C0\u5E73\u53F0\u670D\u52A1\u534F\u8BAE\u300B");return}const e=P.user.data;if(!(e==null?void 0:e.realName)||!(e==null?void 0:e.idCardNo)){i.value=!0;return}if(u.orderNo){d.value=!0;return}S()},j=V(),S=async()=>{var m;const a={cartIds:o.cartPromotionItemList.reduce((s,r)=>(s.push(r.id),s),[]),memberReceiveAddressId:(m=l.value)==null?void 0:m.id,platformType:P.platformType,orderAmount:(o.calcAmount.payAmount-o.calcAmount.promotionAmount).toFixed(2),couponId:u.couponId};try{let{code:s,data:r}=await I.post("/api-mall-portal/order/generateOrder",{data:a});if(s===200){if(r.order.status===1){j.replace({path:"/shopTrade",query:{orderNo:r==null?void 0:r.order.orderSn,id:r==null?void 0:r.order.id}});return}d.value=!0,u.orderNo=(r==null?void 0:r.order.orderSn)||"",u.actualPrice=(r==null?void 0:r.order.payAmount)||0}}catch{}},B=()=>{i.value=!1,y()};return()=>t(M,null,[p.value?null:t("div",null,[o.cartPromotionItemList.length?t("div",{class:n.cartConfirm},[t("div",{class:n.cartConfirmBox},[t(G,{item:l.value,setAddress:x},null)]),t("div",{style:{marginTop:"20px"},class:[n.cartBox,n.cartConfirmBox]},[t("div",{class:n.shopBox},[o.cartPromotionItemList.map(e=>t("div",{class:[n.cartItem],style:{marginBottom:"10px"}},[t(U,{price:v(e.price),desc:_(e.productAttr),title:e.productName,thumb:e.productPic,num:e.quantity},null)]))]),t(q,{border:!1},{default:()=>[t(Q,{orderType:"GOODS",orderAmount:o.calcAmount.totalAmount,onCouponSelect:e=>{const a=e.map(s=>s.discountPrice).reduce((s,r)=>s+r,0),m=e.map(s=>s.couponIssueId).join(",");o.calcAmount.promotionAmount=a,u.couponId=m}},null),t(k,{border:!1,title:"\u603B\u989D",value:"\xA5 "+v(o.calcAmount.totalAmount)},null)]})]),t("div",{class:n.payProtocol},[t(z,{modelValue:f.value,"onUpdate:modelValue":e=>f.value=e},null),t(w,{buttonText:`\u7ED3\u7B97(${o.cartPromotionItemList.length})`,buttonColor:"var(--van-primary)",disabled:o.cartPromotionItemList.length===0,onSubmit:()=>y()},{default:()=>[t("div",{class:n.confirmBottom},[h("\u5408\u8BA1")," ",t("span",{class:n["price-des"]},[h("\xA5"),v(o.calcAmount.payAmount-o.calcAmount.promotionAmount)])])]})]),t("div",{style:{height:"var(--van-submit-bar-height)"}},null),t(J,{modelValue:i.value,"onUpdate:modelValue":e=>i.value=e},{default:()=>[t(K,{onSuccess:B},null)]}),t(F,{show:d.value,closeOnClickOverlay:!1,position:"bottom",round:!0,closeOnPopstate:!0,safeAreaInsetBottom:!0,style:{minHeight:"30%"}},{default:()=>[t(E,{modelValue:d.value,"onUpdate:modelValue":e=>d.value=e,orderInfo:u,paymentType:"goodsPay",onBackOut:()=>d.value=!1},null)]})]):t($,{buttonText:"\u53BB\u8D2D\u7269\u8F66",onClick:()=>{j.push({path:"/cart"})}},null)])])}});export{Pe as default};
