groupon.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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_combination = require("../../sheep/api/promotion/combination.js");
  6. const sheep_api_product_spu = require("../../sheep/api/product/spu.js");
  7. require("../../sheep/url/index.js");
  8. require("../../sheep/store/index.js");
  9. require("../../sheep/store/app.js");
  10. require("../../sheep/api/promotion/diy.js");
  11. require("../../sheep/request/index.js");
  12. require("../../sheep/config/index.js");
  13. require("../../sheep/platform/index.js");
  14. require("../../sheep/platform/provider/wechat/index.js");
  15. require("../../sheep/platform/provider/wechat/miniProgram.js");
  16. require("../../sheep/api/member/auth.js");
  17. require("../../sheep/api/member/social.js");
  18. require("../../sheep/api/member/user.js");
  19. require("../../sheep/platform/provider/apple/index.js");
  20. require("../../sheep/platform/share.js");
  21. require("../../sheep/router/index.js");
  22. require("../../sheep/hooks/useModal.js");
  23. require("../../sheep/helper/index.js");
  24. require("../../sheep/helper/test.js");
  25. require("../../sheep/helper/digit.js");
  26. require("../../sheep/helper/throttle.js");
  27. require("../../sheep/platform/pay.js");
  28. require("../../sheep/api/pay/order.js");
  29. require("../../sheep/store/user.js");
  30. require("../../sheep/store/cart.js");
  31. require("../../sheep/api/trade/cart.js");
  32. require("../../sheep/api/pay/wallet.js");
  33. require("../../sheep/api/trade/order.js");
  34. require("../../sheep/api/promotion/coupon.js");
  35. require("../../sheep/store/sys.js");
  36. require("../../sheep/store/modal.js");
  37. require("../../sheep/config/zIndex.js");
  38. require("../../sheep/util/index.js");
  39. if (!Array) {
  40. const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty");
  41. const _easycom_su_swiper2 = common_vendor.resolveComponent("su-swiper");
  42. const _easycom_s_select_groupon_sku2 = common_vendor.resolveComponent("s-select-groupon-sku");
  43. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  44. (_easycom_s_empty2 + _easycom_su_swiper2 + _easycom_s_select_groupon_sku2 + _easycom_s_layout2)();
  45. }
  46. const _easycom_s_empty = () => "../../sheep/components/s-empty/s-empty.js";
  47. const _easycom_su_swiper = () => "../../sheep/ui/su-swiper/su-swiper.js";
  48. const _easycom_s_select_groupon_sku = () => "../../sheep/components/s-select-groupon-sku/s-select-groupon-sku.js";
  49. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  50. if (!Math) {
  51. (detailNavbar + detailSkeleton + _easycom_s_empty + _easycom_su_swiper + detailCellSku + grouponCardList + _easycom_s_select_groupon_sku + detailCommentCard + detailContentCard + detailTabbar + _easycom_s_layout)();
  52. }
  53. const detailNavbar = () => "./components/detail/detail-navbar.js";
  54. const detailCellSku = () => "./components/detail/detail-cell-sku.js";
  55. const detailTabbar = () => "./components/detail/detail-tabbar.js";
  56. const detailSkeleton = () => "./components/detail/detail-skeleton.js";
  57. const detailCommentCard = () => "./components/detail/detail-comment-card.js";
  58. const detailContentCard = () => "./components/detail/detail-content-card.js";
  59. const grouponCardList = () => "./components/groupon/groupon-card-list.js";
  60. const _sfc_main = {
  61. __name: "groupon",
  62. setup(__props) {
  63. common_vendor.useCssVars((_ctx) => ({
  64. "9d308a56": common_vendor.unref(headerBg),
  65. "54d82b7e": common_vendor.unref(btnBg),
  66. "1431bd3c": common_vendor.unref(disabledBtnBg),
  67. "2fee5ec0": common_vendor.unref(grouponBg)
  68. }));
  69. const headerBg = sheep_index.sheep.$url.css("/static/img/shop/goods/groupon-bg.png");
  70. const btnBg = sheep_index.sheep.$url.css("/static/img/shop/goods/groupon-btn.png");
  71. const disabledBtnBg = sheep_index.sheep.$url.css(
  72. "/static/img/shop/goods/activity-btn-disabled.png"
  73. );
  74. const grouponBg = sheep_index.sheep.$url.css("/static/img/shop/goods/groupon-tip-bg.png");
  75. common_vendor.onPageScroll(() => {
  76. });
  77. const state = common_vendor.reactive({
  78. skeletonLoading: true,
  79. // 骨架屏
  80. goodsId: 0,
  81. // 商品ID
  82. goodsInfo: {},
  83. // 商品信息
  84. goodsSwiper: [],
  85. // 商品轮播图
  86. showSelectSku: false,
  87. // 显示规格弹框
  88. selectedSkuPrice: {},
  89. // 选中的规格价格
  90. activity: {},
  91. // 团购活动
  92. grouponId: 0,
  93. // 团购ID
  94. grouponNum: 0,
  95. // 团购人数
  96. grouponAction: "create",
  97. // 团购操作
  98. combinationHeadId: null
  99. // 拼团团长编号
  100. });
  101. const endTime = common_vendor.computed(() => {
  102. return sheep_hooks_useGoods.useDurationTime(state.activity.endTime);
  103. });
  104. function onSkuChange(e) {
  105. state.selectedSkuPrice = e;
  106. }
  107. function onSkuClose() {
  108. state.showSelectSku = false;
  109. }
  110. function onCreateGroupon() {
  111. state.grouponAction = "create";
  112. state.grouponId = 0;
  113. state.showSelectSku = true;
  114. }
  115. function onJoinGroupon(record) {
  116. state.grouponAction = "join";
  117. state.grouponId = record.activityId;
  118. state.combinationHeadId = record.id;
  119. state.grouponNum = record.userSize;
  120. state.showSelectSku = true;
  121. }
  122. function onBuy(sku) {
  123. sheep_index.sheep.$router.go("/pages/order/confirm", {
  124. data: JSON.stringify({
  125. order_type: "goods",
  126. combinationActivityId: state.activity.id,
  127. combinationHeadId: state.combinationHeadId,
  128. items: [
  129. {
  130. skuId: sku.id,
  131. count: sku.count
  132. }
  133. ]
  134. })
  135. });
  136. }
  137. const shareInfo = common_vendor.computed(() => {
  138. if (common_vendor.lodashExports.isEmpty(state.activity))
  139. return {};
  140. return sheep_index.sheep.$platform.share.getShareInfo(
  141. {
  142. title: state.activity.name,
  143. image: sheep_index.sheep.$url.cdn(state.goodsInfo.picUrl),
  144. params: {
  145. page: "3",
  146. query: state.activity.id
  147. }
  148. },
  149. {
  150. type: "goods",
  151. // 商品海报
  152. title: state.activity.name,
  153. // 商品标题
  154. image: sheep_index.sheep.$url.cdn(state.goodsInfo.picUrl),
  155. // 商品主图
  156. price: sheep_hooks_useGoods.fen2yuan(state.goodsInfo.price),
  157. // 商品价格
  158. marketPrice: sheep_hooks_useGoods.fen2yuan(state.goodsInfo.marketPrice)
  159. // 商品原价
  160. }
  161. );
  162. });
  163. common_vendor.onLoad(async (options) => {
  164. if (!options.id) {
  165. state.goodsInfo = null;
  166. return;
  167. }
  168. state.grouponId = options.id;
  169. const { code, data: activity } = await sheep_api_promotion_combination.CombinationApi.getCombinationActivity(state.grouponId);
  170. state.activity = activity;
  171. const { data: spu } = await sheep_api_product_spu.SpuApi.getSpuDetail(activity.spuId);
  172. state.goodsId = spu.id;
  173. activity.products.forEach((product) => {
  174. spu.price = Math.min(spu.price, product.combinationPrice);
  175. });
  176. state.skeletonLoading = false;
  177. if (code === 0) {
  178. state.goodsInfo = spu;
  179. state.grouponNum = activity.userSize;
  180. state.goodsSwiper = sheep_hooks_useGoods.formatGoodsSwiper(state.goodsInfo.sliderPicUrls);
  181. } else {
  182. state.goodsInfo = null;
  183. }
  184. });
  185. return (_ctx, _cache) => {
  186. return common_vendor.e({
  187. a: state.skeletonLoading
  188. }, state.skeletonLoading ? {} : state.goodsInfo === null || state.activity.status !== 0 || state.activity.endTime < (/* @__PURE__ */ new Date()).getTime() ? {
  189. c: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.back()),
  190. d: common_vendor.p({
  191. text: "活动不存在或已结束",
  192. icon: "/static/soldout-empty.png",
  193. showAction: true,
  194. actionText: "返回上一页"
  195. })
  196. } : common_vendor.e({
  197. e: common_vendor.p({
  198. isPreview: true,
  199. list: state.goodsSwiper,
  200. dotStyle: "tag",
  201. imageMode: "widthFix",
  202. dotCur: "bg-mask-40",
  203. seizeHeight: 750
  204. }),
  205. f: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.activity.price || state.goodsInfo.price)),
  206. g: common_vendor.unref(sheep_index.sheep).$url.static("/static/img/shop/goods/groupon-tag.png"),
  207. h: state.goodsInfo.price
  208. }, state.goodsInfo.price ? {
  209. i: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.goodsInfo.price))
  210. } : {}, {
  211. j: common_vendor.unref(endTime).ms > 0
  212. }, common_vendor.unref(endTime).ms > 0 ? {
  213. k: common_vendor.t(common_vendor.unref(endTime).h),
  214. l: common_vendor.t(common_vendor.unref(endTime).m),
  215. m: common_vendor.t(common_vendor.unref(endTime).s)
  216. } : {}, {
  217. n: common_vendor.t(state.goodsInfo.name),
  218. o: common_vendor.t(state.goodsInfo.introduction),
  219. p: common_vendor.o(($event) => state.showSelectSku = true),
  220. q: common_vendor.p({
  221. sku: state.selectedSkuPrice
  222. }),
  223. r: common_vendor.o(onJoinGroupon),
  224. s: common_vendor.o(($event) => state.activity = $event),
  225. t: common_vendor.p({
  226. modelValue: state.activity
  227. }),
  228. v: common_vendor.o(onBuy),
  229. w: common_vendor.o(onSkuChange),
  230. x: common_vendor.o(onSkuClose),
  231. y: common_vendor.p({
  232. show: state.showSelectSku,
  233. goodsInfo: state.goodsInfo,
  234. grouponAction: state.grouponAction,
  235. grouponNum: state.grouponNum
  236. }),
  237. z: common_vendor.p({
  238. goodsId: state.goodsId
  239. }),
  240. A: common_vendor.p({
  241. content: state.goodsInfo.description
  242. }),
  243. B: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.goodsInfo.marketPrice)),
  244. C: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/goods/index", {
  245. id: state.goodsInfo.id
  246. })),
  247. D: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.activity.price || state.goodsInfo.price)),
  248. E: state.activity.startTime > (/* @__PURE__ */ new Date()).getTime()
  249. }, state.activity.startTime > (/* @__PURE__ */ new Date()).getTime() ? {} : state.activity.endTime <= (/* @__PURE__ */ new Date()).getTime() ? {} : common_vendor.e({
  250. G: state.goodsInfo.stock === 0
  251. }, state.goodsInfo.stock === 0 ? {} : {}), {
  252. F: state.activity.endTime <= (/* @__PURE__ */ new Date()).getTime(),
  253. H: common_vendor.o(onCreateGroupon),
  254. I: common_vendor.n(state.activity.status === 0 && state.goodsInfo.stock !== 0 ? "check-btn-box" : "disabled-btn-box"),
  255. J: state.goodsInfo.stock === 0 || state.activity.status !== 0,
  256. K: common_vendor.o(($event) => state.goodsInfo = $event),
  257. L: common_vendor.p({
  258. modelValue: state.goodsInfo
  259. })
  260. }), {
  261. b: state.goodsInfo === null || state.activity.status !== 0 || state.activity.endTime < (/* @__PURE__ */ new Date()).getTime(),
  262. M: common_vendor.s(_ctx.__cssVars()),
  263. N: common_vendor.p({
  264. onShareAppMessage: common_vendor.unref(shareInfo),
  265. navbar: "goods"
  266. })
  267. });
  268. };
  269. }
  270. };
  271. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-efe71281"], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/pages/goods/groupon.vue"]]);
  272. _sfc_main.__runtimeHooks = 3;
  273. wx.createPage(MiniProgramPage);