159 lines
5.5 KiB
JavaScript
159 lines
5.5 KiB
JavaScript
|
"use strict";
|
||
|
var __async = (__this, __arguments, generator) => {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
var fulfilled = (value) => {
|
||
|
try {
|
||
|
step(generator.next(value));
|
||
|
} catch (e) {
|
||
|
reject(e);
|
||
|
}
|
||
|
};
|
||
|
var rejected = (value) => {
|
||
|
try {
|
||
|
step(generator.throw(value));
|
||
|
} catch (e) {
|
||
|
reject(e);
|
||
|
}
|
||
|
};
|
||
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
||
|
step((generator = generator.apply(__this, __arguments)).next());
|
||
|
});
|
||
|
};
|
||
|
const common_vendor = require("../../../common/vendor.js");
|
||
|
const sheep_index = require("../../index.js");
|
||
|
const sheep_api_promotion_seckill = require("../../api/promotion/seckill.js");
|
||
|
const sheep_api_product_spu = require("../../api/product/spu.js");
|
||
|
if (!Array) {
|
||
|
const _easycom_s_goods_column2 = common_vendor.resolveComponent("s-goods-column");
|
||
|
_easycom_s_goods_column2();
|
||
|
}
|
||
|
const _easycom_s_goods_column = () => "../s-goods-column/s-goods-column.js";
|
||
|
if (!Math) {
|
||
|
_easycom_s_goods_column();
|
||
|
}
|
||
|
const _sfc_main = {
|
||
|
__name: "s-seckill-block",
|
||
|
props: {
|
||
|
// 装修数据
|
||
|
data: {
|
||
|
type: Object,
|
||
|
default: () => ({})
|
||
|
},
|
||
|
// 装修样式
|
||
|
styles: {
|
||
|
type: Object,
|
||
|
default: () => ({})
|
||
|
}
|
||
|
},
|
||
|
setup(__props) {
|
||
|
const props = __props;
|
||
|
const goodsFields = common_vendor.reactive({
|
||
|
// 商品价格
|
||
|
price: { show: true },
|
||
|
// 库存
|
||
|
stock: { show: true },
|
||
|
// 商品名称
|
||
|
name: { show: true },
|
||
|
// 商品介绍
|
||
|
introduction: { show: true },
|
||
|
// 市场价
|
||
|
marketPrice: { show: true },
|
||
|
// 销量
|
||
|
salesCount: { show: true }
|
||
|
});
|
||
|
const { layoutType, badge, btnBuy, space } = props.data;
|
||
|
props.styles;
|
||
|
const buyStyle = common_vendor.computed(() => {
|
||
|
const btnBuy2 = props.data.btnBuy;
|
||
|
if ((btnBuy2 == null ? void 0 : btnBuy2.type) === "text") {
|
||
|
return {
|
||
|
background: `linear-gradient(to right, ${btnBuy2.bgBeginColor}, ${btnBuy2.bgEndColor})`
|
||
|
};
|
||
|
}
|
||
|
if ((btnBuy2 == null ? void 0 : btnBuy2.type) === "img") {
|
||
|
return {
|
||
|
width: "54rpx",
|
||
|
height: "54rpx",
|
||
|
background: `url(${sheep_index.sheep.$url.cdn(btnBuy2.imgUrl)}) no-repeat`,
|
||
|
backgroundSize: "100% 100%"
|
||
|
};
|
||
|
}
|
||
|
});
|
||
|
const productList = common_vendor.ref([]);
|
||
|
common_vendor.onMounted(() => __async(this, null, function* () {
|
||
|
const { data: activity } = yield sheep_api_promotion_seckill.SeckillApi.getSeckillActivity(props.data.activityId);
|
||
|
const { data: spu } = yield sheep_api_product_spu.SpuApi.getSpuDetail(activity.spuId);
|
||
|
activity.products.forEach((product) => {
|
||
|
spu.price = Math.min(spu.price, product.seckillPrice);
|
||
|
});
|
||
|
spu.stock = activity.stock;
|
||
|
spu.salesCount = activity.totalStock - activity.stock;
|
||
|
productList.value = [spu];
|
||
|
}));
|
||
|
return (_ctx, _cache) => {
|
||
|
var _a;
|
||
|
return common_vendor.e({
|
||
|
a: common_vendor.unref(layoutType) === "threeCol"
|
||
|
}, common_vendor.unref(layoutType) === "threeCol" ? {
|
||
|
b: common_vendor.f(productList.value, (product, k0, i0) => {
|
||
|
var _a2;
|
||
|
return {
|
||
|
a: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/modules/mall/goods/seckill", {
|
||
|
id: props.data.activityId
|
||
|
}), product.id),
|
||
|
b: "e9825f2b-0-" + i0,
|
||
|
c: common_vendor.p({
|
||
|
size: "sm",
|
||
|
goodsFields,
|
||
|
tagStyle: common_vendor.unref(badge),
|
||
|
data: product,
|
||
|
titleColor: (_a2 = __props.data.fields.name) == null ? void 0 : _a2.color,
|
||
|
topRadius: __props.data.borderRadiusTop,
|
||
|
bottomRadius: __props.data.borderRadiusBottom
|
||
|
}),
|
||
|
d: product.id
|
||
|
};
|
||
|
}),
|
||
|
c: common_vendor.s({
|
||
|
padding: __props.data.space + "rpx"
|
||
|
}),
|
||
|
d: common_vendor.s({
|
||
|
margin: "-" + __props.data.space + "rpx"
|
||
|
})
|
||
|
} : {}, {
|
||
|
e: common_vendor.unref(layoutType) === "oneCol"
|
||
|
}, common_vendor.unref(layoutType) === "oneCol" ? {
|
||
|
f: common_vendor.f(productList.value, (product, index, i0) => {
|
||
|
var _a2, _b;
|
||
|
return {
|
||
|
a: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/modules/mall/goods/seckill", {
|
||
|
id: props.data.activityId
|
||
|
}), index),
|
||
|
b: "e9825f2b-1-" + i0,
|
||
|
c: common_vendor.p({
|
||
|
size: "lg",
|
||
|
goodsFields,
|
||
|
seckillTag: true,
|
||
|
tagStyle: common_vendor.unref(badge),
|
||
|
data: product,
|
||
|
titleColor: (_a2 = __props.data.fields.name) == null ? void 0 : _a2.color,
|
||
|
subTitleColor: (_b = __props.data.fields.introduction) == null ? void 0 : _b.color,
|
||
|
topRadius: __props.data.borderRadiusTop,
|
||
|
bottomRadius: __props.data.borderRadiusBottom
|
||
|
}),
|
||
|
d: index
|
||
|
};
|
||
|
}),
|
||
|
g: common_vendor.t(((_a = common_vendor.unref(btnBuy)) == null ? void 0 : _a.type) === "text" ? common_vendor.unref(btnBuy).text : "立即秒杀"),
|
||
|
h: common_vendor.s(buyStyle.value),
|
||
|
i: common_vendor.s({
|
||
|
marginBottom: common_vendor.unref(space) + "px"
|
||
|
})
|
||
|
} : {});
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-e9825f2b"]]);
|
||
|
wx.createComponent(Component);
|
||
|
//# sourceMappingURL=s-seckill-block.js.map
|