groupon.js 11 KB

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