var V=Object.defineProperty;var j=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var C=(n,r,a)=>r in n?V(n,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[r]=a,P=(n,r)=>{for(var a in r||(r={}))O.call(r,a)&&C(n,a,r[a]);if(j)for(var a of j(r))N.call(r,a)&&C(n,a,r[a]);return n};import{d as q,M as d,a4 as U,a5 as w,a6 as F,a7 as k,b as t,a3 as M,m as G,p as H,a0 as $,j as I,P as z,F as D,T as g}from"./vendor.27e15f5e.js";/* empty css               *//* empty css               *//* empty css                *//* empty css               *//* empty css              *//* empty css                */import{c as o,f as E}from"./cart.9f734fbb.js";import{s as i}from"./index.module.3bc378ff.js";import{A as J}from"./index.73cde4a1.js";import{p as f,r as B,m as v,C as K,s as L}from"./index.aa5e2480.js";import{C as Q,P as W}from"./index.0f2c0804.js";import{C as X,U as Y}from"./index.28c70a58.js";import{a as S,r as Z}from"./address.936e1d3f.js";/* empty css               *//* empty css               */import"./index.f720c953.js";/* empty css               *//* empty css              *//* empty css               */var he=q({name:"cartConfirm",setup(){const n=d(!0),r=U(),a=d();w(async()=>{if(f({api:"setBarStatus",content:{status:1}}),n.value=!0,r.query.cartIds)try{let{code:e,data:l}=await B.post("/api-mall-portal/order/generateConfirmOrder",{params:{cartIds:r.query.cartIds}});e===200&&(o.calcAmount=l.calcAmount,o.cartPromotionItemList=l.cartPromotionItemList,o.memberReceiveAddressList=l.memberReceiveAddressList)}catch{}if(n.value=!1,o.memberReceiveAddressList.length){const e=o.memberReceiveAddressList.find(l=>l.defaultStatus)||o.memberReceiveAddressList[0];e&&(a.value=e)}S.id&&(x(P({},S)||{}),Z())});const x=e=>{a.value=e},p=d(!1),m=d(!1),u=d(!1),A=d();F(u,(e,l)=>{u.value?f({api:"setBarStatus",content:{status:0}}):f({api:"setBarStatus",content:{status:1}})});const y=()=>{var l;if(!((l=a.value)==null?void 0:l.id)){g("\u8BF7\u9009\u62E9\u6536\u8D27\u5730\u5740");return}if(!p.value){g("\u8BF7\u5148\u9605\u8BFB\u5E76\u540C\u610F\u300A\u4EA7\u54C1\u53CA\u670D\u52A1\u534F\u8BAE\u300B");return}const e=L.user.data;if(!(e==null?void 0:e.student.realName)||!(e==null?void 0:e.student.idCardNo)){u.value=!0;return}T()},b=k(),T=async()=>{var h;const l={cartIds:o.cartPromotionItemList.reduce((c,s)=>(c.push(s.id),c),[]),memberReceiveAddressId:(h=a.value)==null?void 0:h.id,platformType:L.platformType,orderAmount:(o.calcAmount.payAmount-o.calcAmount.promotionAmount).toFixed(2)};try{const{code:c,data:s}=await B.post("/api-mall-portal/order/generateOrder",{data:l});if(c===200){if(s.order.status===1){b.replace({path:"/shopTrade",query:{orderNo:s==null?void 0:s.order.orderSn,id:s==null?void 0:s.order.id}});return}m.value=!0,A.value=s==null?void 0:s.pay}}catch{}},R=()=>{u.value=!1,y()};return()=>t(D,null,[n.value?null:t("div",null,[o.cartPromotionItemList.length?t("div",{class:i.cartConfirm},[t("div",{class:i.cartConfirmBox},[t(J,{item:a.value,setAddress:x},null)]),t("div",{style:{marginTop:"20px"},class:[i.cartBox,i.cartConfirmBox]},[t("div",{class:i.shopBox},[o.cartPromotionItemList.map(e=>t("div",{class:[i.cartItem],style:{marginBottom:"10px"}},[t(M,{price:v(e.price),desc:E(e.productAttr),title:e.productName,thumb:e.productPic,num:e.quantity},null)]))]),t(G,{border:!0},{default:()=>[t(H,{border:!1,title:"\u603B\u989D",value:"\xA5 "+v(o.calcAmount.totalAmount)},null)]})]),t("div",{class:i.payProtocol},[t(Q,{modelValue:p.value,"onUpdate:modelValue":e=>p.value=e},null),t($,{buttonText:`\u7ED3\u7B97(${o.cartPromotionItemList.length})`,buttonColor:"var(--van-primary)",disabled:o.cartPromotionItemList.length===0,onSubmit:()=>y()},{default:()=>[t("div",{class:i.confirmBottom},[I("\u5408\u8BA1")," ",t("span",{class:i["price-des"]},[I("\xA5"),v(o.calcAmount.payAmount-o.calcAmount.promotionAmount)])])]})]),t("div",{style:{height:"var(--van-submit-bar-height)"}},null),t(X,{modelValue:u.value,"onUpdate:modelValue":e=>u.value=e},{default:()=>[t(Y,{onSuccess:R},null)]}),t(z,{show:m.value,closeOnClickOverlay:!1,position:"bottom",round:!0,closeOnPopstate:!0,safeAreaInsetBottom:!0,style:{minHeight:"30%"}},{default:()=>[t(W,{modelValue:m.value,"onUpdate:modelValue":e=>m.value=e,orderInfo:A.value,paymentType:"goodsPay",onBackOut:()=>m.value=!1},null)]})]):t(K,{buttonText:"\u53BB\u8D2D\u7269\u8F66",onClick:()=>{b.push({path:"/cart"})}},null)])])}});export{he as default};
