1 |
- var U=Object.defineProperty;var j=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var I=(u,s,a)=>s in u?U(u,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):u[s]=a,P=(u,s)=>{for(var a in s||(s={}))w.call(s,a)&&I(u,a,s[a]);if(j)for(var a of j(s))F.call(s,a)&&I(u,a,s[a]);return u};import{d as k,M as d,a4 as q,a5 as M,a6 as H,b as t,a3 as G,m as $,p as B,G as D,a0 as z,j as L,P as E,F as J,T as S}from"./vendor.2bcdc9cf.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{c as o,f as K}from"./cart.2a3b730f.js";import{s as i}from"./index.module.3bc378ff.js";import{A as Q}from"./index.e7c25db6.js";import{r as b,m as v,C as W,s as x}from"./index.3619a7ff.js";import{C as X,P as Y}from"./index.69271b6e.js";import{U as Z,C as _,a as ee}from"./index.d554fd8c.js";import{a as T,r as te}from"./address.6eabc372.js";import{C as oe}from"./index.6e7075da.js";/* empty css *//* empty css *//* empty css */import"./item.3ccc7112.js";import"./index.ebee95a8.js";var Be=k({name:"cartConfirm",setup(){const u=d(!0),s=q(),a=d(),n=d({useBalance:!1,balance:0,couponId:""});M(async()=>{if(u.value=!0,await V(),s.query.cartIds)try{let{code:e,data:l}=await b.post("/api-mall-portal/order/generateConfirmOrder",{params:{cartIds:s.query.cartIds}});e===200&&(o.calcAmount=l.calcAmount,o.cartPromotionItemList=l.cartPromotionItemList,o.memberReceiveAddressList=l.memberReceiveAddressList)}catch{}if(u.value=!1,o.memberReceiveAddressList.length){const e=o.memberReceiveAddressList.find(l=>l.defaultStatus)||o.memberReceiveAddressList[0];e&&(a.value=e)}T.id&&(y(P({},T)||{}),te())});const V=async()=>{try{const{data:e}=await b.get("/api-student/userCashAccount/get");n.value.balance=e.balance||0}catch{}},y=e=>{a.value=e},A=d(!1),m=d(!1),p=d(!1),C=d(),h=()=>{var l;if(!((l=a.value)==null?void 0:l.id)){S("\u8BF7\u9009\u62E9\u6536\u8D27\u5730\u5740");return}if(!A.value){S("\u8BF7\u5148\u9605\u8BFB\u5E76\u540C\u610F\u300A\u4EA7\u54C1\u53CA\u670D\u52A1\u534F\u8BAE\u300B");return}const e=x.user.data;if(!(e==null?void 0:e.student.realName)||!(e==null?void 0:e.student.idCardNo)){p.value=!0;return}N()},g=H(),N=async()=>{var f;const l={cartIds:o.cartPromotionItemList.reduce((c,r)=>(c.push(r.id),c),[]),memberReceiveAddressId:(f=a.value)==null?void 0:f.id,platformType:x.platformType,orderAmount:(o.calcAmount.payAmount-o.calcAmount.promotionAmount).toFixed(2),couponId:n.value.couponId,useBalance:n.value.useBalance};try{const{code:c,data:r}=await b.post("/api-mall-portal/order/generateOrder",{data:l});if(c===200){if(r.order.status===1){g.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.value=r==null?void 0:r.pay}}catch{}},O=()=>{p.value=!1,console.log(x.user.data),h()},R=()=>{let e=Number((o.calcAmount.payAmount-o.calcAmount.promotionAmount).toFixed(2));return console.log(e),n.value.useBalance&&(e=e-n.value.balance<=0?0:Number((e-n.value.balance).toFixed(2))),e};return()=>t(J,null,[t(oe,null,null),u.value?null:t("div",null,[o.cartPromotionItemList.length?t("div",{class:i.cartConfirm},[t("div",{class:i.cartConfirmBox},[t(Q,{item:a.value,setAddress:y},null)]),t("div",{style:{marginTop:"20px"},class:[i.cartBox,i.cartConfirmBox]},[t("div",{class:i.shopBox},[o.cartPromotionItemList.map(e=>t("div",{class:[i.cartItem],style:{marginBottom:"10px"}},[t(G,{price:v(e.price),desc:K(e.productAttr),title:e.productName,thumb:e.productPic,num:e.quantity},null)]))]),t($,{border:!0},{default:()=>[t(Z,{useSystem:"MALL",typeDetail:"MALLCOUPON",orderAmount:o.calcAmount.totalAmount,onCouponSelect:e=>{console.log(e,"coupon");const l=e.map(c=>c.faceValue).reduce((c,r)=>c+r,0),f=e.map(c=>c.couponCodeId).join(",");o.calcAmount.promotionAmount=l,n.value.couponId=f,console.log(n,"coupon")}},null),t(B,{onClick:()=>{console.log(!0,"111"),n.value.useBalance=!n.value.useBalance}},{title:`\u4F59\u989D\u652F\u4ED8\uFF08\u5269\u4F59\uFF1A\uFFE5${v(n.value.balance)}\uFF09`,"right-icon":()=>t(D,{modelValue:n.value.useBalance},null)}),t(B,{border:!1,title:"\u603B\u989D",value:"\xA5 "+v(o.calcAmount.totalAmount)},null)]})]),t("div",{class:i.payProtocol},[t(X,{showHeader:!0,modelValue:A.value,"onUpdate:modelValue":e=>A.value=e},null),t(z,{buttonText:`\u7ED3\u7B97(${o.cartPromotionItemList.length})`,buttonColor:"var(--van-primary)",disabled:o.cartPromotionItemList.length===0,onSubmit:()=>h()},{default:()=>[t("div",{class:i.confirmBottom},[L("\u5408\u8BA1")," ",t("span",{class:i["price-des"]},[L("\xA5"),v(R())])])]})]),t("div",{style:{height:"var(--van-submit-bar-height)"}},null),t(_,{modelValue:p.value,"onUpdate:modelValue":e=>p.value=e},{default:()=>[t(ee,{onSuccess:O},null)]}),t(E,{show:m.value,closeOnClickOverlay:!1,position:"bottom",round:!0,closeOnPopstate:!0,safeAreaInsetBottom:!0,style:{minHeight:"30%"}},{default:()=>[t(Y,{modelValue:m.value,"onUpdate:modelValue":e=>m.value=e,orderInfo:C.value,paymentType:"goodsPay",onBackOut:()=>m.value=!1},null)]})]):t(W,{buttonText:"\u53BB\u8D2D\u7269\u8F66",onClick:()=>{g.push({path:"/cart"})}},null)])])}});export{Be as default};
|