seckill.js 13 KB

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