"use strict"; const common_vendor = require("../../common/vendor.js"); const apiservice_apiService = require("../../apiservice/apiService.js"); const _sfc_main = { setup() { const tabs = ["景区动态", "新闻报道", "活动演出", "景区通知"]; const currentTab = common_vendor.ref(0); let notices = common_vendor.ref([]); const loading = common_vendor.ref(false); const fetchnotices = async () => { loading.value = true; try { const res = await apiservice_apiService.apiService.noticeList(); if (res.code === 1e3) { notices.value = res.data; } else { common_vendor.index.__f__("warn", "at pages/index/notices.vue:77", "查询失败:", res.message); } } catch (error) { common_vendor.index.__f__("error", "at pages/index/notices.vue:81", "获取预约信息错误:", error); common_vendor.index.showToast({ title: "网络错误", icon: "none" }); } finally { loading.value = false; } }; const parseContentImg = (content = "") => { if (!content || typeof content !== "string") { return null; } const imgMatch = content.match(/]+src=["']?([^"'>]+)["']?/i); const imgSrc = imgMatch ? imgMatch[1] : null; return imgSrc; }; const parseContentText = (content = "") => { if (!content || typeof content !== "string") { return ""; } let text = content.replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim(); if (text.length > 50) { text = text.slice(0, 50) + "......"; } return text; }; const gotoDetail = (item) => { const data = encodeURIComponent(JSON.stringify(item)); common_vendor.index.navigateTo({ url: `/pages/index/notices-detail?data=${data}` }); }; const filterednotices = common_vendor.computed(() => { return notices.value.filter((item) => item.category === tabs[currentTab.value]); }); const onTabChange = (e) => { currentTab.value = e.currentIndex; }; common_vendor.onMounted(() => { fetchnotices(); }); return { tabs, currentTab, notices, filterednotices, loading, onTabChange, parseContentImg, parseContentText, gotoDetail }; } }; if (!Array) { const _easycom_uni_segmented_control2 = common_vendor.resolveComponent("uni-segmented-control"); _easycom_uni_segmented_control2(); } const _easycom_uni_segmented_control = () => "../../uni_modules/uni-segmented-control/components/uni-segmented-control/uni-segmented-control.js"; if (!Math) { _easycom_uni_segmented_control(); } function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: common_vendor.o($setup.onTabChange), b: common_vendor.p({ current: $setup.currentTab, values: $setup.tabs, ["style-type"]: "button", ["active-color"]: "#3b82f6" }), c: $setup.loading }, $setup.loading ? {} : {}, { d: common_vendor.f($setup.filterednotices, (item, index, i0) => { return { a: $setup.parseContentImg(item.content) || `https://farm.evcc.top/Uploads/yuanboyuan/news/${encodeURIComponent(item.category)}.jpg`, b: common_vendor.t(item.title.length > 36 ? item.title.slice(0, 36) + "……" : item.title), c: common_vendor.t(item.createTime), d: index, e: common_vendor.o(($event) => $setup.gotoDetail(item), index) }; }), e: !$setup.filterednotices.length }, !$setup.filterednotices.length ? { f: common_vendor.t($setup.tabs[$setup.currentTab]) } : {}); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/notices.js.map