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