"use strict";
const common_vendor = require("../../common/vendor.js");
const utils_navTo = require("../../utils/navTo.js");
const api_api = require("../../api/api.js");
const common_assets = require("../../common/assets.js");
if (!Array) {
  const _easycom_up__image2 = common_vendor.resolveComponent("up--image");
  const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  (_easycom_up__image2 + _easycom_u_icon2)();
}
const _easycom_up__image = () => "../../node-modules/uview-plus/components/u--image/u--image.js";
const _easycom_u_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js";
if (!Math) {
  (navBar + _easycom_up__image + _easycom_u_icon + tabBar)();
}
const tabBar = () => "../../components/tabBar/tabBar.js";
const navBar = () => "../../components/navBar/navBar.js";
const _sfc_main = {
  __name: "index",
  setup(__props) {
    common_vendor.ref(null);
    common_vendor.ref([]);
    const most_read_articles = common_vendor.ref([]);
    const new_articles = common_vendor.ref([]);
    const recommend_doctor = common_vendor.ref([]);
    const recommend_hospital = common_vendor.ref([]);
    const numInfo = common_vendor.reactive({});
    const goDetail = (id) => {
      utils_navTo.navTo({
        url: `/pages/detail/detail?id=${id}&type=article`
      });
    };
    const goListBy = (id, name, type) => {
      let url = "";
      if (type == "doctor") {
        url = `/pages/search/search?doctor_id=${id}&doctor_name=${name}`;
      } else {
        url = `/pages/search/search?hospital_id=${id}&hospital_name=${name}`;
      }
      utils_navTo.navTo({
        url
      });
    };
    const getData = async () => {
      const { data } = await api_api.api.getHomeData();
      if (data.code == 200) {
        most_read_articles.value = data.data.most_read_articles;
        new_articles.value = data.data.new_articles;
        recommend_doctor.value = data.data.recommend_doctor;
        recommend_hospital.value = data.data.recommend_hospital;
      }
    };
    const getStatic = () => {
      api_api.api.getHomeStatics().then((res) => {
        let result = res.data.data;
        Object.assign(numInfo, result);
      });
    };
    const goList = (type) => {
      utils_navTo.navTo({
        url: "/pages/search/search?order=" + type
      });
    };
    const goVideo = () => {
      utils_navTo.navTo({
        url: "/pages/videoList/videoList"
      });
    };
    const goSick = () => {
      utils_navTo.navTo({
        url: "/pages/sickList/sickList"
      });
    };
    const searchDoctor = () => {
      utils_navTo.navTo({
        url: "/pages/searchList/searchList?type=doctor&name=医生&id="
      });
    };
    const goHospital = () => {
      utils_navTo.navTo({
        url: "/pages/searchList/searchList?type=hospital&name=医院&id="
      });
    };
    common_vendor.onShow(() => {
      getStatic();
      getData();
    });
    return (_ctx, _cache) => {
      return {
        a: common_vendor.p({
          type: "home"
        }),
        b: common_vendor.t(numInfo.article_num),
        c: common_vendor.t(numInfo.video_num),
        d: common_vendor.t(numInfo.video_read_num && numInfo.article_read_num ? numInfo.video_read_num + numInfo.article_read_num : 0),
        e: common_vendor.o(goVideo),
        f: common_vendor.p({
          src: common_vendor.unref(common_assets.videoImg),
          radius: "20rpx",
          width: "330rpx",
          height: "176rpx"
        }),
        g: common_vendor.o(goSick),
        h: common_vendor.p({
          src: common_vendor.unref(common_assets.sickImg),
          width: "330rpx",
          radius: "20rpx",
          height: "176rpx"
        }),
        i: common_vendor.o(goHospital),
        j: common_vendor.p({
          src: common_vendor.unref(common_assets.hospitalImg),
          radius: "20rpx",
          width: "330rpx",
          height: "176rpx"
        }),
        k: common_vendor.o(searchDoctor),
        l: common_vendor.p({
          src: common_vendor.unref(common_assets.doctorImg),
          width: "330rpx",
          radius: "20rpx",
          height: "176rpx"
        }),
        m: common_vendor.p({
          name: "arrow-right",
          size: "16",
          color: "#3CC7C0"
        }),
        n: common_vendor.o(($event) => goList("new")),
        o: common_vendor.f(new_articles.value, (item, k0, i0) => {
          return {
            a: common_vendor.t(item.article_title),
            b: common_vendor.f(item.author, (tag, k1, i1) => {
              return {
                a: common_vendor.t(tag.doctor_name),
                b: tag.author_id
              };
            }),
            c: item.article_id,
            d: common_vendor.o(($event) => goDetail(item.article_id), item.article_id)
          };
        }),
        p: common_vendor.p({
          name: "arrow-right",
          size: "16",
          color: "#3CC7C0"
        }),
        q: common_vendor.o(($event) => goList("read")),
        r: common_vendor.f(most_read_articles.value, (item, k0, i0) => {
          return {
            a: common_vendor.t(item.article_title),
            b: common_vendor.f(item.author, (tag, k1, i1) => {
              return {
                a: common_vendor.t(tag.doctor_name),
                b: tag.author_id
              };
            }),
            c: item.article_id,
            d: common_vendor.o(($event) => goDetail(item.article_id), item.article_id)
          };
        }),
        s: common_vendor.p({
          name: "arrow-right",
          size: "16",
          color: "#3CC7C0"
        }),
        t: common_vendor.o(goHospital),
        v: common_vendor.f(recommend_hospital.value, (item, k0, i0) => {
          return {
            a: common_vendor.t(item.hospital_name),
            b: item.hospital_id,
            c: common_vendor.o(($event) => goListBy(item.hospital_id, item.hospital_name, "hospital"), item.hospital_id)
          };
        }),
        w: common_vendor.p({
          name: "arrow-right",
          size: "16",
          color: "#3CC7C0"
        }),
        x: common_vendor.o(searchDoctor),
        y: common_vendor.f(recommend_doctor.value, (item, k0, i0) => {
          return {
            a: common_vendor.t(item.doctor_name),
            b: item.doctor_id,
            c: common_vendor.o(($event) => goListBy(item.doctor_id, item.doctor_name, "doctor"), item.doctor_id)
          };
        })
      };
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1cf27b2a"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index.js.map
