index.e06b6ffd.js 4.9 KB

1
  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.b7226882.js";import"./index.20c0f4c5.js";import"./index.ed3a5560.js";import{C as D}from"./index.30f2a704.js";import{C as j}from"./index.40f703b6.js";import{C as G}from"./index.9269bf1e.js";import{S as H}from"./index.7c58bd0a.js";import{c as e,f as M}from"./cart.5e5d785e.js";import{s}from"./index.module.0e920025.js";import{A as J}from"./index.4a49cc1f.js";import{C as Q}from"./index.3d92d0ba.js";import{P as $}from"./index.beac08d2.js";import{C as z}from"./index.3a3292e3.js";import{U as E}from"./index.c1bb54e7.js";import{U as K}from"./index.15e122d4.js";import{C as W}from"./index.969bba7f.js";import"./index.1799aedf.js";import"./index.b1e15d61.js";import"./icon_checkbox.808b953c.js";import"./icon_checkbox-tenant.ecfa11df.js";import"./icon_checkbox_default.256c0849.js";import"./index.83925f29.js";import"./hooks.a4ed20cb.js";import"./index.00914c2e.js";import"./index.af733095.js";import"./index.527ae768.js";import"./index.021f1c7b.js";import"./use-id.5d5e6e63.js";import"./index.9dec3b5d.js";import"./index.016a5975.js";import"./item.a48bb030.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};