Files
cmgd-mini-app/unpackage/dist/dev/mp-weixin/pages/mall/detail.js
2026-01-05 12:47:14 +08:00

137 lines
5.1 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const utils_helper = require("../../utils/helper.js");
const api_goods = require("../../api/goods.js");
const api_config = require("../../api/config.js");
if (!Array) {
const _easycom_nut_watermark2 = common_vendor.resolveComponent("nut-watermark");
const _easycom_nut_cell_group2 = common_vendor.resolveComponent("nut-cell-group");
const _easycom_nut_icon2 = common_vendor.resolveComponent("nut-icon");
const _easycom_nut_button2 = common_vendor.resolveComponent("nut-button");
(_easycom_nut_watermark2 + _easycom_nut_cell_group2 + _easycom_nut_icon2 + _easycom_nut_button2)();
}
const _easycom_nut_watermark = () => "../../uni_modules/nutui-uni/components/watermark/watermark.js";
const _easycom_nut_cell_group = () => "../../uni_modules/nutui-uni/components/cellgroup/cellgroup.js";
const _easycom_nut_icon = () => "../../uni_modules/nutui-uni/components/icon/icon.js";
const _easycom_nut_button = () => "../../uni_modules/nutui-uni/components/button/button.js";
if (!Math) {
(_easycom_nut_watermark + _easycom_nut_cell_group + _easycom_nut_icon + _easycom_nut_button)();
}
const _sfc_main = {
__name: "detail",
setup(__props) {
const audit = common_vendor.ref(true);
const serviceTxt = common_vendor.ref("");
const id = common_vendor.ref(0);
const detail = common_vendor.reactive({});
common_vendor.onLoad((options) => {
common_vendor.index.__f__("log", "at pages/mall/detail.vue:110", "init");
getConfig();
id.value = options.id;
api_goods.fetchGoodsDetail(id.value).then((res) => {
Object.assign(detail, res);
});
});
const buyNow = (goodsId) => {
let token = common_vendor.index.getStorageSync("token");
if (token) {
common_vendor.index.__f__("log", "at pages/mall/detail.vue:127", "已经登陆");
common_vendor.index.navigateTo({
url: `/pages/order/preview?ids=${goodsId}&from=item`
});
} else {
utils_helper.goToLoginPage();
}
};
const getConfig = () => {
api_config.fetchGetConfig().then((res) => {
common_vendor.index.__f__("log", "at pages/mall/detail.vue:140", "getConfig=====>", res);
audit.value = res.appConfig.is_audit == 1;
serviceTxt.value = res.appConfig.service_txt;
});
};
common_vendor.onShareTimeline((res) => {
return {
title: detail.goods_name,
path: "/pages/mall/detail?id=" + detail.goods_id,
imageUrl: detail.image[0].file_path
};
});
common_vendor.onShareAppMessage((res) => {
return {
title: detail.goods_name,
path: "/pages/mall/detail?id=" + detail.goods_id,
imageUrl: detail.image[0].file_path
};
});
const showGoodsImages = (index) => {
common_vendor.index.previewImage({
current: index,
// 指定当前显示的图片索引
urls: detail.image.map((e) => {
return e.file_path;
})
});
};
return (_ctx, _cache) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
return common_vendor.e({
a: ((_a = detail.status) == null ? void 0 : _a.value) === 10
}, ((_b = detail.status) == null ? void 0 : _b.value) === 10 ? {
b: common_vendor.p({
["z-index"]: 1,
content: "此商品已下架"
})
} : {}, {
c: ((_c = detail.status) == null ? void 0 : _c.value) === 30
}, ((_d = detail.status) == null ? void 0 : _d.value) === 30 ? {
d: common_vendor.p({
["z-index"]: 1,
content: "此商品已锁定"
})
} : {}, {
e: ((_e = detail.status) == null ? void 0 : _e.value) === 40
}, ((_f = detail.status) == null ? void 0 : _f.value) === 40 ? {
f: common_vendor.p({
["z-index"]: 1,
content: "此商品已售出"
})
} : {}, {
g: common_vendor.f(detail.image, (item, idx, i0) => {
return {
a: item.file_path,
b: common_vendor.o(($event) => showGoodsImages(idx), idx),
c: idx
};
}),
h: common_vendor.t(detail.goods_price),
i: common_vendor.t((_g = detail.degree) == null ? void 0 : _g.degree_name),
j: common_vendor.t(detail.goods_name),
k: common_vendor.t(detail.content),
l: common_vendor.t(serviceTxt.value),
m: common_vendor.p({
name: "service"
}),
n: ((_h = detail.status) == null ? void 0 : _h.value) === 20
}, ((_i = detail.status) == null ? void 0 : _i.value) === 20 ? common_vendor.e({
o: !audit.value
}, !audit.value ? {
p: common_vendor.o(($event) => buyNow(detail.goods_id)),
q: common_vendor.p({
type: "primary"
})
} : {}) : common_vendor.e({
r: !audit.value
}, !audit.value ? {
s: common_vendor.p({
plain: true
})
} : {}));
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-da39d73f"]]);
_sfc_main.__runtimeHooks = 6;
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/mall/detail.js.map