"use strict";const e=require("../../../common/vendor.js"),r=require("../../index.js"),o=require("../../api/promotion/coupon.js"),t=require("../../util/const.js"),i=require("../../util/index.js");if(require("../../url/index.js"),require("../../store/index.js"),require("../../store/app.js"),require("../../api/promotion/diy.js"),require("../../request/index.js"),require("../../config/index.js"),require("../../platform/index.js"),require("../../platform/provider/wechat/index.js"),require("../../platform/provider/wechat/miniProgram.js"),require("../../api/member/auth.js"),require("../../api/member/social.js"),require("../../api/member/user.js"),require("../../platform/provider/apple/index.js"),require("../../platform/share.js"),require("../../router/index.js"),require("../../hooks/useModal.js"),require("../../helper/index.js"),require("../../helper/test.js"),require("../../helper/digit.js"),require("../../api/member/signin.js"),require("../../helper/throttle.js"),require("../../platform/pay.js"),require("../../api/pay/order.js"),require("../../store/user.js"),require("../../store/cart.js"),require("../../api/trade/cart.js"),require("../../api/pay/wallet.js"),require("../../api/trade/order.js"),require("../../store/sys.js"),require("../../store/modal.js"),require("../../config/zIndex.js"),!Array){e.resolveComponent("su-coupon")()}Math;const s={__name:"s-coupon-block",props:{data:{type:Object,default:()=>({})},styles:{type:Object,default:()=>({})}},setup(s){const u=s,{columns:a,button:n}=u.data,p=["lg","md","xs"],d={background:`url(${r.sheep.$url.cdn(u.data.bgImg)}) no-repeat top center / 100% 100%`},c={background:n.bgColor,color:n.color},l=e=>e.discountType===t.PromotionDiscountTypeEnum.PRICE.type?i.floatToFixed2(e.discountPrice):e.discountType===t.PromotionDiscountTypeEnum.PERCENT.type?e.discountPercent:`未知【${e.discountType}】`,m=e.ref([]);async function y(r){const{error:t,msg:i}=await o.CouponApi.takeCoupon(r);0!==t?await j():e.index.showToast({title:i,icon:"none"})}const j=async()=>{const{data:e}=await o.CouponApi.getCouponTemplateListByIds(u.data.couponIds.join(","));m.value=e};return e.onMounted((()=>{j()})),(r,o)=>({a:e.f(m.value,((r,o,u)=>{return e.e(2===e.unref(a)?{a:e.o((e=>y(r.id)),o),b:e.s(c)}:{c:e.s(c),d:e.o((e=>y(r.id)),o)},{e:"8f010012-0-"+u,f:e.p({size:p[e.unref(a)-1],textColor:s.data.textColor,background:"",couponId:r.id,title:r.name,type:(d=r,d.discountType===t.PromotionDiscountTypeEnum.PRICE.type?"reduce":d.discountType===t.PromotionDiscountTypeEnum.PERCENT.type?"percent":`未知【${d.discountType}】`),value:l(r),sellBy:(n=r,n.validityType===t.CouponTemplateValidityTypeEnum.DATE.type?`${i.formatDate(n.validStartTime)} 至 ${i.formatDate(n.validEndTime)}`:n.validityType===t.CouponTemplateValidityTypeEnum.TERM.type?`领取后第 ${n.fixedStartTerm} - ${n.fixedEndTerm} 天内可用`:"未知【"+n.validityType+"】")}),g:o});var n,d})),b:2===e.unref(a),c:e.s(d),d:e.s({marginLeft:`${s.data.space}px`})})}},u=e._export_sfc(s,[["__scopeId","data-v-8f010012"]]);wx.createComponent(u);
