s-goods-column.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const sheep_index = require("../../index.js");
  4. const sheep_hooks_useGoods = require("../../hooks/useGoods.js");
  5. require("../../url/index.js");
  6. require("../../store/index.js");
  7. require("../../store/app.js");
  8. require("../../api/promotion/diy.js");
  9. require("../../request/index.js");
  10. require("../../config/index.js");
  11. require("../../platform/index.js");
  12. require("../../platform/provider/wechat/index.js");
  13. require("../../platform/provider/wechat/miniProgram.js");
  14. require("../../api/member/auth.js");
  15. require("../../api/member/social.js");
  16. require("../../api/member/user.js");
  17. require("../../platform/provider/apple/index.js");
  18. require("../../platform/share.js");
  19. require("../../router/index.js");
  20. require("../../hooks/useModal.js");
  21. require("../../helper/index.js");
  22. require("../../helper/test.js");
  23. require("../../helper/digit.js");
  24. require("../../helper/throttle.js");
  25. require("../../platform/pay.js");
  26. require("../../api/pay/order.js");
  27. require("../../store/user.js");
  28. require("../../store/cart.js");
  29. require("../../api/trade/cart.js");
  30. require("../../api/pay/wallet.js");
  31. require("../../api/trade/order.js");
  32. require("../../api/promotion/coupon.js");
  33. require("../../store/sys.js");
  34. require("../../store/modal.js");
  35. require("../../config/zIndex.js");
  36. require("../../util/index.js");
  37. const _sfc_main = {
  38. __name: "s-goods-column",
  39. props: {
  40. goodsFields: {
  41. type: [Array, Object],
  42. default() {
  43. return {
  44. // 商品价格
  45. price: { show: true },
  46. // 库存
  47. stock: { show: true },
  48. // 商品名称
  49. name: { show: true },
  50. // 商品介绍
  51. introduction: { show: true },
  52. // 市场价
  53. marketPrice: { show: true },
  54. // 销量
  55. salesCount: { show: true }
  56. };
  57. }
  58. },
  59. tagStyle: {
  60. type: Object,
  61. default: {}
  62. },
  63. data: {
  64. type: Object,
  65. default: {}
  66. },
  67. size: {
  68. type: String,
  69. default: "sl"
  70. },
  71. background: {
  72. type: String,
  73. default: ""
  74. },
  75. topRadius: {
  76. type: Number,
  77. default: 0
  78. },
  79. bottomRadius: {
  80. type: Number,
  81. default: 0
  82. },
  83. titleWidth: {
  84. type: Number,
  85. default: 0
  86. },
  87. titleColor: {
  88. type: String,
  89. default: "#333"
  90. },
  91. priceColor: {
  92. type: String,
  93. default: ""
  94. },
  95. originPriceColor: {
  96. type: String,
  97. default: "#C4C4C4"
  98. },
  99. priceUnit: {
  100. type: String,
  101. default: "¥"
  102. },
  103. subTitleColor: {
  104. type: String,
  105. default: "#999999"
  106. },
  107. subTitleBackground: {
  108. type: String,
  109. default: ""
  110. },
  111. buttonShow: {
  112. type: Boolean,
  113. default: true
  114. },
  115. seckillTag: {
  116. type: Boolean,
  117. default: false
  118. },
  119. grouponTag: {
  120. type: Boolean,
  121. default: false
  122. }
  123. },
  124. emits: ["click", "getHeight"],
  125. setup(__props, { emit: emits }) {
  126. const props = __props;
  127. common_vendor.reactive({});
  128. const elStyles = common_vendor.computed(() => {
  129. return {
  130. background: props.background,
  131. "border-top-left-radius": props.topRadius + "px",
  132. "border-top-right-radius": props.topRadius + "px",
  133. "border-bottom-left-radius": props.bottomRadius + "px",
  134. "border-bottom-right-radius": props.bottomRadius + "px"
  135. };
  136. });
  137. const salesAndStock = common_vendor.computed(() => {
  138. var _a, _b;
  139. let text = [];
  140. if ((_a = props.goodsFields.salesCount) == null ? void 0 : _a.show) {
  141. text.push(sheep_hooks_useGoods.formatSales(props.data.sales_show_type, props.data.salesCount));
  142. }
  143. if ((_b = props.goodsFields.stock) == null ? void 0 : _b.show) {
  144. text.push(sheep_hooks_useGoods.formatStock(props.data.stock_show_type, props.data.stock));
  145. }
  146. return text.join(" | ");
  147. });
  148. const onClick = () => {
  149. emits("click");
  150. };
  151. const { proxy } = common_vendor.getCurrentInstance();
  152. const elId = `sheep_${Math.ceil(Math.random() * 1e6).toString(36)}`;
  153. function getGoodsPriceCardWH() {
  154. if (props.size === "md") {
  155. const view = common_vendor.index.createSelectorQuery().in(proxy);
  156. view.select(`#${elId}`).fields({ size: true, scrollOffset: true });
  157. view.exec((data) => {
  158. let totalHeight = 0;
  159. const goodsPriceCard = data[0];
  160. if (props.data.image_wh) {
  161. totalHeight = goodsPriceCard.width / props.data.image_wh.w * props.data.image_wh.h + goodsPriceCard.height;
  162. } else {
  163. totalHeight = goodsPriceCard.width;
  164. }
  165. emits("getHeight", totalHeight);
  166. });
  167. }
  168. }
  169. common_vendor.onMounted(() => {
  170. common_vendor.nextTick$1(() => {
  171. getGoodsPriceCardWH();
  172. });
  173. });
  174. return (_ctx, _cache) => {
  175. 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;
  176. return common_vendor.e({
  177. a: __props.size === "xs"
  178. }, __props.size === "xs" ? common_vendor.e({
  179. b: __props.tagStyle.show
  180. }, __props.tagStyle.show ? {
  181. c: common_vendor.unref(sheep_index.sheep).$url.cdn(__props.tagStyle.src || __props.tagStyle.imgUrl)
  182. } : {}, {
  183. d: common_vendor.unref(sheep_index.sheep).$url.cdn(__props.data.image || __props.data.picUrl),
  184. 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)
  185. }, ((_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({
  186. f: ((_g = __props.goodsFields.title) == null ? void 0 : _g.show) || ((_h = __props.goodsFields.name) == null ? void 0 : _h.show)
  187. }, ((_i = __props.goodsFields.title) == null ? void 0 : _i.show) || ((_j = __props.goodsFields.name) == null ? void 0 : _j.show) ? {
  188. g: common_vendor.t(__props.data.title || __props.data.name),
  189. h: common_vendor.s({
  190. color: __props.titleColor,
  191. width: __props.titleWidth ? __props.titleWidth + "rpx" : ""
  192. })
  193. } : {}, {
  194. i: (_k = __props.goodsFields.price) == null ? void 0 : _k.show
  195. }, ((_l = __props.goodsFields.price) == null ? void 0 : _l.show) ? {
  196. j: common_vendor.t(__props.priceUnit),
  197. k: common_vendor.t(common_vendor.unref(common_vendor.lodashExports.isArray)(__props.data.price) ? common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(__props.data.price[0]) : common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(__props.data.price)),
  198. l: common_vendor.s({
  199. color: __props.goodsFields.price.color
  200. })
  201. } : {}) : {}, {
  202. m: common_vendor.s(common_vendor.unref(elStyles)),
  203. n: common_vendor.o(onClick)
  204. }) : {}, {
  205. o: __props.size === "sm"
  206. }, __props.size === "sm" ? common_vendor.e({
  207. p: __props.tagStyle.show
  208. }, __props.tagStyle.show ? {
  209. q: common_vendor.unref(sheep_index.sheep).$url.cdn(__props.tagStyle.src || __props.tagStyle.imgUrl)
  210. } : {}, {
  211. r: common_vendor.unref(sheep_index.sheep).$url.cdn(__props.data.image || __props.data.picUrl),
  212. 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)
  213. }, ((_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({
  214. t: ((_s = __props.goodsFields.title) == null ? void 0 : _s.show) || ((_t = __props.goodsFields.name) == null ? void 0 : _t.show)
  215. }, ((_u = __props.goodsFields.title) == null ? void 0 : _u.show) || ((_v = __props.goodsFields.name) == null ? void 0 : _v.show) ? {
  216. v: common_vendor.t(__props.data.title || __props.data.name)
  217. } : {}, {
  218. w: (_w = __props.goodsFields.price) == null ? void 0 : _w.show
  219. }, ((_x = __props.goodsFields.price) == null ? void 0 : _x.show) ? {
  220. x: common_vendor.t(__props.priceUnit),
  221. y: common_vendor.t(common_vendor.unref(common_vendor.lodashExports.isArray)(__props.data.price) ? common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(__props.data.price[0]) : common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(__props.data.price)),
  222. z: common_vendor.s({
  223. color: __props.goodsFields.price.color
  224. })
  225. } : {}, {
  226. A: common_vendor.s({
  227. color: __props.titleColor,
  228. width: __props.titleWidth ? __props.titleWidth + "rpx" : ""
  229. })
  230. }) : {}, {
  231. B: common_vendor.s(common_vendor.unref(elStyles)),
  232. C: common_vendor.o(onClick)
  233. }) : {}, {
  234. D: __props.size === "md"
  235. }, __props.size === "md" ? common_vendor.e({
  236. E: __props.tagStyle.show
  237. }, __props.tagStyle.show ? {
  238. F: common_vendor.unref(sheep_index.sheep).$url.cdn(__props.tagStyle.src || __props.tagStyle.imgUrl)
  239. } : {}, {
  240. G: common_vendor.unref(sheep_index.sheep).$url.cdn(__props.data.image || __props.data.picUrl),
  241. H: ((_y = __props.goodsFields.title) == null ? void 0 : _y.show) || ((_z = __props.goodsFields.name) == null ? void 0 : _z.show)
  242. }, ((_A = __props.goodsFields.title) == null ? void 0 : _A.show) || ((_B = __props.goodsFields.name) == null ? void 0 : _B.show) ? {
  243. I: common_vendor.t(__props.data.title || __props.data.name),
  244. J: common_vendor.s({
  245. color: __props.titleColor,
  246. width: __props.titleWidth ? __props.titleWidth + "rpx" : ""
  247. })
  248. } : {}, {
  249. K: ((_C = __props.goodsFields.subtitle) == null ? void 0 : _C.show) || ((_D = __props.goodsFields.introduction) == null ? void 0 : _D.show)
  250. }, ((_E = __props.goodsFields.subtitle) == null ? void 0 : _E.show) || ((_F = __props.goodsFields.introduction) == null ? void 0 : _F.show) ? {
  251. L: common_vendor.t(__props.data.subtitle || __props.data.introduction),
  252. M: common_vendor.s({
  253. color: __props.subTitleColor,
  254. background: __props.subTitleBackground
  255. })
  256. } : {}, {
  257. N: (_G = __props.data.promos) == null ? void 0 : _G.length
  258. }, ((_H = __props.data.promos) == null ? void 0 : _H.length) ? {
  259. O: common_vendor.f(__props.data.promos, (item, k0, i0) => {
  260. return {
  261. a: common_vendor.t(item.title),
  262. b: item.id
  263. };
  264. })
  265. } : {}, {
  266. P: (_I = __props.goodsFields.price) == null ? void 0 : _I.show
  267. }, ((_J = __props.goodsFields.price) == null ? void 0 : _J.show) ? {
  268. Q: common_vendor.t(__props.priceUnit),
  269. R: common_vendor.t(common_vendor.unref(common_vendor.lodashExports.isArray)(__props.data.price) ? common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(__props.data.price[0]) : common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(__props.data.price)),
  270. S: common_vendor.s({
  271. color: __props.goodsFields.price.color
  272. })
  273. } : {}, {
  274. 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)
  275. }, (((_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) ? {
  276. U: common_vendor.t(__props.priceUnit),
  277. V: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(__props.data.marketPrice)),
  278. W: common_vendor.s({
  279. color: __props.originPriceColor
  280. })
  281. } : {}, {
  282. X: common_vendor.t(common_vendor.unref(salesAndStock)),
  283. Y: elId,
  284. Z: common_vendor.s(common_vendor.unref(elStyles)),
  285. aa: common_vendor.o(onClick)
  286. }) : {}, {
  287. ab: __props.size === "lg"
  288. }, __props.size === "lg" ? common_vendor.e({
  289. ac: __props.tagStyle.show
  290. }, __props.tagStyle.show ? {
  291. ad: common_vendor.unref(sheep_index.sheep).$url.cdn(__props.tagStyle.src || __props.tagStyle.imgUrl)
  292. } : {}, {
  293. ae: __props.seckillTag
  294. }, __props.seckillTag ? {} : {}, {
  295. af: __props.grouponTag
  296. }, __props.grouponTag ? {} : {}, {
  297. ag: common_vendor.unref(sheep_index.sheep).$url.cdn(__props.data.image || __props.data.picUrl),
  298. ah: ((_O = __props.goodsFields.title) == null ? void 0 : _O.show) || ((_P = __props.goodsFields.name) == null ? void 0 : _P.show)
  299. }, ((_Q = __props.goodsFields.title) == null ? void 0 : _Q.show) || ((_R = __props.goodsFields.name) == null ? void 0 : _R.show) ? {
  300. ai: common_vendor.t(__props.data.title || __props.data.name),
  301. aj: common_vendor.s({
  302. color: __props.titleColor
  303. })
  304. } : {}, {
  305. ak: ((_S = __props.goodsFields.subtitle) == null ? void 0 : _S.show) || ((_T = __props.goodsFields.introduction) == null ? void 0 : _T.show)
  306. }, ((_U = __props.goodsFields.subtitle) == null ? void 0 : _U.show) || ((_V = __props.goodsFields.introduction) == null ? void 0 : _V.show) ? {
  307. al: common_vendor.t(__props.data.subtitle || __props.data.introduction),
  308. am: common_vendor.s({
  309. color: __props.subTitleColor,
  310. background: __props.subTitleBackground
  311. })
  312. } : {}, {
  313. an: (_W = __props.data.promos) == null ? void 0 : _W.length
  314. }, ((_X = __props.data.promos) == null ? void 0 : _X.length) ? {
  315. ao: common_vendor.f(__props.data.promos, (item, k0, i0) => {
  316. return {
  317. a: common_vendor.t(item.title),
  318. b: item.id
  319. };
  320. })
  321. } : {}, {
  322. ap: (_Y = __props.goodsFields.price) == null ? void 0 : _Y.show
  323. }, ((_Z = __props.goodsFields.price) == null ? void 0 : _Z.show) ? {
  324. aq: common_vendor.t(__props.priceUnit),
  325. ar: common_vendor.t(common_vendor.unref(common_vendor.lodashExports.isArray)(__props.data.price) ? common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(__props.data.price[0]) : common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(__props.data.price)),
  326. as: common_vendor.s({
  327. color: __props.goodsFields.price.color
  328. })
  329. } : {}, {
  330. 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)
  331. }, (((_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) ? {
  332. av: common_vendor.t(__props.priceUnit),
  333. aw: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(__props.data.marketPrice)),
  334. ax: common_vendor.s({
  335. color: __props.originPriceColor
  336. })
  337. } : {}, {
  338. ay: common_vendor.t(common_vendor.unref(salesAndStock)),
  339. az: __props.buttonShow
  340. }, __props.buttonShow ? {} : {}, {
  341. aA: common_vendor.s(common_vendor.unref(elStyles)),
  342. aB: common_vendor.o(onClick)
  343. }) : {}, {
  344. aC: __props.size === "sl"
  345. }, __props.size === "sl" ? common_vendor.e({
  346. aD: __props.tagStyle.show
  347. }, __props.tagStyle.show ? {
  348. aE: common_vendor.unref(sheep_index.sheep).$url.cdn(__props.tagStyle.src || __props.tagStyle.imgUrl)
  349. } : {}, {
  350. aF: common_vendor.unref(sheep_index.sheep).$url.cdn(__props.data.image || __props.data.picUrl),
  351. aG: ((_ca = __props.goodsFields.title) == null ? void 0 : _ca.show) || ((_da = __props.goodsFields.name) == null ? void 0 : _da.show)
  352. }, ((_ea = __props.goodsFields.title) == null ? void 0 : _ea.show) || ((_fa = __props.goodsFields.name) == null ? void 0 : _fa.show) ? {
  353. aH: common_vendor.t(__props.data.title || __props.data.name),
  354. aI: common_vendor.s({
  355. color: __props.titleColor
  356. })
  357. } : {}, {
  358. aJ: ((_ga = __props.goodsFields.subtitle) == null ? void 0 : _ga.show) || ((_ha = __props.goodsFields.introduction) == null ? void 0 : _ha.show)
  359. }, ((_ia = __props.goodsFields.subtitle) == null ? void 0 : _ia.show) || ((_ja = __props.goodsFields.introduction) == null ? void 0 : _ja.show) ? {
  360. aK: common_vendor.t(__props.data.subtitle || __props.data.introduction),
  361. aL: common_vendor.s({
  362. color: __props.subTitleColor,
  363. background: __props.subTitleBackground
  364. })
  365. } : {}, {
  366. aM: (_ka = __props.data.promos) == null ? void 0 : _ka.length
  367. }, ((_la = __props.data.promos) == null ? void 0 : _la.length) ? {
  368. aN: common_vendor.f(__props.data.promos, (item, k0, i0) => {
  369. return {
  370. a: common_vendor.t(item.title),
  371. b: item.id
  372. };
  373. })
  374. } : {}, {
  375. aO: (_ma = __props.goodsFields.price) == null ? void 0 : _ma.show
  376. }, ((_na = __props.goodsFields.price) == null ? void 0 : _na.show) ? common_vendor.e({
  377. aP: common_vendor.t(__props.priceUnit),
  378. aQ: common_vendor.t(common_vendor.unref(common_vendor.lodashExports.isArray)(__props.data.price) ? common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(__props.data.price[0]) : common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(__props.data.price)),
  379. aR: common_vendor.s({
  380. color: __props.goodsFields.price.color
  381. }),
  382. 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)
  383. }, (((_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) ? {
  384. aT: common_vendor.t(__props.priceUnit),
  385. aU: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(__props.data.marketPrice)),
  386. aV: common_vendor.s({
  387. color: __props.originPriceColor
  388. })
  389. } : {}) : {}, {
  390. aW: common_vendor.t(common_vendor.unref(salesAndStock)),
  391. aX: common_vendor.s(common_vendor.unref(elStyles)),
  392. aY: common_vendor.o(onClick)
  393. }) : {});
  394. };
  395. }
  396. };
  397. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1c3d9e07"], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/sheep/components/s-goods-column/s-goods-column.vue"]]);
  398. wx.createComponent(Component);