acdr-ui/dist/dev/mp-weixin/modules/mall/sheep/components/s-image-cube/s-image-cube.js

69 lines
2.6 KiB
JavaScript
Raw Normal View History

2024-09-19 07:20:14 +08:00
"use strict";
2024-10-01 09:15:35 +08:00
const common_vendor = require("../../../../../common/vendor.js");
const modules_mall_sheep_index = require("../../index.js");
2024-09-19 07:20:14 +08:00
const _sfc_main = {
__name: "s-image-cube",
props: {
data: {
type: Object,
default() {
}
},
styles: {
type: Object,
default() {
}
}
},
setup(__props) {
const props = __props;
2024-10-01 09:15:35 +08:00
const windowWidth = modules_mall_sheep_index.sheep.$platform.device.windowWidth;
2024-09-19 07:20:14 +08:00
const cell = common_vendor.computed(() => {
return (windowWidth - ((props.styles.marginLeft || 0) + (props.styles.marginRight || 0) + (props.styles.padding || 0) * 2)) / 4;
});
const parseAdWrap = common_vendor.computed(() => {
var _a, _b, _c, _d;
const heightArr = props.data.list.reduce(
(prev, cur) => prev.includes(cur.height + cur.top) ? prev : [...prev, cur.height + cur.top],
[]
);
const heightMax = Math.max(...heightArr);
return {
height: heightMax * cell.value + "px",
width: windowWidth - (((_b = (_a = props.data) == null ? void 0 : _a.style) == null ? void 0 : _b.marginLeft) + ((_d = (_c = props.data) == null ? void 0 : _c.style) == null ? void 0 : _d.marginRight) + props.styles.padding * 2) * 2 + "px"
};
});
const parseImgStyle = (item) => {
const obj = {
width: item.width * cell.value - props.data.space + "px",
height: item.height * cell.value - props.data.space + "px",
left: item.left * cell.value + "px",
top: item.top * cell.value + "px",
"border-top-left-radius": props.data.borderRadiusTop + "px",
"border-top-right-radius": props.data.borderRadiusTop + "px",
"border-bottom-left-radius": props.data.borderRadiusBottom + "px",
"border-bottom-right-radius": props.data.borderRadiusBottom + "px"
};
return obj;
};
return (_ctx, _cache) => {
return {
a: common_vendor.f(__props.data.list, (item, index, i0) => {
return {
2024-10-01 09:15:35 +08:00
a: common_vendor.unref(modules_mall_sheep_index.sheep).$url.cdn(item.imgUrl),
2024-09-19 07:20:14 +08:00
b: common_vendor.s(parseImgStyle(item)),
2024-10-01 09:15:35 +08:00
c: common_vendor.o(($event) => common_vendor.unref(modules_mall_sheep_index.sheep).$router.go(item.url), index),
2024-09-19 07:20:14 +08:00
d: index
};
}),
b: common_vendor.s({
margin: __props.data.space + "px"
}),
c: common_vendor.s(parseAdWrap.value)
};
};
}
};
2024-10-01 09:15:35 +08:00
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-7028421f"]]);
2024-09-19 07:20:14 +08:00
wx.createComponent(Component);