1 |
- import{d as N,S as d,O,U as I,w as P,b0 as R,bC as U,br as V,Q as q,a2 as w,P as F,j as o,bz as A,z as g,aR as M,C as k,F as j,T as S,g as x,n as L}from"./index.394decd7.js";import"./index.ae2dd816.js";import"./index.dab716ce.js";import{C as z}from"./index.07bd1663.js";import{C as G}from"./index.9e0d46e4.js";import{C as H}from"./index.9462d7c5.js";import{S as D}from"./index.2917b3bd.js";import{c as e,f as Q}from"./cart.3ddc848e.js";import{s}from"./index.module.0e920025.js";import{A as $}from"./index.2b124643.js";import{C as E}from"./index.7ad13071.js";import{P as J}from"./index.2569f88d.js";import{C as K}from"./index.d66a5072.js";import{U as W}from"./index.39e45819.js";import{U as X}from"./index.e98d90c3.js";import{C as Y}from"./index.e6e212d8.js";import"./index.24fb4ee4.js";import"./index.b91a923c.js";import"./icon_checkbox_default.2fe5d57e.js";import"./icon_checkbox-tenant.ecfa11df.js";import"./index.4ef31a7f.js";import"./hooks.9e5ee122.js";import"./index.6726afc4.js";import"./index.a9c78aa8.js";import"./index.224299a1.js";import"./use-id.e2f22365.js";import"./index.4c43caee.js";import"./item.2362e6e9.js";var Lt=N({name:"cartConfirm",setup(){const p=d(!0),y=O(),c=d();I(async()=>{if(p.value=!0,y.query.cartIds)try{const{code:t,data:a}=await P.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&&(c.value=t)}});const C=t=>{c.value=t};I(()=>{R("getAddress",t=>{C((t==null?void 0:t.content)||{})})}),U(()=>{V("getAddress",()=>{})});const f=d(!1),l=d(!1),m=d(!1),i=q({orderNo:"",actualPrice:0,couponId:""});w(m,(t,a)=>{m.value?L({api:"setBarStatus",content:{status:0}}):L({api:"setBarStatus",content:{status:1}})});const b=()=>{var a;if(!((a=c.value)!=null&&a.id)){S("\u8BF7\u9009\u62E9\u6536\u8D27\u5730\u5740");return}if(!f.value){S("\u8BF7\u5148\u9605\u8BFB\u5E76\u540C\u610F\u300A\u9177\u4E50\u79C0\u5E73\u53F0\u670D\u52A1\u534F\u8BAE\u300B");return}const t=x.user.data;if(!(t!=null&&t.realName)||!(t!=null&&t.idCardNo)){m.value=!0;return}if(i.orderNo){l.value=!0;return}B()},h=F(),B=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=c.value)==null?void 0:n.id,platformType:x.platformType,orderAmount:Number((a>=0?a:0).toFixed(2)),couponId:i.couponId};try{const{code:u,data:r}=await P.post("/api-mall-portal/order/generateOrder",{data:v});if(u===200){if(r.order.status===1){h.replace({path:"/shopTrade",query:{orderNo:r==null?void 0:r.order.orderSn,id:r==null?void 0:r.order.id}});return}l.value=!0,i.orderNo=(r==null?void 0:r.order.orderSn)||"",i.actualPrice=(r==null?void 0:r.order.payAmount)||0}}catch{}},T=()=>{m.value=!1,b()};return()=>o(j,null,[o(Y,null,null),p.value?null:o("div",null,[e.cartPromotionItemList.length?o("div",{class:s.cartConfirm},[o("div",{class:s.cartConfirmBox},[o($,{item:c.value,setAddress:C},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(z,{price:A(t.price),desc:Q(t.productAttr),title:t.productName,thumb:t.productPic,num:t.quantity},null)]))]),o(H,{border:!1},{default:()=>[o(X,{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,i.couponId=v}},null),o(G,{border:!1,title:"\u603B\u989D",value:"\xA5 "+A(e.calcAmount.totalAmount)},null)]})]),o("div",{class:s.payProtocol},[o(E,{modelValue:f.value,"onUpdate:modelValue":t=>f.value=t},null),o(D,{buttonText:`\u7ED3\u7B97(${e.cartPromotionItemList.length})`,buttonColor:"var(--van-primary)",disabled:e.cartPromotionItemList.length===0,onSubmit:()=>b()},{default:()=>[o("div",{class:s.confirmBottom},[g("\u5408\u8BA1")," ",o("span",{class:s["price-des"]},[g("\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(K,{modelValue:m.value,"onUpdate:modelValue":t=>m.value=t},{default:()=>[o(W,{onSuccess:T},null)]}),o(M,{show:l.value,closeOnClickOverlay:!1,position:"bottom",round:!0,closeOnPopstate:!0,safeAreaInsetBottom:!0,style:{minHeight:"30%"}},{default:()=>[o(J,{modelValue:l.value,"onUpdate:modelValue":t=>l.value=t,orderInfo:i,paymentType:"goodsPay",onBackOut:()=>l.value=!1},null)]})]):o(k,{buttonText:"\u53BB\u8D2D\u7269\u8F66",onClick:()=>{h.push({path:"/cart"})}},null)])])}});export{Lt as default};
|