2 lines
3.8 KiB
JavaScript
2 lines
3.8 KiB
JavaScript
"use strict";var t=(t,o,e)=>new Promise(((d,a)=>{var i=t=>{try{r(e.next(t))}catch(o){a(o)}},s=t=>{try{r(e.throw(t))}catch(o){a(o)}},r=t=>t.done?d(t.value):Promise.resolve(t.value).then(i,s);r((e=e.apply(t,o)).next())}));const o=require("../../../common/vendor.js"),e=require("../../index.js"),d=require("../../api/product/spu.js");if(!Array){o.resolveComponent("s-goods-column")()}Math;const a={__name:"s-goods-card",props:{data:{type:Object,default(){}},styles:{type:Object,default(){}}},setup(a){var i,s;const r="oneColBigImg",l="twoCol",n="oneColSmallImg",u=o.reactive({goodsList:[],leftGoodsList:[],rightGoodsList:[]}),g=a,{layoutType:p,btnBuy:f,spuIds:c}=null!=(i=g.data)?i:{},{marginLeft:m,marginRight:h}=null!=(s=g.styles)?s:{},b=o.computed((()=>"text"===f.type?{background:`linear-gradient(to right, ${f.bgBeginColor}, ${f.bgEndColor})`}:"img"===f.type?{width:"54rpx",height:"54rpx",background:`url(${e.sheep.$url.cdn(f.imgUrl)}) no-repeat`,backgroundSize:"100% 100%"}:void 0));let x=0,y=0,v=0;function L(t=0,o="left"){u.goodsList[x]&&("left"===o&&(y+=t),"right"===o&&(v+=t),y<=v?u.leftGoodsList.push(u.goodsList[x]):u.rightGoodsList.push(u.goodsList[x]),x++)}return o.onMounted((()=>t(this,null,(function*(){u.goodsList=yield function(o){return t(this,null,(function*(){const{data:t}=yield d.SpuApi.getSpuListByIds(o);return t}))}(c.join(",")),p===l&&L()})))),(t,d)=>o.e({a:o.unref(p)===r&&u.goodsList.length},o.unref(p)===r&&u.goodsList.length?{b:o.f(u.goodsList,((t,d,i)=>{var s;return{a:o.o((d=>o.unref(e.sheep).$router.go("/modules/mall/goods/index",{id:t.id})),t.id),b:"54657914-0-"+i,c:o.p({size:"sl",goodsFields:a.data.fields,tagStyle:a.data.badge,data:t,titleColor:null==(s=a.data.fields.name)?void 0:s.color,subTitleColor:a.data.fields.introduction.color,topRadius:a.data.borderRadiusTop,bottomRadius:a.data.borderRadiusBottom}),d:t.id}})),c:o.t("text"===o.unref(f).type?o.unref(f).text:""),d:o.s(b.value),e:o.s({marginBottom:2*a.data.space+"rpx"})}:{},{f:o.unref(p)===l&&u.goodsList.length},o.unref(p)===l&&u.goodsList.length?{g:o.f(u.leftGoodsList,((t,d,i)=>{var s;return{a:o.o((d=>o.unref(e.sheep).$router.go("/modules/mall/goods/index",{id:t.id})),t.id),b:o.o((t=>L(t,"left")),t.id),c:"54657914-1-"+i,d:o.p({size:"md",goodsFields:a.data.fields,tagStyle:a.data.badge,data:t,titleColor:null==(s=a.data.fields.name)?void 0:s.color,subTitleColor:a.data.fields.introduction.color,topRadius:a.data.borderRadiusTop,bottomRadius:a.data.borderRadiusBottom,titleWidth:330-o.unref(m)-o.unref(h)}),e:t.id}})),h:o.t("text"===o.unref(f).type?o.unref(f).text:""),i:o.s(b.value),j:o.s({paddingRight:a.data.space+"rpx",marginBottom:a.data.space+"px"}),k:o.f(u.rightGoodsList,((t,d,i)=>{var s;return{a:o.o((d=>o.unref(e.sheep).$router.go("/modules/mall/goods/index",{id:t.id})),t.id),b:o.o((t=>L(t,"right")),t.id),c:"54657914-2-"+i,d:o.p({size:"md",goodsFields:a.data.fields,tagStyle:a.data.badge,data:t,titleColor:null==(s=a.data.fields.name)?void 0:s.color,subTitleColor:a.data.fields.introduction.color,topRadius:a.data.borderRadiusTop,bottomRadius:a.data.borderRadiusBottom,titleWidth:330-o.unref(m)-o.unref(h)}),e:t.id}})),l:o.t("text"===o.unref(f).type?o.unref(f).text:""),m:o.s(b.value),n:o.s({paddingLeft:a.data.space+"rpx",marginBottom:a.data.space+"px"})}:{},{o:o.unref(p)===n&&u.goodsList.length},o.unref(p)===n&&u.goodsList.length?{p:o.f(u.goodsList,((t,d,i)=>{var s;return{a:o.o((d=>o.unref(e.sheep).$router.go("/modules/mall/goods/index",{id:t.id})),t.id),b:"54657914-3-"+i,c:o.p({size:"lg",goodsFields:a.data.fields,data:t,tagStyle:a.data.badge,titleColor:null==(s=a.data.fields.name)?void 0:s.color,subTitleColor:a.data.fields.introduction.color,topRadius:a.data.borderRadiusTop,bottomRadius:a.data.borderRadiusBottom}),d:t.id}})),q:o.t("text"===o.unref(f).type?o.unref(f).text:""),r:o.s(b.value),s:o.s({marginBottom:a.data.space+"px"})}:{})}},i=o._export_sfc(a,[["__scopeId","data-v-54657914"]]);wx.createComponent(i);
|