seckill.js 12 KB

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