"use strict"; const common_vendor = require("../../common/vendor.js"); const common_assets = require("../../common/assets.js"); const sheep_index = require("../../sheep/index.js"); require("../../sheep/request/index.js"); const sheep_api_promotion_activity = require("../../sheep/api/promotion/activity.js"); const sheep_api_product_favorite = require("../../sheep/api/product/favorite.js"); const sheep_hooks_useGoods = require("../../sheep/hooks/useGoods.js"); const sheep_api_product_spu = require("../../sheep/api/product/spu.js"); const sheep_api_distri_share = require("../../sheep/api/distri/share.js"); const sheep_hooks_useModal = require("../../sheep/hooks/useModal.js"); require("../../sheep/api/index.js"); require("../../sheep/api/distri/score.js"); require("../../sheep/api/distri/team.js"); require("../../sheep/api/infra/file.js"); require("../../sheep/config/index.js"); require("../../sheep/api/member/address.js"); require("../../sheep/api/member/auth.js"); require("../../sheep/api/member/point.js"); require("../../sheep/api/member/signin.js"); require("../../sheep/api/member/social.js"); require("../../sheep/api/member/user.js"); require("../../sheep/api/migration/app.js"); require("../../sheep/api/migration/chat.js"); require("../../sheep/api/migration/index.js"); require("../../sheep/api/migration/third.js"); require("../../sheep/api/pay/channel.js"); require("../../sheep/api/pay/order.js"); require("../../sheep/api/pay/wallet.js"); require("../../sheep/api/product/category.js"); require("../../sheep/api/product/comment.js"); require("../../sheep/api/product/history.js"); require("../../sheep/api/promotion/article.js"); require("../../sheep/api/promotion/bargain.js"); require("../../sheep/api/promotion/combination.js"); require("../../sheep/api/promotion/coupon.js"); require("../../sheep/api/promotion/diy.js"); require("../../sheep/api/promotion/rewardActivity.js"); require("../../sheep/api/promotion/seckill.js"); require("../../sheep/api/system/area.js"); require("../../sheep/api/system/voice.js"); require("../../sheep/api/trade/afterSale.js"); require("../../sheep/api/trade/brokerage.js"); require("../../sheep/api/trade/cart.js"); require("../../sheep/api/trade/config.js"); require("../../sheep/api/trade/delivery.js"); require("../../sheep/api/trade/order.js"); require("../../sheep/url/index.js"); require("../../sheep/store/index.js"); require("../../sheep/store/app.js"); require("../../sheep/platform/index.js"); require("../../sheep/platform/provider/wechat/index.js"); require("../../sheep/platform/provider/wechat/miniProgram.js"); require("../../sheep/platform/provider/apple/index.js"); require("../../sheep/platform/share.js"); require("../../sheep/router/index.js"); require("../../sheep/helper/throttle.js"); require("../../sheep/platform/pay.js"); require("../../sheep/helper/index.js"); require("../../sheep/helper/test.js"); require("../../sheep/helper/digit.js"); require("../../sheep/store/user.js"); require("../../sheep/store/cart.js"); require("../../sheep/store/sys.js"); require("../../sheep/store/modal.js"); require("../../sheep/config/zIndex.js"); require("../../sheep/util/index.js"); if (!Array) { const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty"); const _easycom_su_swiper2 = common_vendor.resolveComponent("su-swiper"); const _easycom_s_select_sku2 = common_vendor.resolveComponent("s-select-sku"); const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout"); (_easycom_s_empty2 + _easycom_su_swiper2 + _easycom_s_select_sku2 + _easycom_s_layout2)(); } const _easycom_s_empty = () => "../../sheep/components/s-empty/s-empty.js"; const _easycom_su_swiper = () => "../../sheep/ui/su-swiper/su-swiper.js"; const _easycom_s_select_sku = () => "../../sheep/components/s-select-sku/s-select-sku.js"; const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js"; if (!Math) { (detailNavbar + detailSkeleton + _easycom_s_empty + _easycom_su_swiper + detailCellSku + _easycom_s_select_sku + detailCommentCard + detailContentCard + detailTabbar + _easycom_s_layout)(); } const detailNavbar = () => "./components/detail/detail-navbar.js"; const detailCellSku = () => "./components/detail/detail-cell-sku.js"; const detailTabbar = () => "./components/detail/detail-tabbar.js"; const detailSkeleton = () => "./components/detail/detail-skeleton.js"; const detailCommentCard = () => "./components/detail/detail-comment-card.js"; const detailContentCard = () => "./components/detail/detail-content-card.js"; const _sfc_main = { __name: "index", setup(__props) { common_vendor.onPageScroll(() => { }); const state = common_vendor.reactive({ goodsId: 0, skeletonLoading: true, // SPU 加载中 goodsInfo: {}, // SPU 信息 showSelectSku: false, // 是否展示 SKU 选择弹窗 selectedSku: {}, // 选中的 SKU showModel: false, // 是否展示 Coupon 优惠劵的弹窗 couponInfo: [], // 可领取的 Coupon 优惠劵的列表 showActivityModel: false, // 【满减送/限时折扣】是否展示 Activity 营销活动的弹窗 activityInfo: [], // 【满减送/限时折扣】可参与的 Activity 营销活动的列表 activityList: [], // 【秒杀/拼团/砍价】可参与的 Activity 营销活动的列表 linkId: 0 // 分享时的id }); function onSkuChange(e) { state.selectedSku = e; } function onAddCart(e) { if (!e.id) { sheep_index.sheep.$helper.toast("请选择商品规格"); return; } if (!isLogin.value) { sheep_hooks_useModal.showAuthModal(); return; } sheep_index.sheep.$store("cart").add(e); } function onBuy(e) { if (!state.selectedSku.id) { sheep_index.sheep.$helper.toast("请选择商品规格"); return; } sheep_index.sheep.$router.go("/pages/order/confirm", { data: JSON.stringify({ items: [{ skuId: e.id, count: e.goods_num }], spuType: state.goodsInfo.spuType, spuPayType: state.goodsInfo.spuPayType, highPrecision: state.goodsInfo.highPrecision, // TODO 芋艿:后续清理掉这 2 参数 deliveryType: 1, pointStatus: false }) }); } function onActivity() { state.showActivityModel = true; } const shareInfo = common_vendor.computed(() => { if (common_vendor.lodashExports.isEmpty(state.goodsInfo)) return {}; return sheep_index.sheep.$platform.share.getShareInfo({ title: state.goodsInfo.name, image: sheep_index.sheep.$url.cdn(state.goodsInfo.image), desc: state.goodsInfo.subtitle, params: { page: "2" // query: state.linkId, } }, { type: "goods", // 商品海报 title: state.goodsInfo.name, // 商品标题 introduction: state.goodsInfo.introduction, // image: sheep.$url.cdn(state.goodsInfo.image), // 商品主图 image: sheep_index.sheep.$url.cdn(state.goodsInfo.picUrl), // 商品主图 price: sheep_hooks_useGoods.fen2yuan(state.goodsInfo.price), // 商品价格 original_price: sheep_hooks_useGoods.fen2yuan(state.goodsInfo.maretPrice) // 商品原价 }); }); async function getSpuDetail(id) { sheep_api_product_spu.SpuApi.getSpuDetail(id).then((res) => { if (res.code !== 0 || !res.data) { state.goodsInfo = null; return; } state.skeletonLoading = false; state.goodsInfo = res.data; console.log(state.goodsInfo); if (!isLogin.value) { return; } sheep_api_product_favorite.FavoriteApi.isFavoriteExists(state.goodsId, "goods").then((res2) => { if (res2.code !== 0) { return; } state.goodsInfo.favorite = res2.data; }); }); } async function getLink() { sheep_api_distri_share.ShareApi.getLinkId(3, state.goodsId).then((res) => { if (res.code !== 0) { return; } state.linkId = res.data.linkId; }); } const isLogin = common_vendor.computed(() => sheep_index.sheep.$store("user").isLogin); common_vendor.watch(() => isLogin.value, (newVal) => { if (newVal) { getSpuDetail(state.goodsId); } }); common_vendor.onLoad((options) => { if (!options.id && !options.linkId) { state.goodsInfo = null; return; } state.goodsId = options.id || 0; if (!options.id && options.linkId) { console.log("如果只是没有spuId有linkId的话 要去linkId对应的spuId"); const linkId = options.linkId.toString(); sheep_api_distri_share.ShareApi.getObjectIdByLinkId(linkId).then((res) => { if (res.code !== 0) { return; } state.goodsId = res.data; getSpuDetail(state.goodsId); getLink(); }); common_vendor.index.setStorageSync("linkId", options.linkId); } else { getSpuDetail(state.goodsId); } sheep_api_promotion_activity.ActivityApi.getActivityListBySpuId(state.goodsId).then((res) => { if (res.code !== 0) { return; } res.data.forEach((activity) => { if ([1, 2, 3].includes(activity.type)) { state.activityList.push(activity); } else if (activity.type === 5) { state.activityInfo.push(activity); } else { console.log("待实现!优先级不高"); } }); }); }); return (_ctx, _cache) => { return common_vendor.e({ a: common_vendor.o(($event) => state.goodsInfo = $event), b: common_vendor.p({ modelValue: state.goodsInfo }), c: state.skeletonLoading }, state.skeletonLoading ? {} : state.goodsInfo === null ? { e: common_vendor.p({ text: "商品不存在或已下架", icon: "/static/soldout-empty.png", showAction: true, actionText: "再逛逛", actionUrl: "/pages/goods/list" }) } : common_vendor.e({ f: common_vendor.p({ isPreview: true, list: common_vendor.unref(sheep_hooks_useGoods.formatGoodsSwiper)(state.goodsInfo.sliderPicUrls), otStyle: "tag", imageMode: "widthFix", dotCur: "bg-mask-40", seizeHeight: 750 }), g: state.goodsInfo.spuPayType == 2 }, state.goodsInfo.spuPayType == 2 ? { h: common_assets._imports_0 } : {}, { i: state.goodsInfo.highPrecision }, state.goodsInfo.highPrecision ? { j: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan6)(state.selectedSku.highPrecisionPrice || state.goodsInfo.highPrecisionPrice)) } : { k: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.selectedSku.price || state.goodsInfo.price)) }, { l: state.goodsInfo.promotionFee >= 0 }, state.goodsInfo.promotionFee >= 0 ? { m: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.selectedSku.promotionFee || state.goodsInfo.promotionFee)) } : {}, { n: common_vendor.f(state.activityInfo, (promos, k0, i0) => { return { a: common_vendor.t(promos.name), b: promos.id, c: common_vendor.o(onActivity, promos.id) }; }), o: state.couponInfo.length }, state.couponInfo.length ? { p: common_vendor.o(($event) => state.showModel = true) } : {}, { q: common_vendor.t(state.goodsInfo.name), r: common_vendor.t(state.goodsInfo.introduction), s: common_vendor.o(($event) => state.showSelectSku = true), t: common_vendor.o(($event) => state.selectedSku.goods_sku_text = $event), v: common_vendor.p({ sku: state.selectedSku, modelValue: state.selectedSku.goods_sku_text }), w: common_vendor.o(onAddCart), x: common_vendor.o(onBuy), y: common_vendor.o(onSkuChange), z: common_vendor.o(($event) => state.showSelectSku = false), A: common_vendor.p({ goodsInfo: state.goodsInfo, show: state.showSelectSku }), B: common_vendor.p({ goodsId: state.goodsId }), C: common_vendor.p({ content: state.goodsInfo.description }), D: state.goodsInfo.stock > 0 && state.goodsInfo.spuType && state.goodsInfo.spuPayType == 1 }, state.goodsInfo.stock > 0 && state.goodsInfo.spuType && state.goodsInfo.spuPayType == 1 ? { E: common_vendor.o(($event) => state.showSelectSku = true), F: common_vendor.o(($event) => state.showSelectSku = true) } : state.goodsInfo.stock > 0 && state.goodsInfo.spuPayType != 1 || !state.goodsInfo.spuType ? common_vendor.e({ H: state.goodsInfo.spuPayType != 1 && !state.goodsInfo.spuType }, state.goodsInfo.spuPayType != 1 && !state.goodsInfo.spuType ? {} : !state.goodsInfo.spuType ? {} : {}, { I: !state.goodsInfo.spuType, J: common_vendor.o(($event) => state.showSelectSku = true) }) : {}, { G: state.goodsInfo.stock > 0 && state.goodsInfo.spuPayType != 1 || !state.goodsInfo.spuType, K: common_vendor.o(($event) => state.goodsInfo = $event), L: common_vendor.p({ modelValue: state.goodsInfo }) }), { d: state.goodsInfo === null, M: common_vendor.p({ onShareAppMessage: shareInfo.value, navbar: "goods" }) }); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-24a31e85"], ["__file", "D:/zx/mall-front-app/pages/goods/index.vue"]]); _sfc_main.__runtimeHooks = 3; wx.createPage(MiniProgramPage);