import{d as T,U as d,P as O,V as b,y as h,bi as V,S as R,a3 as U,Q as q,j as o,bC as A,A as P,aS as w,C as F,F as k,T as g,g as S,n as x}from"./ResizeObserver.es.45df6c0f.js";import"./index.e11fdb7d.js";import"./index.b5f25372.js";import{C as D}from"./index.61ed2e73.js";import{C as j}from"./index.5034ef43.js";import{C as G}from"./index.7c526aec.js";import{S as H}from"./index.fa8e5493.js";import{c as e,f as M}from"./cart.80adabc4.js";import{s}from"./index.module.0e920025.js";import{A as J}from"./index.5ef269b1.js";import{C as Q}from"./index.e13645c1.js";import{P as $}from"./index.1dcc9e28.js";import{C as z}from"./index.4b7d2a6d.js";import{U as E}from"./index.2679289b.js";import{U as K}from"./index.6f1a1b37.js";import{C as W}from"./index.1a59558b.js";import"./index.483575b2.js";import"./index.d6257742.js";import"./icon_checkbox_default.2fe5d57e.js";import"./icon_checkbox-tenant.ecfa11df.js";import"./index.00200dcc.js";import"./hooks.d8170117.js";import"./index.eaf74307.js";import"./index.0c626117.js";import"./index.f093c879.js";import"./index.0acff0f0.js";import"./use-id.41c465c4.js";import"./index.6d776bb2.js";import"./index.fbfc86db.js";import"./item.1417624b.js";var Bt=T({name:"cartConfirm",setup(){const p=d(!0),y=O(),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&&(e.calcAmount=a.calcAmount,e.cartPromotionItemList=a.cartPromotionItemList,e.memberReceiveAddressList=a.memberReceiveAddressList)}catch{}if(p.value=!1,e.memberReceiveAddressList.length){const t=e.memberReceiveAddressList.find(a=>a.defaultStatus)||e.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")}),V(()=>{});const f=d(!1),m=d(!1),i=d(!1),c=R({orderNo:"",actualPrice:0,couponId:""});U(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=e.cartPromotionItemList.reduce((u,r)=>(u.push(r.id),u),[]),a=e.calcAmount.payAmount-e.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()=>o(k,null,[o(W,null,null),p.value?null:o("div",null,[e.cartPromotionItemList.length?o("div",{class:s.cartConfirm},[o("div",{class:s.cartConfirmBox},[o(J,{item:l.value,setAddress:B},null)]),o("div",{style:{marginTop:"20px"},class:[s.cartBox,s.cartConfirmBox]},[o("div",{class:s.shopBox},[e.cartPromotionItemList.map(t=>o("div",{class:[s.cartItem],style:{marginBottom:"10px"}},[o(D,{price:A(t.price),desc:M(t.productAttr),title:t.productName,thumb:t.productPic,num:t.quantity},null)]))]),o(G,{border:!1},{default:()=>[o(K,{orderType:"GOODS",orderAmount:e.calcAmount.totalAmount,onCouponSelect:t=>{const a=t.map(n=>n.discountPrice).reduce((n,u)=>n+u,0),v=t.map(n=>n.couponIssueId).join(",");e.calcAmount.promotionAmount=a,c.couponId=v}},null),o(j,{border:!1,title:"\u603B\u989D",value:"\xA5 "+A(e.calcAmount.totalAmount)},null)]})]),o("div",{class:s.payProtocol},[o(Q,{modelValue:f.value,"onUpdate:modelValue":t=>f.value=t},null),o(H,{buttonText:`\u7ED3\u7B97(${e.cartPromotionItemList.length})`,buttonColor:"var(--van-primary)",disabled:e.cartPromotionItemList.length===0,onSubmit:()=>C()},{default:()=>[o("div",{class:s.confirmBottom},[P("\u5408\u8BA1")," ",o("span",{class:s["price-des"]},[P("\xA5"),A(e.calcAmount.payAmount-e.calcAmount.promotionAmount>=0?e.calcAmount.payAmount-e.calcAmount.promotionAmount:0)])])]})]),o("div",{style:{height:"var(--van-submit-bar-height)"}},null),o(z,{modelValue:i.value,"onUpdate:modelValue":t=>i.value=t},{default:()=>[o(E,{onSuccess:N},null)]}),o(w,{show:m.value,closeOnClickOverlay:!1,position:"bottom",round:!0,closeOnPopstate:!0,safeAreaInsetBottom:!0,style:{minHeight:"30%"}},{default:()=>[o($,{modelValue:m.value,"onUpdate:modelValue":t=>m.value=t,orderInfo:c,paymentType:"goodsPay",onBackOut:()=>m.value=!1},null)]})]):o(F,{buttonText:"\u53BB\u8D2D\u7269\u8F66",onClick:()=>{I.push({path:"/cart"})}},null)])])}});export{Bt as default};
