"use strict"; const common_vendor = require("../../common/vendor.js"); const hooks_useToast = require("../../hooks/useToast.js"); const api_index = require("../../api/index.js"); if (!Array) { const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons"); const _component_up_line = common_vendor.resolveComponent("up-line"); (_easycom_uni_icons2 + _component_up_line)(); } const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js"; if (!Math) { (common_vendor.unref(productConSwiper) + _easycom_uni_icons + common_vendor.unref(productWindow) + common_vendor.unref(couponListWindow))(); } const productConSwiper = () => "../../components/productConSwiper/index.js"; const couponListWindow = () => "../../components/couponListWindow/index.js"; const productWindow = () => "../../components/productWindow/index.js"; const _sfc_main = { __name: "index", setup(__props) { const { Toast } = hooks_useToast.useToast(); const coupon = common_vendor.ref({ coupon: false, type: 1, list: [], count: [] }); const attrTxt = common_vendor.ref("请选择"); const attrValue = common_vendor.ref(""); common_vendor.ref(false); const id = common_vendor.ref(0); const productInfo = common_vendor.ref({}); const productValue = common_vendor.ref([]); common_vendor.ref([]); common_vendor.ref(1); common_vendor.ref(false); const storeImage = common_vendor.ref(""); common_vendor.ref(""); common_vendor.ref("/static/images/posterbackgd.png"); const sharePacket = common_vendor.ref({ isState: true }); common_vendor.ref(""); common_vendor.ref([]); common_vendor.ref(0); common_vendor.ref(false); const attr = common_vendor.ref({ cartAttr: false, productAttr: [], productSelect: {} }); const description = common_vendor.ref(""); common_vendor.ref(0); const activityH5 = common_vendor.ref([]); const retunTop = common_vendor.ref(true); common_vendor.ref(""); const opacity = common_vendor.ref(0); const scrollY = common_vendor.ref(0); common_vendor.ref([]); const height = common_vendor.ref(0); common_vendor.ref([]); const lock = common_vendor.ref(false); const scrollTop = common_vendor.ref(0); const sliderImage = common_vendor.ref([]); common_vendor.ref(false); common_vendor.ref(""); const imgTop = common_vendor.ref(""); common_vendor.ref(""); const homeTop = common_vendor.ref(20); const userCollect = common_vendor.ref(false); const returnShow = common_vendor.ref(true); const type = common_vendor.ref(""); const showProductPopup = common_vendor.ref(false); const showCouponPopup = common_vendor.ref(false); const handleBtnTpe = common_vendor.ref(""); common_vendor.onLoad((options) => { const pages = getCurrentPages(); returnShow.value = pages.length > 1; retunTop.value = pages.length > 1; setTimeout(() => { if (options.spread) { spread(options.spread).catch(() => { }); } }, 2e3); common_vendor.index.getSystemInfo({ success(res) { height.value = res.windowHeight; } }); if (options.id || options.scene) { if (options.scene) { const qrCodeValue = $util.getUrlParams(decodeURIComponent(options.scene)); const mapeMpQrCodeValue = $util.formatMpQrCodeData(qrCodeValue); id.value = mapeMpQrCodeValue.id; setTimeout(() => { spread(mapeMpQrCodeValue.spread).catch(() => { }); }, 2e3); } else { id.value = options.id; } type.value = options.type ?? "normal"; } getGoodsDetails(); }); common_vendor.onShow(() => { getCartCount(); }); common_vendor.onReady(() => { const menuButton = common_vendor.index.getMenuButtonBoundingClientRect(); const query = common_vendor.index.createSelectorQuery().in(this); query.select("#home").boundingClientRect((data) => { homeTop.value = menuButton.top * 2 + menuButton.height - data.height; }).exec(); }); const handleScroll = (e) => { const scrollYVal = e.detail.scrollTop; const opacityVal = scrollYVal / 350 > 1 ? 1 : scrollYVal / 350; opacity.value = opacityVal; scrollY.value = scrollYVal; if (lock.value) { lock.value = false; return; } }; const getGoodsDetails = async () => { try { const res = await api_index.getArticleDetailId("34"); const product = res.data.productInfo; sliderImage.value = [product.image]; common_vendor.index.__f__("log", "at pages/goods_details/index.vue:453", "sliderImage.value", sliderImage.value); productInfo.value = product; common_vendor.index.__f__("log", "at pages/goods_details/index.vue:455", "productInfo.value", productInfo.value); description.value = product.content; common_vendor.index.__f__("log", "at pages/goods_details/index.vue:457", "description.value", description.value); userCollect.value = res.data.userCollect; attr.value.productAttr = res.data.productAttr; common_vendor.index.__f__("log", "at pages/goods_details/index.vue:460", "res.data.productValue", res.data); productValue.value = res.data.productValue; sharePacket.value.priceName = res.data.priceName; sharePacket.value.isState = Math.floor(res.data.priceName) !== 0; activityH5.value = res.data.activityAllH5 || []; common_vendor.index.setNavigationBarTitle({ title: product.storeName.substring(0, 7) + "..." }); attr.value.productAttr = attr.value.productAttr.map((item) => ({ attrName: item.attrName, attrValues: item.attrValues.split(","), id: item.id, isDel: item.isDel, productId: item.productId, type: item.type })); imgTop.value = productInfo.value.image; downloadFilestoreImage(); DefaultSelect(); } catch (err) { Toast({ title: err.toString(), icon: "none" }); } }; const DefaultSelect = () => { let value = []; common_vendor.index.__f__("log", "at pages/goods_details/index.vue:523", "productValue.value", common_vendor.toRaw(productValue.value)); const keys = Object.keys(productValue.value); common_vendor.index.__f__("log", "at pages/goods_details/index.vue:525", "keys", keys); for (let i = 0; i < keys.length; i++) { const key = keys[i]; common_vendor.index.__f__("log", "at pages/goods_details/index.vue:528", "key", key); value = attr.value.productAttr.length ? key.split(",") : []; } common_vendor.index.__f__("log", "at pages/goods_details/index.vue:534", "value", value); attr.value.productAttr.forEach((item, i) => { item.index = value[i]; }); const productSelect = productValue.value[value.join(",")]; common_vendor.index.__f__("log", "at pages/goods_details/index.vue:539", { productSelect }); common_vendor.index.__f__("log", "at pages/goods_details/index.vue:542", { attr }); if (productSelect && attr.value.productAttr.length) { attr.value.productSelect = { ...attr.value.productSelect, storeName: productInfo.value.storeName, image: productSelect.image, sales: productSelect.sales, weight: productSelect.weight, price: productSelect.price, storePrice: productSelect.storePrice, stock: productSelect.stock, unique: productSelect.id, cart_num: 1 }; attrValue.value = value.join(","); attrTxt.value = "已选择"; } else if (!productSelect && attr.value.productAttr.length) { attr.value.productSelect = { ...attr.value.productSelect, storeName: productInfo.value.storeName, image: productInfo.value.image, sales: productSelect.sales, weight: productSelect.weight, price: productInfo.value.price, storePrice: productSelect.storePrice, stock: 0, unique: productInfo.value.id, cart_num: 1 }; attrValue.value = ""; attrTxt.value = "请选择"; } else if (!productSelect && !attr.value.productAttr.length) { attr.value.productSelect = { ...attr.value.productSelect, storeName: productInfo.value.storeName, image: productInfo.value.image, sales: productSelect.sales, weight: productSelect.weight, price: productInfo.value.price, storePrice: productSelect.storePrice, stock: productInfo.value.stock, unique: productInfo.value.id || "", cart_num: 1 }; attrValue.value = ""; attrTxt.value = "请选择"; } }; const selecAttr = () => { showProductPopup.value = true; handleBtnTpe.value = "buy"; }; const handleCoupon = () => { }; const toShopCart = () => { }; const getCartCount = async (isAnima = false) => { }; const setDomain = (url) => { url = url ? url.toString() : ""; return url.includes("https://") ? url : url.replace("http://", "https://"); }; const downloadFilestoreImage = async () => { try { const res = await common_vendor.index.downloadFile({ url: setDomain(productInfo.value.image) }); storeImage.value = res.tempFilePath; } catch { storeImage.value = ""; } }; function toMessagePage() { common_vendor.index.navigateTo({ url: "/pages/message_create/message_create" }); } return (_ctx, _cache) => { var _a; return common_vendor.e({ a: common_vendor.p({ ["indicator-dots"]: false, imgUrls: sliderImage.value }), b: common_vendor.t(productInfo.value.storeName), c: common_vendor.t(attr.value.productSelect.price || 0), d: common_vendor.t(attr.value.productSelect.weight), e: common_vendor.t(Number(((_a = attr.value.productSelect) == null ? void 0 : _a.sales) || 0)), f: common_vendor.t(productInfo.value.unitName || ""), g: common_vendor.t(attr.value.productSelect.storePrice), h: coupon.value.list.length > 0 }, coupon.value.list.length > 0 ? { i: common_vendor.t(coupon.value.list[0].minPrice), j: common_vendor.t(coupon.value.list[0].money), k: common_vendor.o(handleCoupon) } : {}, { l: common_vendor.t(attrTxt.value), m: common_vendor.t(attrValue.value), n: common_vendor.o(selecAttr), o: common_vendor.p({ type: "cart", size: "24" }), p: common_vendor.p({ color: "#ccc", length: "100%", margin: "10px 0" }), q: common_vendor.p({ size: "24", type: "hand-up" }), r: scrollTop.value, s: common_vendor.s("height:" + height.value + "px;"), t: common_vendor.o(handleScroll), v: common_vendor.p({ size: "22", color: "#666", customPrefix: "iconfont", type: "icon-shouye" }), w: common_vendor.p({ size: "22", color: "#666", customPrefix: "iconfont", type: "icon-kefu1" }), x: common_vendor.o(toMessagePage), y: common_vendor.p({ size: "22", color: "#666", customPrefix: "iconfont", type: "icon-gouwuche" }), z: common_vendor.o(toShopCart), A: common_vendor.p({ attr: attr.value, isShow: 1, iSplus: 1, showPopup: showProductPopup.value, id: "product-window" }), B: common_vendor.p({ coupon: coupon.value, showPopup: showCouponPopup.value }) }); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-c5c6bbf1"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/goods_details/index.js.map