acdr-ui/dist/dev/mp-weixin/modules/mall/sheep/components/s-goods-column/s-goods-column.js
2024-10-01 09:15:35 +08:00

368 lines
18 KiB
JavaScript

"use strict";
const common_vendor = require("../../../../../common/vendor.js");
const modules_mall_sheep_index = require("../../index.js");
const modules_mall_sheep_hooks_useGoods = require("../../hooks/useGoods.js");
const _sfc_main = {
__name: "s-goods-column",
props: {
goodsFields: {
type: [Array, Object],
default() {
return {
// 商品价格
price: { show: true },
// 库存
stock: { show: true },
// 商品名称
name: { show: true },
// 商品介绍
introduction: { show: true },
// 市场价
marketPrice: { show: true },
// 销量
salesCount: { show: true }
};
}
},
tagStyle: {
type: Object,
default: {}
},
data: {
type: Object,
default: {}
},
size: {
type: String,
default: "sl"
},
background: {
type: String,
default: ""
},
topRadius: {
type: Number,
default: 0
},
bottomRadius: {
type: Number,
default: 0
},
titleWidth: {
type: Number,
default: 0
},
titleColor: {
type: String,
default: "#333"
},
priceColor: {
type: String,
default: ""
},
originPriceColor: {
type: String,
default: "#C4C4C4"
},
priceUnit: {
type: String,
default: "¥"
},
subTitleColor: {
type: String,
default: "#999999"
},
subTitleBackground: {
type: String,
default: ""
},
buttonShow: {
type: Boolean,
default: true
},
seckillTag: {
type: Boolean,
default: false
},
grouponTag: {
type: Boolean,
default: false
}
},
emits: ["click", "getHeight"],
setup(__props, { emit: __emit }) {
common_vendor.reactive({});
const props = __props;
const elStyles = common_vendor.computed(() => {
return {
background: props.background,
"border-top-left-radius": props.topRadius + "px",
"border-top-right-radius": props.topRadius + "px",
"border-bottom-left-radius": props.bottomRadius + "px",
"border-bottom-right-radius": props.bottomRadius + "px"
};
});
const salesAndStock = common_vendor.computed(() => {
var _a, _b;
const text = [];
if ((_a = props.goodsFields.salesCount) == null ? void 0 : _a.show) {
text.push(modules_mall_sheep_hooks_useGoods.formatSales(props.data.sales_show_type, props.data.salesCount));
}
if ((_b = props.goodsFields.stock) == null ? void 0 : _b.show) {
text.push(modules_mall_sheep_hooks_useGoods.formatStock(props.data.stock_show_type, props.data.stock));
}
return text.join(" | ");
});
const emits = __emit;
const onClick = () => {
emits("click");
};
const { proxy } = common_vendor.getCurrentInstance();
const elId = `sheep_${Math.ceil(Math.random() * 1e6).toString(36)}`;
function getGoodsPriceCardWH() {
if (props.size === "md") {
const view = common_vendor.index.createSelectorQuery().in(proxy);
view.select(`#${elId}`).fields({ size: true, scrollOffset: true });
view.exec((data) => {
let totalHeight = 0;
const goodsPriceCard = data[0];
if (props.data.image_wh) {
totalHeight = goodsPriceCard.width / props.data.image_wh.w * props.data.image_wh.h + goodsPriceCard.height;
} else {
totalHeight = goodsPriceCard.width;
}
emits("getHeight", totalHeight);
});
}
}
common_vendor.onMounted(() => {
common_vendor.nextTick$1(() => {
getGoodsPriceCardWH();
});
});
return (_ctx, _cache) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra;
return common_vendor.e({
a: __props.size === "xs"
}, __props.size === "xs" ? common_vendor.e({
b: __props.tagStyle.show
}, __props.tagStyle.show ? {
c: common_vendor.unref(modules_mall_sheep_index.sheep).$url.cdn(__props.tagStyle.src || __props.tagStyle.imgUrl)
} : {}, {
d: common_vendor.unref(modules_mall_sheep_index.sheep).$url.cdn(__props.data.image || __props.data.picUrl),
e: ((_a = __props.goodsFields.title) == null ? void 0 : _a.show) || ((_b = __props.goodsFields.name) == null ? void 0 : _b.show) || ((_c = __props.goodsFields.price) == null ? void 0 : _c.show)
}, ((_d = __props.goodsFields.title) == null ? void 0 : _d.show) || ((_e = __props.goodsFields.name) == null ? void 0 : _e.show) || ((_f = __props.goodsFields.price) == null ? void 0 : _f.show) ? common_vendor.e({
f: ((_g = __props.goodsFields.title) == null ? void 0 : _g.show) || ((_h = __props.goodsFields.name) == null ? void 0 : _h.show)
}, ((_i = __props.goodsFields.title) == null ? void 0 : _i.show) || ((_j = __props.goodsFields.name) == null ? void 0 : _j.show) ? {
g: common_vendor.t(__props.data.title || __props.data.name),
h: common_vendor.s({
color: __props.titleColor,
width: __props.titleWidth ? __props.titleWidth + "rpx" : ""
})
} : {}, {
i: (_k = __props.goodsFields.price) == null ? void 0 : _k.show
}, ((_l = __props.goodsFields.price) == null ? void 0 : _l.show) ? {
j: common_vendor.t(__props.priceUnit),
k: common_vendor.t(common_vendor.unref(common_vendor.isArray$1)(__props.data.price) ? common_vendor.unref(modules_mall_sheep_hooks_useGoods.fen2yuan)(__props.data.price[0]) : common_vendor.unref(modules_mall_sheep_hooks_useGoods.fen2yuan)(__props.data.price)),
l: common_vendor.s({
color: __props.goodsFields.price.color
})
} : {}) : {}, {
m: common_vendor.s(elStyles.value),
n: common_vendor.o(onClick)
}) : {}, {
o: __props.size === "sm"
}, __props.size === "sm" ? common_vendor.e({
p: __props.tagStyle.show
}, __props.tagStyle.show ? {
q: common_vendor.unref(modules_mall_sheep_index.sheep).$url.cdn(__props.tagStyle.src || __props.tagStyle.imgUrl)
} : {}, {
r: common_vendor.unref(modules_mall_sheep_index.sheep).$url.cdn(__props.data.image || __props.data.picUrl),
s: ((_m = __props.goodsFields.title) == null ? void 0 : _m.show) || ((_n = __props.goodsFields.name) == null ? void 0 : _n.show) || ((_o = __props.goodsFields.price) == null ? void 0 : _o.show)
}, ((_p = __props.goodsFields.title) == null ? void 0 : _p.show) || ((_q = __props.goodsFields.name) == null ? void 0 : _q.show) || ((_r = __props.goodsFields.price) == null ? void 0 : _r.show) ? common_vendor.e({
t: ((_s = __props.goodsFields.title) == null ? void 0 : _s.show) || ((_t = __props.goodsFields.name) == null ? void 0 : _t.show)
}, ((_u = __props.goodsFields.title) == null ? void 0 : _u.show) || ((_v = __props.goodsFields.name) == null ? void 0 : _v.show) ? {
v: common_vendor.t(__props.data.title || __props.data.name)
} : {}, {
w: (_w = __props.goodsFields.price) == null ? void 0 : _w.show
}, ((_x = __props.goodsFields.price) == null ? void 0 : _x.show) ? {
x: common_vendor.t(__props.priceUnit),
y: common_vendor.t(common_vendor.unref(common_vendor.isArray$1)(__props.data.price) ? common_vendor.unref(modules_mall_sheep_hooks_useGoods.fen2yuan)(__props.data.price[0]) : common_vendor.unref(modules_mall_sheep_hooks_useGoods.fen2yuan)(__props.data.price)),
z: common_vendor.s({
color: __props.goodsFields.price.color
})
} : {}, {
A: common_vendor.s({
color: __props.titleColor,
width: __props.titleWidth ? __props.titleWidth + "rpx" : ""
})
}) : {}, {
B: common_vendor.s(elStyles.value),
C: common_vendor.o(onClick)
}) : {}, {
D: __props.size === "md"
}, __props.size === "md" ? common_vendor.e({
E: __props.tagStyle.show
}, __props.tagStyle.show ? {
F: common_vendor.unref(modules_mall_sheep_index.sheep).$url.cdn(__props.tagStyle.src || __props.tagStyle.imgUrl)
} : {}, {
G: common_vendor.unref(modules_mall_sheep_index.sheep).$url.cdn(__props.data.image || __props.data.picUrl),
H: ((_y = __props.goodsFields.title) == null ? void 0 : _y.show) || ((_z = __props.goodsFields.name) == null ? void 0 : _z.show)
}, ((_A = __props.goodsFields.title) == null ? void 0 : _A.show) || ((_B = __props.goodsFields.name) == null ? void 0 : _B.show) ? {
I: common_vendor.t(__props.data.title || __props.data.name),
J: common_vendor.s({
color: __props.titleColor,
width: __props.titleWidth ? __props.titleWidth + "rpx" : ""
})
} : {}, {
K: ((_C = __props.goodsFields.subtitle) == null ? void 0 : _C.show) || ((_D = __props.goodsFields.introduction) == null ? void 0 : _D.show)
}, ((_E = __props.goodsFields.subtitle) == null ? void 0 : _E.show) || ((_F = __props.goodsFields.introduction) == null ? void 0 : _F.show) ? {
L: common_vendor.t(__props.data.subtitle || __props.data.introduction),
M: common_vendor.s({
color: __props.subTitleColor,
background: __props.subTitleBackground
})
} : {}, {
N: (_G = __props.data.promos) == null ? void 0 : _G.length
}, ((_H = __props.data.promos) == null ? void 0 : _H.length) ? {
O: common_vendor.f(__props.data.promos, (item, k0, i0) => {
return {
a: common_vendor.t(item.title),
b: item.id
};
})
} : {}, {
P: (_I = __props.goodsFields.price) == null ? void 0 : _I.show
}, ((_J = __props.goodsFields.price) == null ? void 0 : _J.show) ? {
Q: common_vendor.t(__props.priceUnit),
R: common_vendor.t(common_vendor.unref(common_vendor.isArray$1)(__props.data.price) ? common_vendor.unref(modules_mall_sheep_hooks_useGoods.fen2yuan)(__props.data.price[0]) : common_vendor.unref(modules_mall_sheep_hooks_useGoods.fen2yuan)(__props.data.price)),
S: common_vendor.s({
color: __props.goodsFields.price.color
})
} : {}, {
T: (((_K = __props.goodsFields.original_price) == null ? void 0 : _K.show) || ((_L = __props.goodsFields.marketPrice) == null ? void 0 : _L.show)) && (__props.data.original_price > 0 || __props.data.marketPrice > 0)
}, (((_M = __props.goodsFields.original_price) == null ? void 0 : _M.show) || ((_N = __props.goodsFields.marketPrice) == null ? void 0 : _N.show)) && (__props.data.original_price > 0 || __props.data.marketPrice > 0) ? {
U: common_vendor.t(__props.priceUnit),
V: common_vendor.t(common_vendor.unref(modules_mall_sheep_hooks_useGoods.fen2yuan)(__props.data.marketPrice)),
W: common_vendor.s({
color: __props.originPriceColor
})
} : {}, {
X: common_vendor.t(salesAndStock.value),
Y: elId,
Z: common_vendor.s(elStyles.value),
aa: common_vendor.o(onClick)
}) : {}, {
ab: __props.size === "lg"
}, __props.size === "lg" ? common_vendor.e({
ac: __props.tagStyle.show
}, __props.tagStyle.show ? {
ad: common_vendor.unref(modules_mall_sheep_index.sheep).$url.cdn(__props.tagStyle.src || __props.tagStyle.imgUrl)
} : {}, {
ae: __props.seckillTag
}, __props.seckillTag ? {} : {}, {
af: __props.grouponTag
}, __props.grouponTag ? {} : {}, {
ag: common_vendor.unref(modules_mall_sheep_index.sheep).$url.cdn(__props.data.image || __props.data.picUrl),
ah: ((_O = __props.goodsFields.title) == null ? void 0 : _O.show) || ((_P = __props.goodsFields.name) == null ? void 0 : _P.show)
}, ((_Q = __props.goodsFields.title) == null ? void 0 : _Q.show) || ((_R = __props.goodsFields.name) == null ? void 0 : _R.show) ? {
ai: common_vendor.t(__props.data.title || __props.data.name),
aj: common_vendor.s({
color: __props.titleColor
})
} : {}, {
ak: ((_S = __props.goodsFields.subtitle) == null ? void 0 : _S.show) || ((_T = __props.goodsFields.introduction) == null ? void 0 : _T.show)
}, ((_U = __props.goodsFields.subtitle) == null ? void 0 : _U.show) || ((_V = __props.goodsFields.introduction) == null ? void 0 : _V.show) ? {
al: common_vendor.t(__props.data.subtitle || __props.data.introduction),
am: common_vendor.s({
color: __props.subTitleColor,
background: __props.subTitleBackground
})
} : {}, {
an: (_W = __props.data.promos) == null ? void 0 : _W.length
}, ((_X = __props.data.promos) == null ? void 0 : _X.length) ? {
ao: common_vendor.f(__props.data.promos, (item, k0, i0) => {
return {
a: common_vendor.t(item.title),
b: item.id
};
})
} : {}, {
ap: (_Y = __props.goodsFields.price) == null ? void 0 : _Y.show
}, ((_Z = __props.goodsFields.price) == null ? void 0 : _Z.show) ? {
aq: common_vendor.t(__props.priceUnit),
ar: common_vendor.t(common_vendor.unref(common_vendor.isArray$1)(__props.data.price) ? common_vendor.unref(modules_mall_sheep_hooks_useGoods.fen2yuan)(__props.data.price[0]) : common_vendor.unref(modules_mall_sheep_hooks_useGoods.fen2yuan)(__props.data.price)),
as: common_vendor.s({
color: __props.goodsFields.price.color
})
} : {}, {
at: (((__ = __props.goodsFields.original_price) == null ? void 0 : __.show) || ((_$ = __props.goodsFields.marketPrice) == null ? void 0 : _$.show)) && (__props.data.original_price > 0 || __props.data.marketPrice > 0)
}, (((_aa = __props.goodsFields.original_price) == null ? void 0 : _aa.show) || ((_ba = __props.goodsFields.marketPrice) == null ? void 0 : _ba.show)) && (__props.data.original_price > 0 || __props.data.marketPrice > 0) ? {
av: common_vendor.t(__props.priceUnit),
aw: common_vendor.t(common_vendor.unref(modules_mall_sheep_hooks_useGoods.fen2yuan)(__props.data.marketPrice)),
ax: common_vendor.s({
color: __props.originPriceColor
})
} : {}, {
ay: common_vendor.t(salesAndStock.value),
az: __props.buttonShow
}, __props.buttonShow ? {} : {}, {
aA: common_vendor.s(elStyles.value),
aB: common_vendor.o(onClick)
}) : {}, {
aC: __props.size === "sl"
}, __props.size === "sl" ? common_vendor.e({
aD: __props.tagStyle.show
}, __props.tagStyle.show ? {
aE: common_vendor.unref(modules_mall_sheep_index.sheep).$url.cdn(__props.tagStyle.src || __props.tagStyle.imgUrl)
} : {}, {
aF: common_vendor.unref(modules_mall_sheep_index.sheep).$url.cdn(__props.data.image || __props.data.picUrl),
aG: ((_ca = __props.goodsFields.title) == null ? void 0 : _ca.show) || ((_da = __props.goodsFields.name) == null ? void 0 : _da.show)
}, ((_ea = __props.goodsFields.title) == null ? void 0 : _ea.show) || ((_fa = __props.goodsFields.name) == null ? void 0 : _fa.show) ? {
aH: common_vendor.t(__props.data.title || __props.data.name),
aI: common_vendor.s({
color: __props.titleColor
})
} : {}, {
aJ: ((_ga = __props.goodsFields.subtitle) == null ? void 0 : _ga.show) || ((_ha = __props.goodsFields.introduction) == null ? void 0 : _ha.show)
}, ((_ia = __props.goodsFields.subtitle) == null ? void 0 : _ia.show) || ((_ja = __props.goodsFields.introduction) == null ? void 0 : _ja.show) ? {
aK: common_vendor.t(__props.data.subtitle || __props.data.introduction),
aL: common_vendor.s({
color: __props.subTitleColor,
background: __props.subTitleBackground
})
} : {}, {
aM: (_ka = __props.data.promos) == null ? void 0 : _ka.length
}, ((_la = __props.data.promos) == null ? void 0 : _la.length) ? {
aN: common_vendor.f(__props.data.promos, (item, k0, i0) => {
return {
a: common_vendor.t(item.title),
b: item.id
};
})
} : {}, {
aO: (_ma = __props.goodsFields.price) == null ? void 0 : _ma.show
}, ((_na = __props.goodsFields.price) == null ? void 0 : _na.show) ? common_vendor.e({
aP: common_vendor.t(__props.priceUnit),
aQ: common_vendor.t(common_vendor.unref(common_vendor.isArray$1)(__props.data.price) ? common_vendor.unref(modules_mall_sheep_hooks_useGoods.fen2yuan)(__props.data.price[0]) : common_vendor.unref(modules_mall_sheep_hooks_useGoods.fen2yuan)(__props.data.price)),
aR: common_vendor.s({
color: __props.goodsFields.price.color
}),
aS: (((_oa = __props.goodsFields.original_price) == null ? void 0 : _oa.show) || ((_pa = __props.goodsFields.marketPrice) == null ? void 0 : _pa.show)) && (__props.data.original_price > 0 || __props.data.marketPrice > 0)
}, (((_qa = __props.goodsFields.original_price) == null ? void 0 : _qa.show) || ((_ra = __props.goodsFields.marketPrice) == null ? void 0 : _ra.show)) && (__props.data.original_price > 0 || __props.data.marketPrice > 0) ? {
aT: common_vendor.t(__props.priceUnit),
aU: common_vendor.t(common_vendor.unref(modules_mall_sheep_hooks_useGoods.fen2yuan)(__props.data.marketPrice)),
aV: common_vendor.s({
color: __props.originPriceColor
})
} : {}) : {}, {
aW: common_vendor.t(salesAndStock.value),
aX: common_vendor.s(elStyles.value),
aY: common_vendor.o(onClick)
}) : {});
};
}
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-9bf049d6"]]);
wx.createComponent(Component);