1 |
- import{d as N,S as d,O,U as I,w as P,b0 as R,bC as U,bq as V,Q as q,a2 as w,P as F,j as e,by 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.e6d6174e.js";import"./index.67c54471.js";import"./index.05f2b7dd.js";import{C as G}from"./index.0ed5cae2.js";import{C as z}from"./index.af99cf22.js";import{C as D}from"./index.4aea64de.js";import{S as H}from"./index.3ef52038.js";import{c as o,f as Q}from"./cart.a845ff4e.js";import{s}from"./index.module.0e920025.js";import{A as $}from"./index.50bc28d3.js";import{C as E}from"./index.cc99aa12.js";import{P as J}from"./index.b2461594.js";import{C as K}from"./index.62005a6f.js";import{U as W}from"./index.09405f55.js";import{U as X}from"./index.a762d91e.js";import"./index.3d7e5752.js";import"./index.d92a5aca.js";import"./icon_checkbox_default.2fe5d57e.js";import"./icon_checkbox-tenant.06c74bc2.js";import"./index.045f03fd.js";import"./index.d8c651bf.js";import"./use-height.8140ea04.js";import"./index.cbc70232.js";import"./hooks.00b5b341.js";import"./index.3dbd60dd.js";import"./index.83d3716a.js";import"./index.17d70acf.js";import"./use-id.f239f36f.js";import"./index.41be4a84.js";import"./item.e1e863f7.js";var Bt=N({name:"cartConfirm",setup(){const p=d(!0),y=O(),c=d();I(async()=>{if(p.value=!0,y.query.cartIds)try{let{code:t,data:a}=await P.post("/api-mall-portal/order/generateConfirmOrder",{params:{cartIds:y.query.cartIds}});t===200&&(o.calcAmount=a.calcAmount,o.cartPromotionItemList=a.cartPromotionItemList,o.memberReceiveAddressList=a.memberReceiveAddressList)}catch{}if(p.value=!1,o.memberReceiveAddressList.length){const t=o.memberReceiveAddressList.find(a=>a.defaultStatus)||o.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),m=d(!1),l=d(!1),i=q({orderNo:"",actualPrice:0,couponId:""});w(l,(t,a)=>{l.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)){l.value=!0;return}if(i.orderNo){m.value=!0;return}B()},h=F(),B=async()=>{var n;const t=o.cartPromotionItemList.reduce((u,r)=>(u.push(r.id),u),[]),a=o.calcAmount.payAmount-o.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{let{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}m.value=!0,i.orderNo=(r==null?void 0:r.order.orderSn)||"",i.actualPrice=(r==null?void 0:r.order.payAmount)||0}}catch{}},T=()=>{l.value=!1,b()};return()=>e(j,null,[p.value?null:e("div",null,[o.cartPromotionItemList.length?e("div",{class:s.cartConfirm},[e("div",{class:s.cartConfirmBox},[e($,{item:c.value,setAddress:C},null)]),e("div",{style:{marginTop:"20px"},class:[s.cartBox,s.cartConfirmBox]},[e("div",{class:s.shopBox},[o.cartPromotionItemList.map(t=>e("div",{class:[s.cartItem],style:{marginBottom:"10px"}},[e(G,{price:A(t.price),desc:Q(t.productAttr),title:t.productName,thumb:t.productPic,num:t.quantity},null)]))]),e(D,{border:!1},{default:()=>[e(X,{orderType:"GOODS",orderAmount:o.calcAmount.totalAmount,onCouponSelect:t=>{const a=t.map(n=>n.discountPrice).reduce((n,u)=>n+u,0),v=t.map(n=>n.couponIssueId).join(",");o.calcAmount.promotionAmount=a,i.couponId=v}},null),e(z,{border:!1,title:"\u603B\u989D",value:"\xA5 "+A(o.calcAmount.totalAmount)},null)]})]),e("div",{class:s.payProtocol},[e(E,{modelValue:f.value,"onUpdate:modelValue":t=>f.value=t},null),e(H,{buttonText:`\u7ED3\u7B97(${o.cartPromotionItemList.length})`,buttonColor:"var(--van-primary)",disabled:o.cartPromotionItemList.length===0,onSubmit:()=>b()},{default:()=>[e("div",{class:s.confirmBottom},[g("\u5408\u8BA1")," ",e("span",{class:s["price-des"]},[g("\xA5"),A(o.calcAmount.payAmount-o.calcAmount.promotionAmount>=0?o.calcAmount.payAmount-o.calcAmount.promotionAmount:0)])])]})]),e("div",{style:{height:"var(--van-submit-bar-height)"}},null),e(K,{modelValue:l.value,"onUpdate:modelValue":t=>l.value=t},{default:()=>[e(W,{onSuccess:T},null)]}),e(M,{show:m.value,closeOnClickOverlay:!1,position:"bottom",round:!0,closeOnPopstate:!0,safeAreaInsetBottom:!0,style:{minHeight:"30%"}},{default:()=>[e(J,{modelValue:m.value,"onUpdate:modelValue":t=>m.value=t,orderInfo:i,paymentType:"goodsPay",onBackOut:()=>m.value=!1},null)]})]):e(k,{buttonText:"\u53BB\u8D2D\u7269\u8F66",onClick:()=>{h.push({path:"/cart"})}},null)])])}});export{Bt as default};
|