"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