"use strict"; const common_vendor = require("../../common/vendor.js"); const utils_request = require("../../utils/request.js"); const utils_moldSearch = require("../../utils/moldSearch.js"); const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({ __name: "index", setup(__props) { const molds = common_vendor.ref([]); const keyword = common_vendor.ref(""); const loading = common_vendor.ref(false); const statusBarHeight = common_vendor.ref(20); const navBarHeight = common_vendor.ref(44); try { const sysInfo = common_vendor.index.getSystemInfoSync(); statusBarHeight.value = sysInfo.statusBarHeight || 20; const menuBtn = common_vendor.index.getMenuButtonBoundingClientRect(); navBarHeight.value = (menuBtn.top - (sysInfo.statusBarHeight || 20)) * 2 + menuBtn.height; } catch { } const filteredMolds = common_vendor.computed(() => utils_moldSearch.searchMolds(molds.value, keyword.value)); function fullUrl(path) { if (!path) return ""; if (path.startsWith("http")) return path; return utils_request.BASE_URL + path; } function parseImages(images) { if (Array.isArray(images)) return images; if (typeof images === "string") { try { return JSON.parse(images); } catch { return []; } } return []; } function onSearchInput(e) { keyword.value = e.detail.value; } function doSearch() { } function previewImage(images, current) { const urls = images.map((img) => fullUrl(img)); common_vendor.index.previewImage({ urls, current: urls[current] }); } function contactService() { common_vendor.index.showModal({ title: "联系客服", content: "如需定制服务,请添加客服微信咨询", showCancel: false }); } async function loadMolds() { loading.value = true; try { const res = await utils_request.get("/api/molds", { pageSize: 100 }); const list = (res == null ? void 0 : res.list) || []; molds.value = list.map((m) => ({ ...m, images: parseImages(m.images) })); } catch { } finally { loading.value = false; } } common_vendor.onMounted(() => { loadMolds(); }); common_vendor.onShow(() => { loadMolds(); }); return (_ctx, _cache) => { return common_vendor.e({ a: navBarHeight.value + "px", b: statusBarHeight.value + "px", c: keyword.value, d: common_vendor.o(onSearchInput), e: common_vendor.o(doSearch), f: common_vendor.f(filteredMolds.value, (mold, k0, i0) => { return common_vendor.e({ a: common_vendor.t(mold.name), b: (mold.images || []).length > 0 }, (mold.images || []).length > 0 ? { c: common_vendor.f(mold.images || [], (img, idx, i1) => { return { a: idx, b: fullUrl(img), c: common_vendor.o(($event) => previewImage(mold.images || [], idx), idx) }; }) } : {}, { d: mold.styleNo }, mold.styleNo ? { e: common_vendor.t(mold.styleNo) } : {}, { f: mold.style }, mold.style ? { g: common_vendor.t(mold.style) } : {}, { h: mold.id }); }), g: !loading.value && filteredMolds.value.length === 0 }, !loading.value && filteredMolds.value.length === 0 ? common_vendor.e({ h: common_vendor.t(keyword.value ? "未找到匹配结果" : "暂无版房信息"), i: keyword.value }, keyword.value ? { j: common_vendor.o(contactService) } : {}) : {}, { k: loading.value }, loading.value ? {} : {}); }; } }); const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-406d5d2c"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/mold/index.js.map