acdr-ui/dist/build/mp-weixin/modules/mall/order/confirm.js

2 lines
6.6 KiB
JavaScript
Raw Normal View History

2024-09-19 07:20:14 +08:00
"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((