"use strict";var e=(e,o,r)=>new Promise(((i,t)=>{var n=e=>{try{a(r.next(e))}catch(o){t(o)}},d=e=>{try{a(r.throw(e))}catch(o){t(o)}},a=e=>e.done?i(e.value):Promise.resolve(e.value).then(n,d);a((r=r.apply(e,o)).next())}));const o=require("../../../common/vendor.js"),r=require("../../../sheep/index.js"),i=require("../../../sheep/api/trade/order.js"),t=require("../../../sheep/api/promotion/coupon.js"),n=require("../../../sheep/hooks/useGoods.js");if(!Array){(o.resolveComponent("s-goods-item")+o.resolveComponent("uni-easyinput")+o.resolveComponent("s-coupon-select")+o.resolveComponent("s-discount-list")+o.resolveComponent("su-fixed")+o.resolveComponent("s-layout")+o.resolveComponent("layout-default-uni"))()}Math||(d+(()=>"../../../sheep/components/s-goods-item/s-goods-item.js")+(()=>"../../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js")+(()=>"../../../sheep/components/s-coupon-select/s-coupon-select.js")+(()=>"../../../sheep/components/s-discount-list/s-discount-list.js")+(()=>"../../../sheep/ui/su-fixed/su-fixed.js")+(()=>"../../../sheep/components/s-layout/s-layout.js"))();const d=()=>"./addressSelection.js",a={__name:"confirm",setup(d){const a=o.reactive({orderPayload:{},orderInfo:{items:[],price:{}},showCoupon:!1,couponInfo:[],showDiscount:!1,pointStatus:!1}),s=o.ref({addressInfo:{},deliveryType:1,isPickUp:!0,pickUpInfo:{},receiverName:"",receiverMobile:""}),l=()=>e(this,null,(function*(){a.pointStatus=!a.pointStatus,yield c()}));function p(o){return e(this,null,(function*(){a.orderPayload.couponId=o,yield c(),a.showCoupon=!1}))}function u(){if(1!==s.value.deliveryType||s.value.addressInfo.id){if(2===s.value.deliveryType){if(!s.value.pickUpInfo.id)return void r.sheep.$helper.toast("请选择自提门店地址");if(""===s.value.receiverName||""===s.value.receiverMobile)return void r.sheep.$helper.toast("请填写联系人或联系人电话");if(!/^[\u4e00-\u9fa5\w]{2,16}$/.test(s.value.receiverName))return void r.sheep.$helper.toast("请填写您的真实姓名");if(!/^1(3|4|5|7|8|9|6)\d{9}$/.test(s.value.receiverMobile))return void r.sheep.$helper.toast("请填写正确的手机号")}!function(){e(this,null,(function*(){const{code:e,data:o}=yield i.OrderApi.createOrder({items:a.orderPayload.items,couponId:a.orderPayload.couponId,remark:a.orderPayload.remark,deliveryType:s.value.deliveryType,addressId:s.value.addressInfo.id,pickUpStoreId:s.value.pickUpInfo.id,receiverName:s.value.receiverName,receiverMobile:s.value.receiverMobile,pointStatus:a.pointStatus,combinationActivityId:a.orderPayload.combinationActivityId,combinationHeadId:a.orderPayload.combinationHeadId,seckillActivityId:a.orderPayload.seckillActivityId});0===e&&(a.orderPayload.items[0].cartId>0&&r.sheep.$store("cart").getList(),r.sheep.$router.redirect("/modules/mall/pay/index",{id:o.payOrderId}))}))}()}else r.sheep.$helper.toast("请选择收货地址")}function c(){return e(this,null,(function*(){const{data:e,code:o}=yield i.OrderApi.settlementOrder({items:a.orderPayload.items,couponId:a.orderPayload.couponId,deliveryType:s.value.deliveryType,addressId:s.value.addressInfo.id,pickUpStoreId:s.value.pickUpInfo.id,receiverName:s.value.receiverName,receiverMobile:s.value.receiverMobile,pointStatus:a.pointStatus,combinationActivityId:a.orderPayload.combinationActivityId,combinationHeadId:a.orderPayload.combinationHeadId,seckillActivityId:a.orderPayload.seckillActivityId});0===o&&(a.orderInfo=e,a.orderInfo.address&&(s.value.addressInfo=a.orderInfo.address))}))}return o.onLoad((o=>e(this,null,(function*(){o.data?(a.orderPayload=JSON.parse(o.data),yield c(),yield function(){return e(this,null,(function*(){const{code:e,data:o}=yield t.CouponApi.getMatchCouponList(a.orderInfo.price.payPrice,a.orderInfo.items.map((e=>e.spuId)),a.orderPayload.items.map((e=>e.skuId)),a.orderPayload.items.map((e=>e.categoryId)));0===e&&(a.couponInfo=o)}))}()):r.sheep.$helper.toast("参数不正确,请检查!")})))),o.watch(s,((o,r)=>e(this,null,(function*(){o.addressInfo.id===r.addressInfo.id&&o.deliveryType===r.deliveryType||(yield c())})))),(e,i)=>o.e({a:o.o((e=>s.value=e)),b:o.p({modelValue:s.value}),c:o.f(a.orderInfo.items,((e,r,i)=>({a:e.skuId,b:"03d33d24-3-"+i+",03d33d24-1",c:o.p({img:e.picUrl,title:e.spuName,skuText:e.properties.map((e=>e.valueName)).join(" "),price:e.price,num:e.count,marginBottom:"10"})}))),d:o.o((e=>a.orderPayload.remark=e)),e:o.p({maxlength:"20",placeholder:"建议留言前先与商家沟通",inputBorder:!1,clearable:!1,modelValue:a.orderPayload.remark}),f:o.t(o.unref(n.fen2yuan)(a.orderInfo.price.totalPrice)),g:0===a.orderInfo.type},0===a.orderInfo.type?{h:o.t(a.pointStatus?"剩余积分":"当前积分"),i:o.unref(r.sheep).$url.static("/static/img/shop/goods/score1.svg"),j:o.t(a.pointStatus?a.orderInfo.totalPoint-a.orderInfo.usePoint:a.orderInfo.totalPoint||0),k:a.pointStatus,l:!a.orderInfo.totalPoint||a.orderInfo.totalPoint<=0,m:o.o(l)}:{},{n:1===s.value.deliveryType},1===s.value.deliveryType?o.e({o:a.orderInfo.price.deliveryPrice>0},a.orderInfo.price.deliveryPrice>0?{p:o.t(o.unref(n.fen2yuan)(a.orderInfo.price.deliveryPrice))}:{}):{},{q:2===s.value.deliveryType},2===s.value.deliveryType?{r:o.o((e=>s.value.receiverName=e)),s:o.p({maxlength:"20",placeholder:"请填写您的联系姓名",inputBorder:!1,clearable:!1,modelValue:s.value.receiverName})}:{},{t:2===s.value.deliveryType},2===s.value.deliveryType?{v:o.o((e=>s.value.receiverMobile=e)),w:o.p({maxlength:"20",placeholder:"请填写您的联系电话",inputBorder:!1,clearable:!1,modelValue:s.value.receiverMobile})}:{},{x:0===a.orderInfo.type},0===a.orderInfo.type?o.e({y:a.orderPayload.couponId>0},a.orderPayload.couponId>0?{z:o.t(o.unref(n.fen2yuan)(a.orderInfo.price.couponPrice))}:{A:o.t(a.couponInfo.length>0?a.couponInfo.length+" 张可用":"暂无可用优惠券"),B:o.n(a.couponInfo.length>0?"text-red":"text-disabled")},{C:o.o((e=>a.showCoupon=!0))}):{},{D:a.orderInfo.price.discountPrice>0},a.orderInfo.price.discountPrice>0?{E:o.t(o.unref(n.fen2yuan)(a.orderInfo.price.discountPrice))}:{},{F:a.orderInfo.price.vipPrice>0},a.orderInfo.price.vipPrice>0?{G:o.t(o.unref(n.fen2yuan)(a.orderInfo.price.vipPrice))}:{},{H:o.t(a.orderInfo.items.reduce(((e,o)=>e+o.count),0)),I:o.t(o.unref(n.fen2yuan)(a.orderInfo.price.payPrice)),J:o.o(p),K:o.o((e=>a.showCoupon=!1)),L:o.o((e=>a.couponInfo=e)),M:o.p({show:a.showCoupon,modelValue:a.couponInfo}),N:o.o((e=>a.showDiscount=!1)),O:o.o((e=>a.orderInfo=e)),P:o.p({show:a.showDiscount,modelValue:a.orderInfo}),Q:o.t(o.unref(n.fen2yuan)(a.orderInfo.price.payPrice)),R:o.o(u),S:o.p({bottom:!0,opacity:!1,bg:"bg-white",placeholder:!0,noFixed:!1,index:200}),T:o.p({title:"确认订单"})})}},s=o._export_sfc(a,[["__scopeId","data-v-03d33d24"]]);wx.createPage(s);