import{d as O,S as d,O as T,U as b,x as h,bD as R,Q as U,a2 as V,P as q,j as e,bz as A,z as P,aR as w,C as D,F,T as g,g as S,n as x}from"./index.3bfa6a0e.js";import"./index.0fd5538f.js";import"./index.c171ade0.js";import{C as k}from"./index.3c85b958.js";import{C as j}from"./index.79997a38.js";import{C as z}from"./index.85c8c2f7.js";import{S as G}from"./index.39563dd4.js";import{c as o,f as H}from"./cart.14281415.js";import{s}from"./index.module.0e920025.js";import{A as M}from"./index.8ee8d6d1.js";import{C as J}from"./index.1a023ea4.js";import{P as Q}from"./index.d8734357.js";import{C as $}from"./index.8a2292dc.js";import{U as E}from"./index.a68b9b7d.js";import{U as K}from"./index.71c10b5c.js";import{C as W}from"./index.645e7ddc.js";import"./index.68aa5658.js";import"./index.fb1da5d0.js";import"./icon_checkbox_default.2fe5d57e.js";import"./icon_checkbox-tenant.ecfa11df.js";import"./index.f272c75f.js";import"./hooks.435f47d5.js";import"./index.0916b076.js";import"./index.bb2d59fe.js";import"./index.983bfd1a.js";import"./use-id.7c44c16f.js";import"./index.8903238b.js";import"./index.9551d420.js";import"./item.48ae45a6.js";var xt=O({name:"cartConfirm",setup(){const p=d(!0),y=T(),l=d();b(async()=>{if(p.value=!0,y.query.cartIds)try{const{code:t,data:a}=await h.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&&(l.value=t)}});const B=t=>{l.value=t};b(()=>{let t=sessionStorage.getItem("addressDetails");t=t?JSON.parse(t):{},l.value=t,sessionStorage.removeItem("addressDetails")}),R(()=>{});const f=d(!1),m=d(!1),i=d(!1),c=U({orderNo:"",actualPrice:0,couponId:""});V(i,(t,a)=>{i.value?x({api:"setBarStatus",content:{status:0}}):x({api:"setBarStatus",content:{status:1}})});const C=()=>{var a;if(!((a=l.value)!=null&&a.id)){g("\u8BF7\u9009\u62E9\u6536\u8D27\u5730\u5740");return}if(!f.value){g("\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)){i.value=!0;return}if(c.orderNo){m.value=!0;return}L()},I=q(),L=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=l.value)==null?void 0:n.id,platformType:S.platformType,orderAmount:Number((a>=0?a:0).toFixed(2)),couponId:c.couponId};try{const{code:u,data:r}=await h.post("/api-mall-portal/order/generateOrder",{data:v});if(u===200){if(r.order.status===1){I.replace({path:"/shopTrade",query:{orderNo:r==null?void 0:r.order.orderSn,id:r==null?void 0:r.order.id}});return}m.value=!0,c.orderNo=(r==null?void 0:r.order.orderSn)||"",c.actualPrice=(r==null?void 0:r.order.payAmount)||0}}catch{}},N=()=>{i.value=!1,C()};return()=>e(F,null,[e(W,null,null),p.value?null:e("div",null,[o.cartPromotionItemList.length?e("div",{class:s.cartConfirm},[e("div",{class:s.cartConfirmBox},[e(M,{item:l.value,setAddress:B},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(k,{price:A(t.price),desc:H(t.productAttr),title:t.productName,thumb:t.productPic,num:t.quantity},null)]))]),e(z,{border:!1},{default:()=>[e(K,{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,c.couponId=v}},null),e(j,{border:!1,title:"\u603B\u989D",value:"\xA5 "+A(o.calcAmount.totalAmount)},null)]})]),e("div",{class:s.payProtocol},[e(J,{modelValue:f.value,"onUpdate:modelValue":t=>f.value=t},null),e(G,{buttonText:`\u7ED3\u7B97(${o.cartPromotionItemList.length})`,buttonColor:"var(--van-primary)",disabled:o.cartPromotionItemList.length===0,onSubmit:()=>C()},{default:()=>[e("div",{class:s.confirmBottom},[P("\u5408\u8BA1")," ",e("span",{class:s["price-des"]},[P("\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($,{modelValue:i.value,"onUpdate:modelValue":t=>i.value=t},{default:()=>[e(E,{onSuccess:N},null)]}),e(w,{show:m.value,closeOnClickOverlay:!1,position:"bottom",round:!0,closeOnPopstate:!0,safeAreaInsetBottom:!0,style:{minHeight:"30%"}},{default:()=>[e(Q,{modelValue:m.value,"onUpdate:modelValue":t=>m.value=t,orderInfo:c,paymentType:"goodsPay",onBackOut:()=>m.value=!1},null)]})]):e(D,{buttonText:"\u53BB\u8D2D\u7269\u8F66",onClick:()=>{I.push({path:"/cart"})}},null)])])}});export{xt as default};
