"use strict";
const common_vendor = require("../../common/vendor.js");
if (!Array) {
  const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
  _easycom_up_icon2();
}
const _easycom_up_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js";
if (!Math) {
  _easycom_up_icon();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "index",
  setup(__props) {
    const $api = common_vendor.inject("$api");
    const id = common_vendor.ref("");
    const config = common_vendor.ref({ logo: [], file: [] });
    const courseInfo = common_vendor.ref({});
    const teacherInfo = common_vendor.ref({});
    const subjectList = common_vendor.ref([]);
    const educationList = common_vendor.ref([]);
    const typeList = common_vendor.ref([]);
    const gradeList = common_vendor.ref([]);
    const genderList = common_vendor.ref([]);
    const learnStatusList = common_vendor.ref([]);
    common_vendor.computed(() => {
      return common_vendor.index.getStorageSync("user");
    });
    common_vendor.onLoad(async (options) => {
      id.value = options && options.id;
      await searchConfig();
      await searchOther();
      await search();
    });
    const searchConfig = async () => {
      config.value = common_vendor.index.getStorageSync("config");
    };
    const searchOther = async () => {
      let res;
      res = await $api(`dictData`, "GET", { code: "subject", is_use: "0" });
      if (res.errcode === 0)
        subjectList.value = res.data;
      res = await $api(`dictData`, "GET", { code: "grade", is_use: "0" });
      if (res.errcode === 0)
        gradeList.value = res.data;
      res = await $api(`dictData`, "GET", { code: "education", is_use: "0" });
      if (res.errcode === 0)
        educationList.value = res.data;
      res = await $api(`dictData`, "GET", { code: "courseType", is_use: "0" });
      if (res.errcode === 0)
        typeList.value = res.data;
      res = await $api(`dictData`, "GET", { code: "gender", is_use: "0" });
      if (res.errcode === 0)
        genderList.value = res.data;
      res = await $api(`dictData`, "GET", { code: "learnStatus", is_use: "0" });
      if (res.errcode === 0)
        learnStatusList.value = res.data;
    };
    const search = async () => {
      if (id.value) {
        const res = await $api(`course/appHomeDetail/${id.value}`, "GET", {});
        if (res.errcode == "0") {
          courseInfo.value = res.data.courseInfo;
          teacherInfo.value = res.data.teacherInfo;
        }
      }
    };
    const getDict = (data, model) => {
      if (data) {
        let res;
        if (model == "education")
          res = educationList.value.find((f) => f.value == data);
        else if (model == "subject")
          res = subjectList.value.find((f) => f.value == data);
        else if (model == "grade")
          res = gradeList.value.find((f) => f.value == data);
        else if (model == "type")
          res = typeList.value.find((f) => f.value == data);
        else if (model == "gender")
          res = genderList.value.find((f) => f.value == data);
        else if (model == "learnStatus")
          res = learnStatusList.value.find((f) => f.value == data);
        return res.label || "暂无";
      }
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.t(courseInfo.value.name || "暂无"),
        b: common_vendor.t(getDict(courseInfo.value.type, "type")),
        c: common_vendor.t(getDict(courseInfo.value.grade, "grade")),
        d: common_vendor.t(getDict(courseInfo.value.subject, "subject")),
        e: courseInfo.value.is_follow
      }, courseInfo.value.is_follow ? {
        f: common_vendor.p({
          name: "star-fill",
          color: "#FFA500",
          size: "30"
        })
      } : {
        g: common_vendor.p({
          name: "star",
          color: "#FFA500",
          size: "30"
        })
      }, {
        h: common_vendor.n(courseInfo.value.type === "0" ? "one0" : courseInfo.value.type === "1" ? "one1" : courseInfo.value.type === "2" ? "one2" : courseInfo.value.type === "3" ? "one3" : ""),
        i: common_vendor.t(courseInfo.value.start_time || "暂无"),
        j: common_vendor.t(courseInfo.value.end_time || "暂无"),
        k: common_vendor.t(courseInfo.value.money || "免费")
      });
    };
  }
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-115e567b"], ["__file", "D:/project/学吧/learn_applet/pagesHome/course/index.vue"]]);
wx.createPage(MiniProgramPage);
