seckill.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const sheep_index = require("../../sheep/index.js");
  4. const sheep_hooks_useGoods = require("../../sheep/hooks/useGoods.js");
  5. const sheep_api_promotion_seckill = require("../../sheep/api/promotion/seckill.js");
  6. const sheep_api_product_spu = require("../../sheep/api/product/spu.js");
  7. const sheep_util_const = require("../../sheep/util/const.js");
  8. require("../../sheep/url/index.js");
  9. require("../../sheep/store/index.js");
  10. require("../../sheep/store/app.js");
  11. require("../../sheep/api/promotion/diy.js");
  12. require("../../sheep/request/index.js");
  13. require("../../sheep/config/index.js");
  14. require("../../sheep/platform/index.js");
  15. require("../../sheep/platform/provider/wechat/index.js");
  16. require("../../sheep/platform/provider/wechat/miniProgram.js");
  17. require("../../sheep/api/member/auth.js");
  18. require("../../sheep/api/member/social.js");
  19. require("../../sheep/api/member/user.js");
  20. require("../../sheep/platform/provider/apple/index.js");
  21. require("../../sheep/platform/share.js");
  22. require("../../sheep/router/index.js");
  23. require("../../sheep/hooks/useModal.js");
  24. require("../../sheep/helper/index.js");
  25. require("../../sheep/helper/test.js");
  26. require("../../sheep/helper/digit.js");
  27. require("../../sheep/api/member/signin.js");
  28. require("../../sheep/helper/throttle.js");
  29. require("../../sheep/platform/pay.js");
  30. require("../../sheep/api/pay/order.js");
  31. require("../../sheep/store/user.js");
  32. require("../../sheep/store/cart.js");
  33. require("../../sheep/api/trade/cart.js");
  34. require("../../sheep/api/pay/wallet.js");
  35. require("../../sheep/api/trade/order.js");
  36. require("../../sheep/api/promotion/coupon.js");
  37. require("../../sheep/store/sys.js");
  38. require("../../sheep/store/modal.js");
  39. require("../../sheep/config/zIndex.js");
  40. require("../../sheep/util/index.js");
  41. if (!Array) {
  42. const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty");
  43. const _easycom_su_swiper2 = common_vendor.resolveComponent("su-swiper");
  44. const _easycom_s_select_seckill_sku2 = common_vendor.resolveComponent("s-select-seckill-sku");
  45. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  46. (_easycom_s_empty2 + _easycom_su_swiper2 + _easycom_s_select_seckill_sku2 + _easycom_s_layout2)();
  47. }
  48. const _easycom_s_empty = () => "../../sheep/components/s-empty/s-empty.js";
  49. const _easycom_su_swiper = () => "../../sheep/ui/su-swiper/su-swiper.js";
  50. const _easycom_s_select_seckill_sku = () => "../../sheep/components/s-select-seckill-sku/s-select-seckill-sku.js";
  51. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  52. if (!Math) {
  53. (detailNavbar + detailSkeleton + _easycom_s_empty + _easycom_su_swiper + detailProgress + detailCellSku + _easycom_s_select_seckill_sku + detailCommentCard + detailContentCard + detailTabbar + _easycom_s_layout)();
  54. }
  55. const detailNavbar = () => "./components/detail/detail-navbar.js";
  56. const detailCellSku = () => "./components/detail/detail-cell-sku.js";
  57. const detailTabbar = () => "./components/detail/detail-tabbar.js";
  58. const detailSkeleton = () => "./components/detail/detail-skeleton.js";
  59. const detailCommentCard = () => "./components/detail/detail-comment-card.js";
  60. const detailContentCard = () => "./components/detail/detail-content-card.js";
  61. const detailProgress = () => "./components/detail/detail-progress.js";
  62. const _sfc_main = {
  63. __name: "seckill",
  64. setup(__props) {
  65. common_vendor.useCssVars((_ctx) => ({
  66. "4f732cf8": common_vendor.unref(headerBg),
  67. "52c6d9a2": common_vendor.unref(btnBg),
  68. "7fa54813": common_vendor.unref(disabledBtnBg),
  69. "056c2c42": common_vendor.unref(seckillBg),
  70. "3634f41e": common_vendor.unref(grouponBg)
  71. }));
  72. const headerBg = sheep_index.sheep.$url.css("/static/img/shop/goods/seckill-bg.png");
  73. const btnBg = sheep_index.sheep.$url.css("/static/img/shop/goods/seckill-btn.png");
  74. const disabledBtnBg = sheep_index.sheep.$url.css(
  75. "/static/img/shop/goods/activity-btn-disabled.png"
  76. );
  77. const seckillBg = sheep_index.sheep.$url.css("/static/img/shop/goods/seckill-tip-bg.png");
  78. const grouponBg = sheep_index.sheep.$url.css("/static/img/shop/goods/groupon-tip-bg.png");
  79. common_vendor.onPageScroll(() => {
  80. });
  81. const state = common_vendor.reactive({
  82. skeletonLoading: true,
  83. goodsInfo: {},
  84. showSelectSku: false,
  85. goodsSwiper: [],
  86. selectedSku: {},
  87. showModel: false,
  88. total: 0,
  89. percent: 0,
  90. price: ""
  91. });
  92. const endTime = common_vendor.computed(() => {
  93. return sheep_hooks_useGoods.useDurationTime(activity.value.endTime);
  94. });
  95. function onSkuChange(e) {
  96. state.selectedSku = e;
  97. }
  98. function onBuy(sku) {
  99. sheep_index.sheep.$router.go("/pages/order/confirm", {
  100. data: JSON.stringify({
  101. order_type: "goods",
  102. buy_type: "seckill",
  103. seckillActivityId: activity.value.id,
  104. items: [
  105. {
  106. skuId: sku.id,
  107. count: sku.count
  108. }
  109. ]
  110. })
  111. });
  112. }
  113. const shareInfo = common_vendor.computed(() => {
  114. if (common_vendor.lodashExports.isEmpty(activity))
  115. return {};
  116. return sheep_index.sheep.$platform.share.getShareInfo(
  117. {
  118. title: activity.value.name,
  119. image: sheep_index.sheep.$url.cdn(state.goodsInfo.picUrl),
  120. params: {
  121. page: "4",
  122. query: activity.value.id
  123. }
  124. },
  125. {
  126. type: "goods",
  127. // 商品海报
  128. title: activity.value.name,
  129. // 商品标题
  130. image: sheep_index.sheep.$url.cdn(state.goodsInfo.picUrl),
  131. // 商品主图
  132. price: state.goodsInfo.price,
  133. // 商品价格
  134. marketPrice: state.goodsInfo.marketPrice
  135. // 商品原价
  136. }
  137. );
  138. });
  139. const activity = common_vendor.ref();
  140. const timeStatusEnum = common_vendor.ref("");
  141. const getActivity = async (id) => {
  142. const { data } = await sheep_api_promotion_seckill.SeckillApi.getSeckillActivity(id);
  143. activity.value = data;
  144. timeStatusEnum.value = sheep_util_const.getTimeStatusEnum(activity.startTime, activity.endTime);
  145. await getSpu(data.spuId);
  146. };
  147. const getSpu = async (id) => {
  148. const { data } = await sheep_api_product_spu.SpuApi.getSpuDetail(id);
  149. data.activity_type = "seckill";
  150. state.goodsInfo = data;
  151. state.goodsSwiper = sheep_hooks_useGoods.formatGoodsSwiper(state.goodsInfo.sliderPicUrls);
  152. state.goodsInfo.price = common_vendor.lodashExports.min([state.goodsInfo.price, ...activity.value.products.map((spu) => spu.seckillPrice)]);
  153. data.skus.forEach((sku) => {
  154. const product = activity.value.products.find((product2) => product2.skuId === sku.id);
  155. if (product) {
  156. sku.price = product.seckillPrice;
  157. sku.stock = Math.min(sku.stock, product.stock);
  158. } else {
  159. sku.stock = 0;
  160. }
  161. if (activity.value.totalLimitCount > 0 && activity.value.singleLimitCount > 0) {
  162. sku.limitCount = Math.min(activity.value.totalLimitCount, activity.value.singleLimitCount);
  163. } else if (activity.value.totalLimitCount > 0) {
  164. sku.limitCount = activity.value.totalLimitCount;
  165. } else if (activity.value.singleLimitCount > 0) {
  166. sku.limitCount = activity.value.singleLimitCount;
  167. }
  168. });
  169. state.skeletonLoading = false;
  170. };
  171. common_vendor.onLoad((options) => {
  172. if (!options.id) {
  173. state.goodsInfo = null;
  174. return;
  175. }
  176. getActivity(options.id);
  177. });
  178. return (_ctx, _cache) => {
  179. var _a;
  180. return common_vendor.e({
  181. a: state.skeletonLoading
  182. }, state.skeletonLoading ? {} : state.goodsInfo === null || state.goodsInfo.activity_type !== "seckill" ? {
  183. c: common_vendor.p({
  184. text: "活动不存在或已结束",
  185. icon: "/static/soldout-empty.png",
  186. showAction: true,
  187. actionText: "再逛逛",
  188. actionUrl: "/pages/goods/list"
  189. })
  190. } : common_vendor.e({
  191. d: common_vendor.p({
  192. isPreview: true,
  193. list: state.goodsSwiper,
  194. dotStyle: "tag",
  195. imageMode: "widthFix",
  196. dotCur: "bg-mask-40",
  197. seizeHeight: 750
  198. }),
  199. e: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.selectedSku.price || state.goodsInfo.price)),
  200. f: endTime.value.ms > 0
  201. }, endTime.value.ms > 0 ? {
  202. g: common_vendor.t(endTime.value.h),
  203. h: common_vendor.t(endTime.value.m),
  204. i: common_vendor.t(endTime.value.s)
  205. } : {}, {
  206. j: state.goodsInfo.marketPrice
  207. }, state.goodsInfo.marketPrice ? {
  208. k: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.selectedSku.marketPrice || state.goodsInfo.marketPrice))
  209. } : {}, {
  210. l: common_vendor.p({
  211. percent: state.percent
  212. }),
  213. m: common_vendor.t((_a = state.goodsInfo) == null ? void 0 : _a.name),
  214. n: common_vendor.t(state.goodsInfo.introduction),
  215. o: common_vendor.o(($event) => state.showSelectSku = true),
  216. p: common_vendor.p({
  217. sku: state.selectedSku
  218. }),
  219. q: common_vendor.o(onBuy),
  220. r: common_vendor.o(onSkuChange),
  221. s: common_vendor.o(($event) => state.showSelectSku = false),
  222. t: common_vendor.o(($event) => state.goodsInfo = $event),
  223. v: common_vendor.p({
  224. show: state.showSelectSku,
  225. ["single-limit-count"]: activity.value.singleLimitCount,
  226. modelValue: state.goodsInfo
  227. }),
  228. w: common_vendor.p({
  229. goodsId: state.goodsInfo.id
  230. }),
  231. x: common_vendor.p({
  232. content: state.goodsInfo.description
  233. }),
  234. y: state.goodsInfo.marketPrice
  235. }, state.goodsInfo.marketPrice ? {
  236. z: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.goodsInfo.marketPrice)),
  237. A: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/goods/index", {
  238. id: state.goodsInfo.id
  239. }))
  240. } : {
  241. B: common_vendor.n(state.goodsInfo.stock === 0 || timeStatusEnum.value !== common_vendor.unref(sheep_util_const.TimeStatusEnum).STARTED ? "" : "")
  242. }, {
  243. C: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.goodsInfo.price)),
  244. D: timeStatusEnum.value === common_vendor.unref(sheep_util_const.TimeStatusEnum).STARTED
  245. }, timeStatusEnum.value === common_vendor.unref(sheep_util_const.TimeStatusEnum).STARTED ? common_vendor.e({
  246. E: state.goodsInfo.stock === 0
  247. }, state.goodsInfo.stock === 0 ? {} : {}) : {
  248. F: common_vendor.t(timeStatusEnum.value)
  249. }, {
  250. G: common_vendor.o(($event) => state.showSelectSku = true),
  251. H: common_vendor.n(timeStatusEnum.value === common_vendor.unref(sheep_util_const.TimeStatusEnum).STARTED && state.goodsInfo.stock != 0 ? "check-btn-box" : "disabled-btn-box"),
  252. I: state.goodsInfo.stock === 0 || timeStatusEnum.value !== common_vendor.unref(sheep_util_const.TimeStatusEnum).STARTED,
  253. J: common_vendor.o(($event) => state.goodsInfo = $event),
  254. K: common_vendor.p({
  255. modelValue: state.goodsInfo
  256. })
  257. }), {
  258. b: state.goodsInfo === null || state.goodsInfo.activity_type !== "seckill",
  259. L: common_vendor.s(_ctx.__cssVars()),
  260. M: common_vendor.p({
  261. onShareAppMessage: shareInfo.value,
  262. navbar: "goods"
  263. })
  264. });
  265. };
  266. }
  267. };
  268. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-960ccb8e"], ["__file", "D:/zx/mall-front-app/pages/goods/seckill.vue"]]);
  269. _sfc_main.__runtimeHooks = 3;
  270. wx.createPage(MiniProgramPage);