wangzhibo
2025-10-23 cad64c1de2c45856b0774933c5801b05b64984e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
"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(/<img[^>]+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