"use strict";var e=require("../common/vendor.js"),o=require("../api/user.js"),r=require("../api/storeOrder.js");require("../common/request.js");const s={data:()=>({addressId:null,wxPay:!0,address:null,orderId:null,order:null,items:null,couponText:"请选择优惠券",userCouponId:0,coupons:[],couponShow:!1,payMoney:0,discountMoney:0}),onLoad(o){this.orderId=o.orderId;var r=this;e.index.$on("updateAddress",(e=>{r.addressId=e.addressId,r.address=e,r.address.address=e.province+e.city+e.district+e.detail}))},onShow(){this.getStoreOrderById(),this.getMyEnableCouponList()},methods:{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={orderId:this.orderId,userCouponId:this.userCouponId};console.log(o),r.compute(o).then((o=>{200==o.code?(this.payMoney=o.data.payMoney,this.discountMoney=o.data.discountMoney):(this.userCouponId=0,this.couponText="请选择优惠券",e.index.showToast({icon:"none",title:o.msg}))}),(e=>{}))},getMyEnableCouponList(){o.getMyEnableCouponList({couponType:2}).then((e=>{200==e.code&&(this.coupons=e.data)}),(e=>{}))},getStoreOrderById(){var e={orderId:this.orderId};console.log(e),r.getStoreOrderById(e).then((e=>{200==e.code&&(this.order=e.order,this.items=e.items,null!=this.order.userName&&(this.address={realName:this.order.userName,phone:this.order.userPhone,address:this.order.userAddress}),this.compute())}),(e=>{}))},openAddress(){e.index.navigateTo({url:"/pages_user/address"})},payOrder(){var o={userCouponId:this.userCouponId,addressId:this.addressId,remark:this.order.remark,orderId:this.order.orderId},s=this;e.index.showLoading(),r.pay(o).then((o=>{200==o.code?e.index.redirectTo({url:"/pages_order/storeOrderPayment?orderId="+s.order.orderId}):e.index.showToast({icon:"none",title:o.msg})}),(e=>{}))}}};if(!Array){e.resolveComponent("u-popup")()}Math;var d=e._export_sfc(s,[["render",function(o,r,s,d,t,n){return e.e({a:null==t.address},null==t.address?{b:e.o((e=>n.openAddress()))}:{},{c:null!=t.address},null!=t.address?e.e({d:e.t(t.address.realName),e:null!=t.address.phone},null!=t.address.phone?{f:e.t(t.address.phone)}:{},{g:e.t(t.address.address),h:e.o((e=>n.openAddress()))}):{},{i:e.f(t.items,((o,r,s)=>e.e({a:""==JSON.parse(o.jsonInfo).image?"/static/images/drug.svg":JSON.parse(o.jsonInfo).image,b:e.t(JSON.parse(o.jsonInfo).productName),c:e.t(JSON.parse(o.jsonInfo).sku)},1==t.order.ordetType?{d:e.t(o.num)}:{},{e:r}))),j:1==t.order.ordetType,k:null!=t.order},null!=t.order?{l:e.t(t.order.totalPrice.toFixed(2))}:{},{m:null!=t.order},null!=t.order?{n:e.t(t.order.payPrice.toFixed(2))}:{},{o:null!=t.order&&(null==t.order.userCouponId||0==t.order.userCouponId)},null==t.order||null!=t.order.userCouponId&&0!=t.order.userCouponId?{}:e.e({p:e.t(t.couponText),q:0!=t.userCouponId},0!=t.userCouponId?{r:e.o((e=>n.delCoupon()))}:{},{s:e.o((e=>n.openCoupon()))}),{t:e.t(t.discountMoney.toFixed(2)),v:e.t(t.payMoney.toFixed(2)),w:t.wxPay,x:null!=t.order},null!=t.order?{y:t.order.remark,z:e.o((e=>t.order.remark=e.detail.value))}:{},{A:t.coupons.length>0},t.coupons.length>0?{B:e.f(t.coupons,((o,r,s)=>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=>n.couponSelect(o)))})))}:{},{C:0==t.coupons.length},(t.coupons.length,{}),{D:e.o(n.close),E:e.o(n.open),F:e.p({closeable:!0,show:t.couponShow,round:10,mode:"bottom"}),G:null!=t.order},null!=t.order?{H:e.t(t.payMoney.toFixed(2)),I:e.o((e=>n.payOrder()))}:{})}]]);s.__runtimeHooks=2,wx.createPage(d);
