"use strict";
const common_vendor = require("../../common/vendor.js");
const API_api = require("../../API/api.js");
const _sfc_main = {
  __name: "drinks",
  setup(__props) {
    const historyList = common_vendor.ref([]);
    const filteredHistoryList = common_vendor.computed(() => {
      return historyList.value.filter((item) => item.categoryId === "2");
    });
    const fetchHistoryData = async () => {
      try {
        const res = await common_vendor.index.request({
          url: API_api.apiImageUrl + "/api/business/list",
          method: "POST"
        });
        if (res.data.code === 0) {
          historyList.value = res.data.data;
        }
      } catch (error) {
        console.error("Error fetching data:", error);
      }
    };
    common_vendor.onMounted(() => {
      fetchHistoryData();
    });
    const handleDonate = (item) => {
      if (!item || !item.hasOwnProperty("id")) {
        console.error("The 'item' variable is undefined or missing the 'id' property.");
        return;
      }
      const merchantId = item.id;
      common_vendor.index.navigateTo({
        url: `/pages/merchant/merchant?merchantId=${merchantId}`
      });
      console.log(`Navigating to merchant details page with merchantId: ${merchantId}`);
    };
    return (_ctx, _cache) => {
      return {
        a: common_vendor.f(common_vendor.unref(filteredHistoryList), (item, index, i0) => {
          return {
            a: item.businessAvatar,
            b: common_vendor.t(item.businessName),
            c: index,
            d: common_vendor.o(($event) => handleDonate(item))
          };
        })
      };
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/111111000000/uniapp04/pages/drinks/drinks.vue"]]);
my.createPage(MiniProgramPage);
