var S=Object.defineProperty;var C=Object.getOwnPropertySymbols;var V=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var j=(n,a,o)=>a in n?S(n,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[a]=o,P=(n,a)=>{for(var o in a||(a={}))V.call(a,o)&&j(n,o,a[o]);if(C)for(var o of C(a))O.call(a,o)&&j(n,o,a[o]);return n};import{d as N,M as i,a4 as q,a5 as U,a6 as w,b as t,a3 as F,m as k,p as H,a0 as M,j as I,P as G,F as $,T as g}from"./vendor.2bcdc9cf.js";/* empty css               *//* empty css               *//* empty css                *//* empty css               *//* empty css              *//* empty css                */import{c as r,f as z}from"./cart.2a3b730f.js";import{s as d}from"./index.module.3bc378ff.js";import{A as D}from"./index.e7c25db6.js";import{r as L,m as f,C as E,s as v}from"./index.b8b9219f.js";import{C as J,P as K}from"./index.c3eb7a0c.js";import{C as Q,U as W}from"./index.190275ff.js";import{a as B,r as X}from"./address.6eabc372.js";import{C as Y}from"./index.4cc32b24.js";/* empty css               *//* empty css               *//* empty css               *//* empty css              *//* empty css               */var ye=N({name:"cartConfirm",setup(){const n=i(!0),a=q(),o=i();U(async()=>{if(n.value=!0,a.query.cartIds)try{let{code:e,data:l}=await L.post("/api-mall-portal/order/generateConfirmOrder",{params:{cartIds:a.query.cartIds}});e===200&&(r.calcAmount=l.calcAmount,r.cartPromotionItemList=l.cartPromotionItemList,r.memberReceiveAddressList=l.memberReceiveAddressList)}catch{}if(n.value=!1,r.memberReceiveAddressList.length){const e=r.memberReceiveAddressList.find(l=>l.defaultStatus)||r.memberReceiveAddressList[0];e&&(o.value=e)}B.id&&(b(P({},B)||{}),X())});const b=e=>{o.value=e},p=i(!1),u=i(!1),c=i(!1),x=i(),A=()=>{var l;if(!((l=o.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=v.user.data;if(!(e==null?void 0:e.student.realName)||!(e==null?void 0:e.student.idCardNo)){c.value=!0;return}T()},y=w(),T=async()=>{var h;const l={cartIds:r.cartPromotionItemList.reduce((m,s)=>(m.push(s.id),m),[]),memberReceiveAddressId:(h=o.value)==null?void 0:h.id,platformType:v.platformType,orderAmount:(r.calcAmount.payAmount-r.calcAmount.promotionAmount).toFixed(2)};try{const{code:m,data:s}=await L.post("/api-mall-portal/order/generateOrder",{data:l});if(m===200){if(s.order.status===1){y.replace({path:"/shopTrade",query:{orderNo:s==null?void 0:s.order.orderSn,id:s==null?void 0:s.order.id}});return}u.value=!0,x.value=s==null?void 0:s.pay}}catch{}},R=()=>{c.value=!1,console.log(v.user.data),A()};return()=>t($,null,[t(Y,null,null),n.value?null:t("div",null,[r.cartPromotionItemList.length?t("div",{class:d.cartConfirm},[t("div",{class:d.cartConfirmBox},[t(D,{item:o.value,setAddress:b},null)]),t("div",{style:{marginTop:"20px"},class:[d.cartBox,d.cartConfirmBox]},[t("div",{class:d.shopBox},[r.cartPromotionItemList.map(e=>t("div",{class:[d.cartItem],style:{marginBottom:"10px"}},[t(F,{price:f(e.price),desc:z(e.productAttr),title:e.productName,thumb:e.productPic,num:e.quantity},null)]))]),t(k,{border:!0},{default:()=>[t(H,{border:!1,title:"\u603B\u989D",value:"\xA5 "+f(r.calcAmount.totalAmount)},null)]})]),t("div",{class:d.payProtocol},[t(J,{showHeader:!0,modelValue:p.value,"onUpdate:modelValue":e=>p.value=e},null),t(M,{buttonText:`\u7ED3\u7B97(${r.cartPromotionItemList.length})`,buttonColor:"var(--van-primary)",disabled:r.cartPromotionItemList.length===0,onSubmit:()=>A()},{default:()=>[t("div",{class:d.confirmBottom},[I("\u5408\u8BA1")," ",t("span",{class:d["price-des"]},[I("\xA5"),f(r.calcAmount.payAmount-r.calcAmount.promotionAmount)])])]})]),t("div",{style:{height:"var(--van-submit-bar-height)"}},null),t(Q,{modelValue:c.value,"onUpdate:modelValue":e=>c.value=e},{default:()=>[t(W,{onSuccess:R},null)]}),t(G,{show:u.value,closeOnClickOverlay:!1,position:"bottom",round:!0,closeOnPopstate:!0,safeAreaInsetBottom:!0,style:{minHeight:"30%"}},{default:()=>[t(K,{modelValue:u.value,"onUpdate:modelValue":e=>u.value=e,orderInfo:x.value,paymentType:"goodsPay",onBackOut:()=>u.value=!1},null)]})]):t(E,{buttonText:"\u53BB\u8D2D\u7269\u8F66",onClick:()=>{y.push({path:"/cart"})}},null)])])}});export{ye as default};
