import{d as O,O as d,L as T,P as I,e as P,a$ as R,bz as V,bw as U,N as w,Z as q,M,i as e,bu as A,w as g,aQ as F,C as k,F as G,aE as L,s as S,p as x}from"./index.afa1b71c.js";import"./index.637c8eb4.js";import"./index.30fb9a6a.js";import{C as $}from"./index.4d5e3e51.js";import{C as j}from"./index.8fb41b14.js";import{C as z}from"./index.acab22df.js";import{S as D}from"./index.a1ee611c.js";import{c as o,f as E}from"./cart.e4f6de23.js";import{s}from"./index.module.0e920025.js";import{A as H}from"./index.ff117807.js";import{C as Q}from"./index.ac9161f1.js";import{P as Z}from"./index.e5ffb8f7.js";import{C as J}from"./index.fcfcccb4.js";import{U as K}from"./index.da06133b.js";import{U as W}from"./index.966761e5.js";import"./index.42378eb4.js";import"./index.4b8ed396.js";import"./icon_checkbox_default.2fe5d57e.js";import"./index.ceb58f38.js";import"./index.61a5e45f.js";import"./use-height.f6c2abd5.js";import"./index.cb45b534.js";import"./hooks.ea9ec317.js";import"./index.570461cd.js";import"./index.deee835e.js";import"./index.72f11453.js";import"./index.dd9b166a.js";import"./use-id.237d90a3.js";import"./index.f80d8e15.js";import"./item.32a673da.js";var Bt=O({name:"cartConfirm",setup(){const p=d(!0),y=T(),c=d();I(async()=>{if(p.value=!0,y.query.cartIds)try{let{code:t,data:a}=await P.post("/api-mall-portal/order/generateConfirmOrder",{params:{cartIds:y.query.cartIds}});t===200&&(o.calcAmount=a.calcAmount,o.cartPromotionItemList=a.cartPromotionItemList,o.memberReceiveAddressList=a.memberReceiveAddressList)}catch{}if(p.value=!1,o.memberReceiveAddressList.length){const t=o.memberReceiveAddressList.find(a=>a.defaultStatus)||o.memberReceiveAddressList[0];t&&(c.value=t)}});const C=t=>{c.value=t};I(()=>{R("getAddress",t=>{C((t==null?void 0:t.content)||{})})}),V(()=>{U("getAddress",()=>{})});const f=d(!1),m=d(!1),l=d(!1),i=w({orderNo:"",actualPrice:0,couponId:""});q(l,(t,a)=>{l.value?x({api:"setBarStatus",content:{status:0}}):x({api:"setBarStatus",content:{status:1}})});const b=()=>{var a;if(!((a=c.value)!=null&&a.id)){L("\u8BF7\u9009\u62E9\u6536\u8D27\u5730\u5740");return}if(!f.value){L("\u8BF7\u5148\u9605\u8BFB\u5E76\u540C\u610F\u300A\u9177\u4E50\u79C0\u5E73\u53F0\u670D\u52A1\u534F\u8BAE\u300B");return}const t=S.user.data;if(!(t!=null&&t.realName)||!(t!=null&&t.idCardNo)){l.value=!0;return}if(i.orderNo){m.value=!0;return}B()},h=M(),B=async()=>{var n;const t=o.cartPromotionItemList.reduce((u,r)=>(u.push(r.id),u),[]),a=o.calcAmount.payAmount-o.calcAmount.promotionAmount,v={cartIds:t,memberReceiveAddressId:(n=c.value)==null?void 0:n.id,platformType:S.platformType,orderAmount:Number((a>=0?a:0).toFixed(2)),couponId:i.couponId};try{let{code:u,data:r}=await P.post("/api-mall-portal/order/generateOrder",{data:v});if(u===200){if(r.order.status===1){h.replace({path:"/shopTrade",query:{orderNo:r==null?void 0:r.order.orderSn,id:r==null?void 0:r.order.id}});return}m.value=!0,i.orderNo=(r==null?void 0:r.order.orderSn)||"",i.actualPrice=(r==null?void 0:r.order.payAmount)||0}}catch{}},N=()=>{l.value=!1,b()};return()=>e(G,null,[p.value?null:e("div",null,[o.cartPromotionItemList.length?e("div",{class:s.cartConfirm},[e("div",{class:s.cartConfirmBox},[e(H,{item:c.value,setAddress:C},null)]),e("div",{style:{marginTop:"20px"},class:[s.cartBox,s.cartConfirmBox]},[e("div",{class:s.shopBox},[o.cartPromotionItemList.map(t=>e("div",{class:[s.cartItem],style:{marginBottom:"10px"}},[e($,{price:A(t.price),desc:E(t.productAttr),title:t.productName,thumb:t.productPic,num:t.quantity},null)]))]),e(z,{border:!1},{default:()=>[e(W,{orderType:"GOODS",orderAmount:o.calcAmount.totalAmount,onCouponSelect:t=>{const a=t.map(n=>n.discountPrice).reduce((n,u)=>n+u,0),v=t.map(n=>n.couponIssueId).join(",");o.calcAmount.promotionAmount=a,i.couponId=v}},null),e(j,{border:!1,title:"\u603B\u989D",value:"\xA5 "+A(o.calcAmount.totalAmount)},null)]})]),e("div",{class:s.payProtocol},[e(Q,{modelValue:f.value,"onUpdate:modelValue":t=>f.value=t},null),e(D,{buttonText:`\u7ED3\u7B97(${o.cartPromotionItemList.length})`,buttonColor:"var(--van-primary)",disabled:o.cartPromotionItemList.length===0,onSubmit:()=>b()},{default:()=>[e("div",{class:s.confirmBottom},[g("\u5408\u8BA1")," ",e("span",{class:s["price-des"]},[g("\xA5"),A(o.calcAmount.payAmount-o.calcAmount.promotionAmount>=0?o.calcAmount.payAmount-o.calcAmount.promotionAmount:0)])])]})]),e("div",{style:{height:"var(--van-submit-bar-height)"}},null),e(J,{modelValue:l.value,"onUpdate:modelValue":t=>l.value=t},{default:()=>[e(K,{onSuccess:N},null)]}),e(F,{show:m.value,closeOnClickOverlay:!1,position:"bottom",round:!0,closeOnPopstate:!0,safeAreaInsetBottom:!0,style:{minHeight:"30%"}},{default:()=>[e(Z,{modelValue:m.value,"onUpdate:modelValue":t=>m.value=t,orderInfo:i,paymentType:"goodsPay",onBackOut:()=>m.value=!1},null)]})]):e(k,{buttonText:"\u53BB\u8D2D\u7269\u8F66",onClick:()=>{h.push({path:"/cart"})}},null)])])}});export{Bt as default};
