"use strict";
const common_vendor = require("../../common/vendor.js");
const sheep_index = require("../../sheep/index.js");
const sheep_hooks_useGoods = require("../../sheep/hooks/useGoods.js");
const sheep_api_promotion_seckill = require("../../sheep/api/promotion/seckill.js");
const sheep_api_product_spu = require("../../sheep/api/product/spu.js");
const sheep_util_const = require("../../sheep/util/const.js");
require("../../sheep/api/index.js");
require("../../sheep/api/distri/score.js");
require("../../sheep/request/index.js");
require("../../sheep/config/index.js");
require("../../sheep/store/index.js");
require("../../sheep/store/app.js");
require("../../sheep/api/promotion/diy.js");
require("../../sheep/platform/index.js");
require("../../sheep/platform/provider/wechat/index.js");
require("../../sheep/platform/provider/wechat/miniProgram.js");
require("../../sheep/api/member/auth.js");
require("../../sheep/api/member/social.js");
require("../../sheep/api/member/user.js");
require("../../sheep/platform/provider/apple/index.js");
require("../../sheep/platform/share.js");
require("../../sheep/router/index.js");
require("../../sheep/hooks/useModal.js");
require("../../sheep/helper/index.js");
require("../../sheep/helper/test.js");
require("../../sheep/helper/digit.js");
require("../../sheep/api/member/signin.js");
require("../../sheep/helper/throttle.js");
require("../../sheep/url/index.js");
require("../../sheep/platform/pay.js");
require("../../sheep/api/pay/order.js");
require("../../sheep/store/user.js");
require("../../sheep/store/cart.js");
require("../../sheep/api/trade/cart.js");
require("../../sheep/api/pay/wallet.js");
require("../../sheep/api/trade/order.js");
require("../../sheep/api/promotion/coupon.js");
require("../../sheep/store/sys.js");
require("../../sheep/store/modal.js");
require("../../sheep/api/distri/share.js");
require("../../sheep/api/distri/team.js");
require("../../sheep/api/infra/file.js");
require("../../sheep/api/member/address.js");
require("../../sheep/api/member/point.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/product/category.js");
require("../../sheep/api/product/comment.js");
require("../../sheep/api/product/favorite.js");
require("../../sheep/api/product/history.js");
require("../../sheep/api/promotion/activity.js");
require("../../sheep/api/promotion/article.js");
require("../../sheep/api/promotion/bargain.js");
require("../../sheep/api/promotion/combination.js");
require("../../sheep/api/promotion/rewardActivity.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/config.js");
require("../../sheep/api/trade/delivery.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_seckill_sku2 = common_vendor.resolveComponent("s-select-seckill-sku");
  const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  (_easycom_s_empty2 + _easycom_su_swiper2 + _easycom_s_select_seckill_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_seckill_sku = () => "../../sheep/components/s-select-seckill-sku/s-select-seckill-sku.js";
const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
if (!Math) {
  (detailNavbar + detailSkeleton + _easycom_s_empty + _easycom_su_swiper + detailProgress + detailCellSku + _easycom_s_select_seckill_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 detailProgress = () => "./components/detail/detail-progress.js";
const _sfc_main = {
  __name: "seckill",
  setup(__props) {
    common_vendor.useCssVars((_ctx) => ({
      "4f732cf8": common_vendor.unref(headerBg),
      "52c6d9a2": common_vendor.unref(btnBg),
      "7fa54813": common_vendor.unref(disabledBtnBg),
      "056c2c42": common_vendor.unref(seckillBg),
      "3634f41e": common_vendor.unref(grouponBg)
    }));
    const headerBg = sheep_index.sheep.$url.css("/static/img/shop/goods/seckill-bg.png");
    const btnBg = sheep_index.sheep.$url.css("/static/img/shop/goods/seckill-btn.png");
    const disabledBtnBg = sheep_index.sheep.$url.css(
      "/static/img/shop/goods/activity-btn-disabled.png"
    );
    const seckillBg = sheep_index.sheep.$url.css("/static/img/shop/goods/seckill-tip-bg.png");
    const grouponBg = sheep_index.sheep.$url.css("/static/img/shop/goods/groupon-tip-bg.png");
    common_vendor.onPageScroll(() => {
    });
    const state = common_vendor.reactive({
      skeletonLoading: true,
      goodsInfo: {},
      showSelectSku: false,
      goodsSwiper: [],
      selectedSku: {},
      showModel: false,
      total: 0,
      percent: 0,
      price: ""
    });
    const endTime = common_vendor.computed(() => {
      return sheep_hooks_useGoods.useDurationTime(activity.value.endTime);
    });
    function onSkuChange(e) {
      state.selectedSku = e;
    }
    function onBuy(sku) {
      sheep_index.sheep.$router.go("/pages/order/confirm", {
        data: JSON.stringify({
          order_type: "goods",
          buy_type: "seckill",
          seckillActivityId: activity.value.id,
          items: [
            {
              skuId: sku.id,
              count: sku.count
            }
          ]
        })
      });
    }
    const shareInfo = common_vendor.computed(() => {
      if (common_vendor.lodashExports.isEmpty(activity))
        return {};
      return sheep_index.sheep.$platform.share.getShareInfo(
        {
          title: activity.value.name,
          image: sheep_index.sheep.$url.cdn(state.goodsInfo.picUrl),
          params: {
            page: "4",
            query: activity.value.id
          }
        },
        {
          type: "goods",
          // 商品海报
          title: activity.value.name,
          // 商品标题
          image: sheep_index.sheep.$url.cdn(state.goodsInfo.picUrl),
          // 商品主图
          price: state.goodsInfo.price,
          // 商品价格
          marketPrice: state.goodsInfo.marketPrice
          // 商品原价
        }
      );
    });
    const activity = common_vendor.ref();
    const timeStatusEnum = common_vendor.ref("");
    const getActivity = async (id) => {
      const { data } = await sheep_api_promotion_seckill.SeckillApi.getSeckillActivity(id);
      activity.value = data;
      timeStatusEnum.value = sheep_util_const.getTimeStatusEnum(activity.startTime, activity.endTime);
      await getSpu(data.spuId);
    };
    const getSpu = async (id) => {
      const { data } = await sheep_api_product_spu.SpuApi.getSpuDetail(id);
      data.activity_type = "seckill";
      state.goodsInfo = data;
      state.goodsSwiper = sheep_hooks_useGoods.formatGoodsSwiper(state.goodsInfo.sliderPicUrls);
      state.goodsInfo.price = common_vendor.lodashExports.min([state.goodsInfo.price, ...activity.value.products.map((spu) => spu.seckillPrice)]);
      data.skus.forEach((sku) => {
        const product = activity.value.products.find((product2) => product2.skuId === sku.id);
        if (product) {
          sku.price = product.seckillPrice;
          sku.stock = Math.min(sku.stock, product.stock);
        } else {
          sku.stock = 0;
        }
        if (activity.value.totalLimitCount > 0 && activity.value.singleLimitCount > 0) {
          sku.limitCount = Math.min(activity.value.totalLimitCount, activity.value.singleLimitCount);
        } else if (activity.value.totalLimitCount > 0) {
          sku.limitCount = activity.value.totalLimitCount;
        } else if (activity.value.singleLimitCount > 0) {
          sku.limitCount = activity.value.singleLimitCount;
        }
      });
      state.skeletonLoading = false;
    };
    common_vendor.onLoad((options) => {
      if (!options.id) {
        state.goodsInfo = null;
        return;
      }
      getActivity(options.id);
    });
    return (_ctx, _cache) => {
      var _a;
      return common_vendor.e({
        a: state.skeletonLoading
      }, state.skeletonLoading ? {} : state.goodsInfo === null || state.goodsInfo.activity_type !== "seckill" ? {
        c: common_vendor.p({
          text: "活动不存在或已结束",
          icon: "/static/soldout-empty.png",
          showAction: true,
          actionText: "再逛逛",
          actionUrl: "/pages/goods/list"
        })
      } : common_vendor.e({
        d: common_vendor.p({
          isPreview: true,
          list: state.goodsSwiper,
          dotStyle: "tag",
          imageMode: "widthFix",
          dotCur: "bg-mask-40",
          seizeHeight: 750
        }),
        e: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.selectedSku.price || state.goodsInfo.price)),
        f: endTime.value.ms > 0
      }, endTime.value.ms > 0 ? {
        g: common_vendor.t(endTime.value.h),
        h: common_vendor.t(endTime.value.m),
        i: common_vendor.t(endTime.value.s)
      } : {}, {
        j: state.goodsInfo.marketPrice
      }, state.goodsInfo.marketPrice ? {
        k: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.selectedSku.marketPrice || state.goodsInfo.marketPrice))
      } : {}, {
        l: common_vendor.p({
          percent: state.percent
        }),
        m: common_vendor.t((_a = state.goodsInfo) == null ? void 0 : _a.name),
        n: common_vendor.t(state.goodsInfo.introduction),
        o: common_vendor.o(($event) => state.showSelectSku = true),
        p: common_vendor.p({
          sku: state.selectedSku
        }),
        q: common_vendor.o(onBuy),
        r: common_vendor.o(onSkuChange),
        s: common_vendor.o(($event) => state.showSelectSku = false),
        t: common_vendor.o(($event) => state.goodsInfo = $event),
        v: common_vendor.p({
          show: state.showSelectSku,
          ["single-limit-count"]: activity.value.singleLimitCount,
          modelValue: state.goodsInfo
        }),
        w: common_vendor.p({
          goodsId: state.goodsInfo.id
        }),
        x: common_vendor.p({
          content: state.goodsInfo.description
        }),
        y: state.goodsInfo.marketPrice
      }, state.goodsInfo.marketPrice ? {
        z: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.goodsInfo.marketPrice)),
        A: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/goods/index", {
          id: state.goodsInfo.id
        }))
      } : {
        B: common_vendor.n(state.goodsInfo.stock === 0 || timeStatusEnum.value !== common_vendor.unref(sheep_util_const.TimeStatusEnum).STARTED ? "" : "")
      }, {
        C: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.goodsInfo.price)),
        D: timeStatusEnum.value === common_vendor.unref(sheep_util_const.TimeStatusEnum).STARTED
      }, timeStatusEnum.value === common_vendor.unref(sheep_util_const.TimeStatusEnum).STARTED ? common_vendor.e({
        E: state.goodsInfo.stock === 0
      }, state.goodsInfo.stock === 0 ? {} : {}) : {
        F: common_vendor.t(timeStatusEnum.value)
      }, {
        G: common_vendor.o(($event) => state.showSelectSku = true),
        H: common_vendor.n(timeStatusEnum.value === common_vendor.unref(sheep_util_const.TimeStatusEnum).STARTED && state.goodsInfo.stock != 0 ? "check-btn-box" : "disabled-btn-box"),
        I: state.goodsInfo.stock === 0 || timeStatusEnum.value !== common_vendor.unref(sheep_util_const.TimeStatusEnum).STARTED,
        J: common_vendor.o(($event) => state.goodsInfo = $event),
        K: common_vendor.p({
          modelValue: state.goodsInfo
        })
      }), {
        b: state.goodsInfo === null || state.goodsInfo.activity_type !== "seckill",
        L: common_vendor.s(_ctx.__cssVars()),
        M: common_vendor.p({
          onShareAppMessage: shareInfo.value,
          navbar: "goods"
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-960ccb8e"], ["__file", "D:/zx/mall-front-app/pages/goods/seckill.vue"]]);
_sfc_main.__runtimeHooks = 3;
wx.createPage(MiniProgramPage);
