packageOrderPay.js 5.2 KB

1
  1. "use strict";var e=require("../common/vendor.js"),o=require("../api/common.js"),s=require("../api/userAddress.js"),t=require("../api/user.js"),a=require("../api/package.js"),d=require("../api/packageOrder.js");require("../common/request.js");const r={data:()=>({giftPrice:0,payTypes:[],addressId:null,wxPay:!0,address:null,orderId:null,order:null,items:null,payType:"1",couponText:"请选择优惠券",userCouponId:0,coupons:[],couponShow:!1,payMoney:0,discountMoney:0,payRemain:0,payDelivery:0,payPrice:0,gifts:[]}),onLoad(o){this.orderId=o.orderId;var s=this;e.index.$on("updateAddress",(e=>{s.addressId=e.addressId,s.address=e,s.address.address=e.province+e.city+e.district+e.detail})),this.getAddressByDefault()},onShow(){this.getPackageOrderById(),this.getPackageById(),this.getConfigByKey()},methods:{getAddressByDefault(){s.getAddressByDefault().then((o=>{200==o.code?null!=o.data&&(this.addressId=o.data.addressId,this.address=o.data,this.address.address=o.data.province+o.data.city+o.data.district+o.data.detail):e.index.showToast({icon:"none",title:o.msg})}),(e=>{}))},getConfigByKey(){o.getConfigByKey({key:"his.package"}).then((e=>{200==e.code&&(this.giftPrice=JSON.parse(e.data).giftPrice,console.log(this.giftPrice))}),(e=>{}))},checkPayType(e){var o=!1;return this.payTypes.forEach((function(s,t,a){s.toString()==e.toString()&&(o=!0)})),o},payTypeChange(e){console.log(e.detail.value),this.payType=e.detail.value,this.compute()},couponSelect(e){this.couponShow=!1,this.userCouponId=e.id,console.log(e),this.couponText=e.price+"元优惠券",this.compute()},open(){},close(){this.couponShow=!1},openCoupon(){this.couponShow=!0},delCoupon(){this.userCouponId=0,this.couponText="请选择优惠券",this.compute()},compute(){var o={payType:this.payType,orderId:this.orderId,userCouponId:this.userCouponId,companyId:this.companyId,companyUserId:this.companyUserId};console.log(o),d.compute(o).then((o=>{200==o.code?(this.payPrice=o.moneys.payPrice.toFixed(2),this.payMoney=o.moneys.payMoney.toFixed(2),this.discountMoney=o.moneys.discountMoney.toFixed(2),this.payDelivery=o.moneys.payDelivery.toFixed(2),this.payRemain=o.moneys.payRemain.toFixed(2),this.gifts=o.moneys.gifts):(this.payType=1,this.compute(),this.userCouponId=0,this.couponText="请选择优惠券",e.index.showToast({icon:"none",title:o.msg}))}),(e=>{}))},getMyEnableCouponList(){var e={};0==this.package.isShow?(e.couponType=5,e.cateId=this.package.privateType):1==this.package.isShow&&(e.couponType=6,e.cateId=this.package.diseaseType),t.getMyEnableCouponList(e).then((e=>{200==e.code&&(this.coupons=e.data)}),(e=>{}))},getPackageOrderById(){var e={orderId:this.orderId};console.log(e),d.getPackageOrderById(e).then((e=>{200==e.code&&(this.order=e.order,this.compute(),this.getPackageById(this.order.packageId))}),(e=>{}))},getPackageById(e){var o={packageId:e};a.getPackageById(o).then((e=>{200==e.code&&(this.package=e.data,this.payTypes=e.data.payType.split(","),console.log(this.payTypes),this.getMyEnableCouponList())}),(e=>{}))},openAddress(){e.index.navigateTo({url:"/pages_user/address"})},payOrder(){var o={payType:this.payType,userCouponId:this.userCouponId,addressId:this.addressId,remark:this.order.remark,orderId:this.order.orderId};e.index.showLoading(),d.pay(o).then((o=>{200==o.code?e.index.redirectTo({url:"./packagePayment?orderId="+this.orderId}):e.index.showToast({icon:"none",title:o.msg})}),(e=>{}))}}};if(!Array){e.resolveComponent("u-popup")()}Math;var n=e._export_sfc(r,[["render",function(o,s,t,a,d,r){return e.e({a:null==d.address},null==d.address?{b:e.o((e=>r.openAddress()))}:{},{c:null!=d.address},null!=d.address?e.e({d:e.t(d.address.realName),e:null!=d.address.phone},null!=d.address.phone?{f:e.t(d.address.phone)}:{},{g:e.t(d.address.address),h:e.o((e=>r.openAddress()))}):{},{i:e.t(d.payPrice),j:null!=d.order&&(null==d.order.userCouponId||0==d.order.userCouponId)},null==d.order||null!=d.order.userCouponId&&0!=d.order.userCouponId?{}:e.e({k:e.t(d.couponText),l:0!=d.userCouponId},0!=d.userCouponId?{m:e.o((e=>r.delCoupon()))}:{},{n:e.o((e=>r.openCoupon()))}),{o:e.t(d.discountMoney),p:e.t(d.payMoney),q:e.t(d.payRemain),r:e.t(d.payDelivery),s:r.checkPayType("1")},r.checkPayType("1")?{t:"1"==d.payType}:{},{v:r.checkPayType("2")},r.checkPayType("2")?{w:"2"==d.payType}:{},{x:r.checkPayType("3")},r.checkPayType("3")?{y:"3"==d.payType}:{},{z:e.o(((...e)=>r.payTypeChange&&r.payTypeChange(...e))),A:d.gifts.length>0},d.gifts.length>0?{B:e.f(d.gifts,((o,s,t)=>({a:o.image,b:e.t(o.productName),c:e.t(o.sku),d:e.t(o.price.toFixed(2)),e:e.t(o.count)})))}:{},{C:null!=d.order},null!=d.order?{D:d.order.remark,E:e.o((e=>d.order.remark=e.detail.value))}:{},{F:d.coupons.length>0},d.coupons.length>0?{G:e.f(d.coupons,((o,s,t)=>e.e({a:0==o.status},(o.status,{}),{b:0!=o.status},(o.status,{}),{c:e.t(o.price.toFixed(2)),d:e.t(o.minPrice.toFixed(2)),e:e.t(o.title),f:0==o.status||2==o.status},0==o.status||2==o.status?{g:e.t(o.limitTime)}:{},{h:1==o.status},1==o.status?{i:e.t(o.useTime)}:{},{j:1==o.status},(o.status,{}),{k:2==o.status},(o.status,{}),{l:0==o.status},(o.status,{}),{m:e.o((e=>r.couponSelect(o)))})))}:{},{H:0==d.coupons.length},(d.coupons.length,{}),{I:e.o(r.close),J:e.o(r.open),K:e.p({closeable:!0,show:d.couponShow,round:10,mode:"bottom"}),L:null!=d.order},null!=d.order?{M:e.t(d.payMoney),N:e.o((e=>r.payOrder()))}:{})}]]);wx.createPage(n);