pages-order-confirm.a37de497.js 12 KB

1
  1. import{y as e,c as s,ab as t,Y as r,l as o,m as a,e as l,f as d,w as i,j as c,t as n,u,i as p,Z as f,E as y,G as m,o as P,s as _,aa as b,k as h,r as x,F as v,v as I,B as w,g as k,ac as g,a1 as T,x as j}from"./index-b48a414d.js";import{_ as M}from"./s-address-item.88e47ed1.js";import{_ as O}from"./s-goods-item.13120f93.js";import{_ as V,a as C}from"./phone-international-input.feef99c7.js";import{_ as D}from"./_plugin-vue_export-helper.1b428a4d.js";import{p as E,f as A,d as F,a as N,_ as S}from"./s-layout.d6dcdc81.js";import{_ as $}from"./points.c381a8e1.js";/* empty css */const B=D({__name:"s-points-pop",props:{modelValue:{type:Object,default(){}},show:{type:Boolean,default:!1},currentMemberPoints:{type:Number,default:0},currentTotalPrice:{type:Number,default:0},currentDeliveryPrice:{type:Number,default:0}},emits:["confirm","close"],setup(P,{emit:_}){const b=P,h=_,x=e({points:0,disabled:!1}),v=s((()=>parseFloat(b.currentMemberPoints))),I=s((()=>parseFloat(b.currentTotalPrice))),w=s((()=>parseFloat(b.currentDeliveryPrice))),k=s((()=>I.value?(I.value-.01-w.value).toFixed(2):I.value));t((()=>{x.points>v.value&&r((()=>{x.points=v.value})),x.points>k.value&&r((()=>{x.points=k.value})),(0==k.value||k.value<0)&&(x.disabled=!0),k.value>0&&(x.disabled=!1)}));const g=()=>{h("confirm",x.points)};return(e,s)=>{const t=p,r=f,_=y,b=m,v=o(a("su-popup"),V);return l(),d(v,{show:P.show,type:"bottom",round:"10",onClose:s[2]||(s[2]=e=>h("close")),showClose:"",backgroundColor:"#ffffff"},{default:i((()=>[c(t,{class:"title ss-m-t-16 ss-m-l-20 ss-flex"},{default:i((()=>[n("使用积分")])),_:1}),c(t,{class:"model-box ss-p-x-30"},{default:i((()=>[c(r,{modelValue:x.points,"onUpdate:modelValue":s[0]||(s[0]=e=>x.points=e),modelModifiers:{number:!0},class:"uni-input input-points ss-m-b-10",type:"number",placeholder:"请输入抵扣积分",oninput:"this.value=this.value.replace(/\\D/g);",disabled:x.disabled},null,8,["modelValue","disabled"])])),_:1}),c(t,{class:"modal-footer text-center"},{default:i((()=>[c(t,{class:"subtitle text-disabled"},{default:i((()=>[n("您的可用积分"),c(_,{class:"text-red"},{default:i((()=>[n(u(P.currentMemberPoints),1)])),_:1})])),_:1}),c(t,{class:"subtitle text-disabled"},{default:i((()=>[n("当前订单价格"),c(_,{class:"text-red"},{default:i((()=>[n("¥"+u(I.value),1)])),_:1}),n(",可使用最高"),c(_,{class:"text-red"},{default:i((()=>[n(u(k.value),1)])),_:1}),n("积分 ")])),_:1}),c(t,{class:"ss-flex ss-m-y-20 ss-col-center"},{default:i((()=>[c(b,{class:"confirm-btn ss-reset-button",onClick:s[1]||(s[1]=e=>{x.points=0,h("confirm",x.points)})},{default:i((()=>[n("取消")])),_:1}),c(b,{class:"confirm-btn ss-reset-button",onClick:g},{default:i((()=>[n("确认")])),_:1})])),_:1})])),_:1})])),_:1},8,["show"])}}},[["__scopeId","data-v-797017b8"]]),R=D({__name:"confirm",setup(t){const r=e({orderPayload:{},orderInfo:{items:[],price:{}},addressInfo:{},showPoints:!1,couponInfo:[],showDiscount:!1,currentMemberPoints:0,usedPoint:0,currentTotalPrice:0,currentDeliveryPrice:0}),f=s((()=>{console.log(r.orderInfo.shopRespVOMap);const e={};try{Object.keys(r.orderInfo.shopRespVOMap).forEach((s=>{const t=r.orderInfo.shopNameMap[s];t&&(e[t]=r.orderInfo.shopRespVOMap[s],e[t].remark="",e[t].shopId=s)}))}catch(s){}return e})),V=s((()=>{let e=0;return Object.values(f.value).forEach((s=>{s.items.forEach((s=>{e+=s.count}))})),e}));function D(){g("SELECT_ADDRESS",(e=>{!async function(e={}){T.isEmpty(e)||(r.addressInfo=e);await H()}(e.addressInfo)})),console.log(r.orderPayload.spuType),r.orderPayload.spuType?_.$router.go("/pages/user/address/list"):_.$router.go("/pages/user/dummyAddress/list")}async function R(e){null==e&&(e=0);const s=r.currentTotalPrice;r.orderInfo.price.payPrice=100*(s-e),r.usedPoint=e,r.showPoints=!1}function U(){r.addressInfo.id?r.usedPoint>r.currentMemberPoints?_.$helper.toast("可用积分不足"):async function(){const e=f.value,s={};Object.keys(e).forEach((t=>{const r=e[t];s[r.shopId]=r.remark}));const t=r.orderPayload.highPrecision?(r.orderInfo.price.virtualPayPrice/100).toFixed(4).slice(0,-2):r.usedPoint;console.log(t);const{code:o,data:a}=await b.createOrder({items:r.orderPayload.items,couponId:r.orderPayload.couponId,addressId:r.addressInfo.id,deliveryType:1==r.orderPayload.spuType?1:3,pointStatus:!1,combinationActivityId:r.orderPayload.combinationActivityId,combinationHeadId:r.orderPayload.combinationHeadId,seckillActivityId:r.orderPayload.seckillActivityId,payIntegral:t,shopRemarks:s});if(0!==o)return;r.orderPayload.items[0].cartId>0&&_.$store("cart").getList();_.$router.redirect("/pages/pay/index",{id:a.payOrderId})}():_.$helper.toast("请选择收货地址")}async function H(){const e=f.value;let s={};0!==Object.keys(e).length&&Object.keys(e).forEach((t=>{const r=e[t];s[t]=r.remark}));const{data:t,code:o}=await b.settlementOrder({items:r.orderPayload.items,couponId:r.orderPayload.couponId,addressId:r.addressInfo.id,deliveryType:1==r.orderPayload.spuType?1:3,pointStatus:!1,combinationActivityId:r.orderPayload.combinationActivityId,combinationHeadId:r.orderPayload.combinationHeadId,seckillActivityId:r.orderPayload.seckillActivityId,usedPoint:r.usedPoint,addressType:1==r.orderPayload.spuType?1:2});0===o&&(r.orderInfo=t,0!==Object.keys(s).length&&Object.keys(s).forEach((e=>{f.value[e].remark=s[e]})),r.orderInfo.address&&(r.addressInfo=r.orderInfo.address),r.currentMemberPoints=E(r.orderInfo.currentQuota),r.currentTotalPrice=A(r.orderInfo.price.payPrice),r.currentDeliveryPrice=A(r.orderInfo.price.deliveryPrice),2==r.orderPayload.spuPayType&&(r.usedPoint=r.currentTotalPrice-.01,console.log(r.spuType)))}return P((async e=>{e.data?(r.orderPayload=JSON.parse(e.data),await H()):_.$helper.toast("参数不正确,请检查!")})),(e,s)=>{const t=y,P=p,_=o(a("s-address-item"),M),b=o(a("s-goods-item"),O),g=o(a("uni-easyinput"),C),T=j,E=o(a("s-points-pop"),B),H=m,G=o(a("su-fixed"),N),L=o(a("s-layout"),S);return l(),d(L,{title:"确认订单"},{default:i((()=>[c(P,{class:"bg-white address-box ss-m-b-14 ss-r-b-10",onClick:D},{default:i((()=>[c(_,{item:r.addressInfo,spuType:r.orderPayload.spuType,hasBorderBottom:!1},{default:i((()=>[c(P,{class:"ss-rest-button"},{default:i((()=>[c(t,{class:"_icon-forward"})])),_:1})])),_:1},8,["item","spuType"])])),_:1}),(l(!0),h(v,null,x(f.value,((e,s)=>(l(),d(P,{class:"order-card-box ss-m-b-14",key:s},{default:i((()=>[c(P,{class:"title-text ss-p-x-20 ss-p-t-20"},{default:i((()=>[n(u(s),1)])),_:2},1024),(l(!0),h(v,null,x(e.items,(e=>{var s;return l(),d(b,{key:null==e?void 0:e.skuId,img:null==e?void 0:e.picUrl,title:null==e?void 0:e.spuName,skuText:null==(s=null==e?void 0:e.properties)?void 0:s.map((e=>e.valueName)).join(" "),price:e.highPrecisionPrice?null==e?void 0:e.highPrecisionPrice:null==e?void 0:e.price,num:null==e?void 0:e.count,virtualPirce:!!e.highPrecisionPrice},null,8,["img","title","skuText","price","num","virtualPirce"])})),128)),c(P,{class:"order-item ss-flex ss-col-center ss-row-between ss-p-x-20 bg-white ss-r-10"},{default:i((()=>[c(P,{class:"item-title"},{default:i((()=>[n("运费")])),_:1}),c(P,{class:"ss-flex ss-col-center"},{default:i((()=>[n(u(e.price.deliveryPrice?"¥"+I(A)(e.price.deliveryPrice):"包邮"),1)])),_:2},1024)])),_:2},1024),c(P,{class:"order-item ss-flex ss-col-center ss-row-between ss-p-x-20 bg-white ss-r-10"},{default:i((()=>[c(P,{class:"item-title"},{default:i((()=>[n("订单备注")])),_:1}),c(P,{class:"ss-flex ss-col-center"},{default:i((()=>[c(g,{maxlength:"20",placeholder:"建议留言前先与商家沟通",modelValue:e.remark,"onUpdate:modelValue":s=>e.remark=s,inputBorder:!1,clearable:!1},null,8,["modelValue","onUpdate:modelValue"])])),_:2},1024)])),_:2},1024),0==r.orderPayload.spuType?(l(),d(P,{key:0,class:"order-item ss-flex ss-col-center ss-row-between ss-p-x-20 bg-white ss-r-10"},{default:i((()=>[c(P,{class:"item-title"},{default:i((()=>[n("数量")])),_:1}),c(P,{class:"ss-flex ss-col-center"},{default:i((()=>[n(u(V.value),1)])),_:1})])),_:1})):(l(),d(P,{key:1,class:"order-item ss-flex ss-col-center ss-row-between ss-p-x-20 bg-white ss-r-10"},{default:i((()=>[c(P,{class:"item-title"},{default:i((()=>[n("总价")])),_:1}),c(P,{class:"ss-flex ss-col-center"},{default:i((()=>[2==r.orderPayload.spuPayType?(l(),d(T,{key:0,src:$,style:{width:"30rpx",height:"30rpx"}})):(l(),d(t,{key:1},{default:i((()=>[n("¥")])),_:1})),n(" "+u(I(A)(e.price.payPrice)),1)])),_:2},1024)])),_:2},1024))])),_:2},1024)))),128)),c(P,{class:"bg-white total-card-box ss-p-20 ss-m-b-14 ss-r-10"},{default:i((()=>[c(P,{class:"title-text"},{default:i((()=>[n(" 价格明细 ")])),_:1}),c(P,{class:"total-box-content border-bottom"},{default:i((()=>[c(P,{class:"order-item ss-flex ss-col-center ss-row-between"},{default:i((()=>[c(P,{class:"item-title"},{default:i((()=>[n("商品总价 共"+u(V.value)+"件商品",1)])),_:1}),c(P,{class:"ss-flex ss-col-center"},{default:i((()=>[c(t,{class:"item-value ss-m-r-24"},{default:i((()=>[2==r.orderPayload.spuPayType?(l(),d(T,{key:0,src:$,style:{width:"30rpx",height:"30rpx"}})):(l(),d(t,{key:1},{default:i((()=>[n("¥")])),_:1})),r.orderPayload.highPrecision?(l(),d(t,{key:2},{default:i((()=>[n(u(I(F)(r.orderInfo.price.virtualTotalPrice)),1)])),_:1})):(l(),d(t,{key:3},{default:i((()=>[n(u(I(A)(r.orderInfo.price.totalPrice)),1)])),_:1}))])),_:1})])),_:1})])),_:1}),c(P,{class:"order-item ss-flex ss-col-center ss-row-between"},{default:i((()=>[c(P,{class:"item-title"},{default:i((()=>[n("运费")])),_:1}),c(P,{class:"ss-flex ss-col-center"},{default:i((()=>[c(t,{class:"item-value ss-m-r-24"},{default:i((()=>[2==r.orderPayload.spuPayType?(l(),d(T,{key:0,src:$,style:{width:"30rpx",height:"30rpx"}})):(l(),d(t,{key:1},{default:i((()=>[n("¥")])),_:1})),n(" "+u(I(A)(r.orderInfo.price.deliveryPrice)),1)])),_:1})])),_:1})])),_:1}),2!=r.orderPayload.spuPayType?(l(),d(P,{key:0,class:"order-item ss-flex ss-col-center ss-row-between"},{default:i((()=>[c(P,{class:"item-title"},{default:i((()=>[n("积分抵扣")])),_:1}),c(P,{class:"ss-flex ss-col-center",onClick:s[0]||(s[0]=e=>r.showPoints=!0)},{default:i((()=>[c(t,{class:w(["item-value",r.usedPoint>0?"text-red":"text-disabled"])},{default:i((()=>[n(u(r.usedPoint>0?" 可抵扣"+r.usedPoint+"元":"不使用积分"),1)])),_:1},8,["class"]),c(t,{class:"_icon-forward item-icon"})])),_:1})])),_:1})):k("",!0)])),_:1}),c(P,{class:"total-box-footer ss-font-28 ss-flex ss-row-right ss-col-center ss-m-r-28"},{default:i((()=>[c(P,{class:"total-num ss-m-r-20"},{default:i((()=>[n(" 共"+u(V.value)+"件 ",1)])),_:1}),c(P,null,{default:i((()=>[n("合计:")])),_:1}),c(P,{class:"total-num text-red ss-flex"},{default:i((()=>[2==r.orderPayload.spuPayType?(l(),d(T,{key:0,src:$,class:"ss-m-r-10",style:{width:"30rpx",height:"30rpx"}})):(l(),d(t,{key:1},{default:i((()=>[n("¥")])),_:1})),r.orderPayload.highPrecision?(l(),d(t,{key:2},{default:i((()=>[n(u(I(F)(r.orderInfo.price.virtualTotalPrice)),1)])),_:1})):2==r.orderPayload.spuPayType?(l(),d(t,{key:3},{default:i((()=>[n(u(I(A)(r.orderInfo.price.payPrice)-.01),1)])),_:1})):(l(),d(t,{key:4},{default:i((()=>[n(u(I(A)(r.orderInfo.price.payPrice)),1)])),_:1}))])),_:1})])),_:1})])),_:1}),c(E,{modelValue:r.couponInfo,"onUpdate:modelValue":s[1]||(s[1]=e=>r.couponInfo=e),currentMemberPoints:r.currentMemberPoints,currentTotalPrice:r.currentTotalPrice,currentDeliveryPrice:r.currentDeliveryPrice,show:r.showPoints,onConfirm:R,onClose:s[2]||(s[2]=e=>r.showPoints=!1)},null,8,["modelValue","currentMemberPoints","currentTotalPrice","currentDeliveryPrice","show"]),c(G,{bottom:"",opacity:!1,bg:"bg-white",placeholder:"",noFixed:!1,index:200},{default:i((()=>[c(P,{class:"footer-box border-top ss-flex ss-row-between ss-p-x-20 ss-col-center"},{default:i((()=>[c(P,{class:"total-box-footer ss-flex ss-col-center"},{default:i((()=>[r.orderPayload.highPrecision?(l(),d(P,{key:0},{default:i((()=>[2==r.orderPayload.spuPayType?(l(),d(T,{key:0,src:$,style:{width:"30rpx",height:"30rpx"}})):k("",!0),n(" "+u(I(F)(r.orderInfo.price.virtualPayPrice)-.01)+" ¥0.01 ",1)])),_:1})):2==r.orderPayload.spuPayType?(l(),d(P,{key:1,class:"total-num ss-font-30 text-red"},{default:i((()=>[2==r.orderPayload.spuPayType?(l(),d(T,{key:0,src:$,style:{width:"30rpx",height:"30rpx"}})):k("",!0),n(" "+u(r.usedPoint)+" ¥0.01 ",1)])),_:1})):(l(),d(P,{key:2,class:"total-num ss-font-30 text-red"},{default:i((()=>[n(" ¥"+u(I(A)(r.orderInfo.price.payPrice)),1)])),_:1}))])),_:1}),c(H,{class:"ss-reset-button ui-BG-Main-Gradient ss-r-40 submit-btn ui-Shadow-Main",onClick:U},{default:i((()=>[n(" 提交订单 ")])),_:1})])),_:1})])),_:1})])),_:1})}}},[["__scopeId","data-v-850111cb"]]);export{R as default};