1 |
- 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.39b48a47.js";import"./index.fcbcb027.js";import"./index.34ac729a.js";import{C as D}from"./index.ff5688ac.js";import{C as j}from"./index.db115763.js";import{C as G}from"./index.9f5e14d1.js";import{S as H}from"./index.18400b32.js";import{c as e,f as M}from"./cart.426348e2.js";import{s}from"./index.module.0e920025.js";import{A as J}from"./index.b1a42bb7.js";import{C as Q}from"./index.08a7f4aa.js";import{P as $}from"./index.1347f274.js";import{C as z}from"./index.a0f53d9f.js";import{U as E}from"./index.0404e33a.js";import{U as K}from"./index.659f2bf7.js";import{C as W}from"./index.970ad07b.js";import"./index.0a093430.js";import"./index.3c44a6d7.js";import"./icon_checkbox.808b953c.js";import"./icon_checkbox-tenant.ecfa11df.js";import"./icon_checkbox_default.256c0849.js";import"./index.bb84a3aa.js";import"./hooks.6df65925.js";import"./index.f6c41ddf.js";import"./index.16ffd6ad.js";import"./index.867583ad.js";import"./index.428ab1a8.js";import"./use-id.b004ff17.js";import"./index.418cbe7f.js";import"./index.45e4ca3e.js";import"./item.e9e354a0.js";var Lt=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{Lt as default};
|