groupon.js 12 KB

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