300 lines
11 KiB
JavaScript
300 lines
11 KiB
JavaScript
"use strict";
|
|
var __async = (__this, __arguments, generator) => {
|
|
return new Promise((resolve, reject) => {
|
|
var fulfilled = (value) => {
|
|
try {
|
|
step(generator.next(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var rejected = (value) => {
|
|
try {
|
|
step(generator.throw(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
});
|
|
};
|
|
const common_vendor = require("../../../common/vendor.js");
|
|
const sheep_index = require("../../../sheep/index.js");
|
|
const sheep_api_promotion_coupon = require("../../../sheep/api/promotion/coupon.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");
|
|
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_coupon_get2 = common_vendor.resolveComponent("s-coupon-get");
|
|
const _easycom_s_activity_pop2 = common_vendor.resolveComponent("s-activity-pop");
|
|
const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
|
|
const _component_layout_default_uni = common_vendor.resolveComponent("layout-default-uni");
|
|
(_easycom_s_empty2 + _easycom_su_swiper2 + _easycom_s_select_sku2 + _easycom_s_coupon_get2 + _easycom_s_activity_pop2 + _easycom_s_layout2 + _component_layout_default_uni)();
|
|
}
|
|
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_coupon_get = () => "../../../sheep/components/s-coupon-get/s-coupon-get.js";
|
|
const _easycom_s_activity_pop = () => "../../../sheep/components/s-activity-pop/s-activity-pop.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 + detailActivityTip + detailTabbar + _easycom_s_coupon_get + _easycom_s_activity_pop + _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 detailActivityTip = () => "./components/detail/detail-activity-tip.js";
|
|
const _sfc_main = {
|
|
__name: "index",
|
|
setup(__props) {
|
|
common_vendor.onPageScroll(() => {
|
|
});
|
|
const isLogin = common_vendor.computed(() => sheep_index.sheep.$store("user").isLogin);
|
|
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 营销活动的列表
|
|
});
|
|
function onSkuChange(e) {
|
|
state.selectedSku = e;
|
|
}
|
|
function onAddCart(e) {
|
|
if (!e.id) {
|
|
sheep_index.sheep.$helper.toast("请选择商品规格");
|
|
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("/modules/mall/order/confirm", {
|
|
data: JSON.stringify({
|
|
items: [
|
|
{
|
|
skuId: e.id,
|
|
count: e.goods_num,
|
|
categoryId: state.goodsInfo.categoryId
|
|
}
|
|
]
|
|
})
|
|
});
|
|
}
|
|
function onActivity() {
|
|
state.showActivityModel = true;
|
|
}
|
|
function onGet(id) {
|
|
return __async(this, null, function* () {
|
|
const { code } = yield sheep_api_promotion_coupon.CouponApi.takeCoupon(id);
|
|
if (code !== 0) {
|
|
return;
|
|
}
|
|
common_vendor.index.showToast({
|
|
title: "领取成功"
|
|
});
|
|
setTimeout(() => {
|
|
getCoupon();
|
|
}, 1e3);
|
|
});
|
|
}
|
|
const shareInfo = common_vendor.computed(() => {
|
|
if (common_vendor.isEmpty(state.goodsInfo))
|
|
return {};
|
|
return sheep_index.sheep.$platform.share.getShareInfo(
|
|
{
|
|
title: state.goodsInfo.name,
|
|
image: sheep_index.sheep.$url.cdn(state.goodsInfo.picUrl),
|
|
desc: state.goodsInfo.introduction,
|
|
params: {
|
|
page: "2",
|
|
query: state.goodsInfo.id
|
|
}
|
|
},
|
|
{
|
|
type: "goods",
|
|
// 商品海报
|
|
title: state.goodsInfo.name,
|
|
// 商品名称
|
|
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.marketPrice)
|
|
// 商品原价
|
|
}
|
|
);
|
|
});
|
|
function getCoupon() {
|
|
return __async(this, null, function* () {
|
|
const { code, data } = yield sheep_api_promotion_coupon.CouponApi.getCouponTemplateList(state.goodsId, 2, 10);
|
|
if (code === 0) {
|
|
state.couponInfo = data;
|
|
}
|
|
});
|
|
}
|
|
common_vendor.onLoad((options) => {
|
|
if (!options.id) {
|
|
state.goodsInfo = null;
|
|
return;
|
|
}
|
|
state.goodsId = options.id;
|
|
sheep_api_product_spu.SpuApi.getSpuDetail(state.goodsId).then((res) => {
|
|
if (res.code !== 0 || !res.data) {
|
|
state.goodsInfo = null;
|
|
return;
|
|
}
|
|
state.skeletonLoading = false;
|
|
state.goodsInfo = res.data;
|
|
if (isLogin.value) {
|
|
sheep_api_product_favorite.FavoriteApi.isFavoriteExists(state.goodsId, "goods").then((res2) => {
|
|
if (res2.code !== 0) {
|
|
return;
|
|
}
|
|
state.goodsInfo.favorite = res2.data;
|
|
});
|
|
}
|
|
});
|
|
getCoupon();
|
|
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: state.skeletonLoading
|
|
}, state.skeletonLoading ? {} : state.goodsInfo === null ? {
|
|
c: common_vendor.p({
|
|
text: "商品不存在或已下架",
|
|
icon: "/static/soldout-empty.png",
|
|
showAction: true,
|
|
actionText: "再逛逛",
|
|
actionUrl: "/modules/mall/goods/list"
|
|
})
|
|
} : common_vendor.e({
|
|
d: 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
|
|
}),
|
|
e: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.selectedSku.price || state.goodsInfo.price)),
|
|
f: state.goodsInfo.marketPrice > 0
|
|
}, state.goodsInfo.marketPrice > 0 ? {
|
|
g: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.selectedSku.marketPrice || state.goodsInfo.marketPrice))
|
|
} : {}, {
|
|
h: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.formatSales)("exact", state.goodsInfo.salesCount)),
|
|
i: 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)
|
|
};
|
|
}),
|
|
j: state.couponInfo.length
|
|
}, state.couponInfo.length ? {
|
|
k: common_vendor.o(($event) => state.showModel = true)
|
|
} : {}, {
|
|
l: common_vendor.t(state.goodsInfo.name),
|
|
m: common_vendor.t(state.goodsInfo.introduction),
|
|
n: common_vendor.o(($event) => state.showSelectSku = true),
|
|
o: common_vendor.o(($event) => state.selectedSku.goods_sku_text = $event),
|
|
p: common_vendor.p({
|
|
sku: state.selectedSku,
|
|
modelValue: state.selectedSku.goods_sku_text
|
|
}),
|
|
q: common_vendor.o(onAddCart),
|
|
r: common_vendor.o(onBuy),
|
|
s: common_vendor.o(onSkuChange),
|
|
t: common_vendor.o(($event) => state.showSelectSku = false),
|
|
v: common_vendor.p({
|
|
goodsInfo: state.goodsInfo,
|
|
show: state.showSelectSku
|
|
}),
|
|
w: common_vendor.p({
|
|
goodsId: state.goodsId
|
|
}),
|
|
x: common_vendor.p({
|
|
content: state.goodsInfo.description
|
|
}),
|
|
y: state.activityList.length > 0
|
|
}, state.activityList.length > 0 ? {
|
|
z: common_vendor.p({
|
|
["activity-list"]: state.activityList
|
|
})
|
|
} : {}, {
|
|
A: state.goodsInfo.stock > 0
|
|
}, state.goodsInfo.stock > 0 ? {
|
|
B: common_vendor.o(($event) => state.showSelectSku = true),
|
|
C: common_vendor.o(($event) => state.showSelectSku = true)
|
|
} : {}, {
|
|
D: common_vendor.o(($event) => state.goodsInfo = $event),
|
|
E: common_vendor.p({
|
|
modelValue: state.goodsInfo
|
|
}),
|
|
F: common_vendor.o(($event) => state.showModel = false),
|
|
G: common_vendor.o(onGet),
|
|
H: common_vendor.o(($event) => state.couponInfo = $event),
|
|
I: common_vendor.p({
|
|
show: state.showModel,
|
|
modelValue: state.couponInfo
|
|
}),
|
|
J: common_vendor.o(($event) => state.showActivityModel = false),
|
|
K: common_vendor.o(($event) => state.activityInfo = $event),
|
|
L: common_vendor.p({
|
|
show: state.showActivityModel,
|
|
modelValue: state.activityInfo
|
|
})
|
|
}), {
|
|
b: state.goodsInfo === null,
|
|
M: common_vendor.p({
|
|
onShareAppMessage: shareInfo.value,
|
|
navbar: "goods"
|
|
})
|
|
});
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-aded4edc"]]);
|
|
_sfc_main.__runtimeHooks = 3;
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=index.js.map
|