WXL
11 小时以前 05c363fdd7ab04e3bd9a753e2c5d5bfff04d681c
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const _sfc_main = {
  __name: "list",
  setup(__props) {
    const searchKey = common_vendor.ref("");
    const currentCategory = common_vendor.ref("all");
    const categories = [
      { value: "all", label: "全部" },
      { value: "covid", label: "新冠疫苗" },
      { value: "flu", label: "流感疫苗" },
      { value: "hpv", label: "HPV疫苗" },
      { value: "child", label: "儿童疫苗" }
    ];
    const vaccines = common_vendor.ref([
      {
        id: 1,
        nameKey: "vaccine.list.covid.name",
        descKey: "vaccine.list.covid.desc",
        image: "/static/vaccine/covid.jpg",
        price: 0,
        recommended: true,
        category: "covid"
      },
      {
        id: 2,
        nameKey: "vaccine.list.flu.name",
        descKey: "vaccine.list.flu.desc",
        image: "/static/vaccine/flu.jpg",
        price: 180,
        seasonal: true,
        category: "flu"
      },
      {
        id: 3,
        nameKey: "vaccine.list.hpv.name",
        descKey: "vaccine.list.hpv.desc",
        image: "/static/vaccine/hpv.jpg",
        price: 2800,
        recommended: true,
        category: "hpv"
      }
    ]);
    const currentPage = common_vendor.ref(1);
    const hasMore = common_vendor.ref(true);
    const refreshing = common_vendor.ref(false);
    const filteredVaccines = common_vendor.computed(() => {
      let result = vaccines.value;
      if (searchKey.value) {
        const key = searchKey.value.toLowerCase();
        result = result.filter(
          (vaccine) => vaccine.nameKey.toLowerCase().includes(key) || vaccine.descKey.toLowerCase().includes(key)
        );
      }
      if (currentCategory.value !== "all") {
        result = result.filter((vaccine) => vaccine.category === currentCategory.value);
      }
      return result;
    });
    const selectCategory = (category) => {
      currentCategory.value = category;
    };
    const viewDetail = (vaccine) => {
      common_vendor.index.navigateTo({
        url: `/pages/vaccine/detail?id=${vaccine.id}`
      });
    };
    const bookVaccine = (vaccine) => {
      common_vendor.index.navigateTo({
        url: `/pages/vaccine/book?id=${vaccine.id}`
      });
    };
    const onRefresh = () => {
      refreshing.value = true;
      currentPage.value = 1;
      loadVaccines();
      setTimeout(() => {
        refreshing.value = false;
      }, 1e3);
    };
    const onLoadMore = () => {
      if (!hasMore.value)
        return;
      currentPage.value++;
      loadVaccines();
    };
    const loadVaccines = () => {
      setTimeout(() => {
        if (currentPage.value >= 3) {
          hasMore.value = false;
        }
      }, 1e3);
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: _ctx.$t("vaccine.search.placeholder"),
        b: searchKey.value,
        c: common_vendor.o(($event) => searchKey.value = $event.detail.value),
        d: common_vendor.f(categories, (category, index, i0) => {
          return {
            a: common_vendor.t(_ctx.$t(`vaccine.category.${category.value}`)),
            b: index,
            c: currentCategory.value === category.value ? 1 : "",
            d: common_vendor.o(($event) => selectCategory(category.value), index)
          };
        }),
        e: common_vendor.f(filteredVaccines.value, (vaccine, index, i0) => {
          return common_vendor.e({
            a: vaccine.image,
            b: common_vendor.t(_ctx.$t(vaccine.nameKey)),
            c: vaccine.price === 0
          }, vaccine.price === 0 ? {
            d: common_vendor.t(_ctx.$t("vaccine.tag.free"))
          } : {}, {
            e: vaccine.recommended
          }, vaccine.recommended ? {
            f: common_vendor.t(_ctx.$t("vaccine.tag.recommended"))
          } : {}, {
            g: vaccine.seasonal
          }, vaccine.seasonal ? {
            h: common_vendor.t(_ctx.$t("vaccine.tag.seasonal"))
          } : {}, {
            i: common_vendor.t(_ctx.$t(vaccine.descKey)),
            j: vaccine.price > 0
          }, vaccine.price > 0 ? {
            k: common_vendor.t(vaccine.price)
          } : {
            l: common_vendor.t(_ctx.$t("vaccine.free"))
          }, {
            m: common_vendor.o(($event) => bookVaccine(vaccine), index),
            n: index,
            o: common_vendor.o(($event) => viewDetail(vaccine), index)
          });
        }),
        f: common_vendor.t(_ctx.$t("vaccine.book")),
        g: hasMore.value
      }, hasMore.value ? {
        h: common_vendor.t(_ctx.$t("common.loading"))
      } : {}, {
        i: filteredVaccines.value.length === 0
      }, filteredVaccines.value.length === 0 ? {
        j: common_assets._imports_0$6
      } : {}, {
        k: refreshing.value,
        l: common_vendor.o(onRefresh),
        m: common_vendor.o(onLoadMore),
        n: common_vendor.gei(_ctx, "")
      });
    };
  }
};
wx.createPage(_sfc_main);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/vaccine/list.js.map