"use strict";
var common_vendor = require("../../common/vendor.js");
var api_index = require("../../api/index.js");
require("../../utils/request.js");
const _sfc_main = {
  setup(__props) {
    let data = common_vendor.reactive({
      cur: 0,
      firstClass: [],
      titleList: []
    });
    common_vendor.onShow(() => {
      getClassifications();
    });
    common_vendor.onHide(() => {
      console.log(11222);
      common_vendor.index.removeStorage({ key: "classId" });
      data.cur = 0;
    });
    const bindToView = (item, index) => {
      data.cur = item.id;
      data.titleList = item.two;
    };
    const getClassifications = async () => {
      try {
        const res = await api_index.getTwoClassification();
        console.log(res, "\u4E09\u7EA7\u5206\u7C7B");
        data.cur = common_vendor.index.getStorageSync("classId") || 0;
        data.firstClass = res;
        if (data.cur === 0) {
          data.cur = res[0].id;
          data.titleList = res[0].two;
        } else {
          data.titleList = res.find((item) => item.id === data.cur).two;
        }
        console.log("getClassification", res);
      } catch (err) {
        common_vendor.index.showToast({ title: err, icon: "none" });
        console.log("getClassification", err);
      }
    };
    const toThreeClassHandler = (pid) => common_vendor.index.navigateTo({ url: `/pages/class/classList?pid=${pid}` });
    return (_ctx, _cache) => {
      return {
        a: common_vendor.f(common_vendor.unref(data).firstClass, (item, index, i0) => {
          return {
            a: common_vendor.t(item.name),
            b: common_vendor.n(common_vendor.unref(data).cur == item.id ? "check" : ""),
            c: item.id,
            d: common_vendor.o(($event) => bindToView(item), item.id)
          };
        }),
        b: common_vendor.f(common_vendor.unref(data).titleList, (item, k0, i0) => {
          return {
            a: common_vendor.t(item.name),
            b: common_vendor.f(item.three, (it, k1, i1) => {
              return {
                a: it.image_text,
                b: common_vendor.t(it.name),
                c: it.id,
                d: common_vendor.o(($event) => toThreeClassHandler(it.id), it.id)
              };
            })
          };
        })
      };
    };
  }
};
var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/vue/\u5927\u5065\u5EB7\u5546\u57CE/healthMall/pages/class/class.vue"]]);
wx.createPage(MiniProgramPage);