2 lines
2.5 KiB
JavaScript
2 lines
2.5 KiB
JavaScript
"use strict";const e=require("../../../common/vendor.js"),t=require("../../index.js"),o=require("../../api/promotion/seckill.js"),a=require("../../api/product/spu.js");if(!Array){e.resolveComponent("s-goods-column")()}Math;const r={__name:"s-seckill-block",props:{data:{type:Object,default:()=>({})},styles:{type:Object,default:()=>({})}},setup(r){const d=r,i=e.reactive({price:{show:!0},stock:{show:!0},name:{show:!0},introduction:{show:!0},marketPrice:{show:!0},salesCount:{show:!0}}),{layoutType:l,badge:s,btnBuy:n,space:u}=d.data;d.styles;const c=e.computed((()=>{const e=d.data.btnBuy;return"text"===(null==e?void 0:e.type)?{background:`linear-gradient(to right, ${e.bgBeginColor}, ${e.bgEndColor})`}:"img"===(null==e?void 0:e.type)?{width:"54rpx",height:"54rpx",background:`url(${t.sheep.$url.cdn(e.imgUrl)}) no-repeat`,backgroundSize:"100% 100%"}:void 0})),p=e.ref([]);return e.onMounted((()=>{return e=this,t=null,r=function*(){const{data:e}=yield o.SeckillApi.getSeckillActivity(d.data.activityId),{data:t}=yield a.SpuApi.getSpuDetail(e.spuId);e.products.forEach((e=>{t.price=Math.min(t.price,e.seckillPrice)})),t.stock=e.stock,t.salesCount=e.totalStock-e.stock,p.value=[t]},new Promise(((o,a)=>{var d=e=>{try{l(r.next(e))}catch(t){a(t)}},i=e=>{try{l(r.throw(e))}catch(t){a(t)}},l=e=>e.done?o(e.value):Promise.resolve(e.value).then(d,i);l((r=r.apply(e,t)).next())}));var e,t,r})),(o,a)=>{var g;return e.e({a:"threeCol"===e.unref(l)},"threeCol"===e.unref(l)?{b:e.f(p.value,((o,a,l)=>{var n;return{a:e.o((o=>e.unref(t.sheep).$router.go("/modules/mall/goods/seckill",{id:d.data.activityId})),o.id),b:"a2b9f0d4-0-"+l,c:e.p({size:"sm",goodsFields:i,tagStyle:e.unref(s),data:o,titleColor:null==(n=r.data.fields.name)?void 0:n.color,topRadius:r.data.borderRadiusTop,bottomRadius:r.data.borderRadiusBottom}),d:o.id}})),c:e.s({padding:r.data.space+"rpx"}),d:e.s({margin:"-"+r.data.space+"rpx"})}:{},{e:"oneCol"===e.unref(l)},"oneCol"===e.unref(l)?{f:e.f(p.value,((o,a,l)=>{var n,u;return{a:e.o((o=>e.unref(t.sheep).$router.go("/modules/mall/goods/seckill",{id:d.data.activityId})),a),b:"a2b9f0d4-1-"+l,c:e.p({size:"lg",goodsFields:i,seckillTag:!0,tagStyle:e.unref(s),data:o,titleColor:null==(n=r.data.fields.name)?void 0:n.color,subTitleColor:null==(u=r.data.fields.introduction)?void 0:u.color,topRadius:r.data.borderRadiusTop,bottomRadius:r.data.borderRadiusBottom}),d:a}})),g:e.t("text"===(null==(g=e.unref(n))?void 0:g.type)?e.unref(n).text:"立即秒杀"),h:e.s(c.value),i:e.s({marginBottom:e.unref(u)+"px"})}:{})}}},d=e._export_sfc(r,[["__scopeId","data-v-a2b9f0d4"]]);wx.createComponent(d);
|