"use strict";
const common_vendor = require("../../common/vendor.js");
const api_api = require("../../api/api.js");
const common_assets = require("../../common/assets.js");
const utils_navTo = require("../../utils/navTo.js");
if (!Array) {
  const _easycom_up__image2 = common_vendor.resolveComponent("up--image");
  const _easycom_up_dropdown_item2 = common_vendor.resolveComponent("up-dropdown-item");
  const _easycom_up_dropdown2 = common_vendor.resolveComponent("up-dropdown");
  const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
  const _easycom_z_paging2 = common_vendor.resolveComponent("z-paging");
  const _easycom_up_radio2 = common_vendor.resolveComponent("up-radio");
  const _easycom_up_radio_group2 = common_vendor.resolveComponent("up-radio-group");
  const _easycom_up_popup2 = common_vendor.resolveComponent("up-popup");
  (_easycom_up__image2 + _easycom_up_dropdown_item2 + _easycom_up_dropdown2 + _easycom_up_icon2 + _easycom_z_paging2 + _easycom_up_radio2 + _easycom_up_radio_group2 + _easycom_up_popup2)();
}
const _easycom_up__image = () => "../../node-modules/uview-plus/components/u--image/u--image.js";
const _easycom_up_dropdown_item = () => "../../node-modules/uview-plus/components/u-dropdown-item/u-dropdown-item.js";
const _easycom_up_dropdown = () => "../../node-modules/uview-plus/components/u-dropdown/u-dropdown.js";
const _easycom_up_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js";
const _easycom_z_paging = () => "../../uni_modules/z-paging/components/z-paging/z-paging.js";
const _easycom_up_radio = () => "../../node-modules/uview-plus/components/u-radio/u-radio.js";
const _easycom_up_radio_group = () => "../../node-modules/uview-plus/components/u-radio-group/u-radio-group.js";
const _easycom_up_popup = () => "../../node-modules/uview-plus/components/u-popup/u-popup.js";
if (!Math) {
  (navBarSearch + _easycom_up__image + _easycom_up_dropdown_item + _easycom_up_dropdown + _easycom_up_icon + _easycom_z_paging + _easycom_up_radio + _easycom_up_radio_group + _easycom_up_popup)();
}
const navBarSearch = () => "../../components/navBarSearch/navBarSearch.js";
const _sfc_main = {
  __name: "search",
  setup(__props) {
    const paging = common_vendor.ref(null);
    const uDropdownRef = common_vendor.ref(null);
    const dataList = common_vendor.ref([]);
    const total = common_vendor.ref(0);
    const keyWord = common_vendor.ref("");
    const label_iden = common_vendor.ref("");
    const isArticle = common_vendor.ref(true);
    const hospital_id = common_vendor.ref("");
    const hospital_name = common_vendor.ref("");
    const doctor_id = common_vendor.ref("");
    const doctor_name = common_vendor.ref("");
    const numInfo = common_vendor.reactive({});
    const searchInfo = common_vendor.reactive({});
    const navName = common_vendor.ref("肝胆相照临床病例库");
    const options = common_vendor.ref([
      {
        label: "正序",
        value: "asc"
      },
      {
        label: "倒序",
        value: "desc"
      }
    ]);
    const isSearch = common_vendor.ref(false);
    const order = common_vendor.reactive({
      read_num: "",
      push_date: ""
    });
    const showCase = common_vendor.ref(false);
    const canOpenCase = common_vendor.ref(false);
    const caseValue1 = common_vendor.ref("");
    const caseValue2 = common_vendor.ref("");
    const caseValue3 = common_vendor.ref("");
    const level = common_vendor.ref(1);
    const labelObj = common_vendor.reactive({
      list1: [],
      list2: [],
      list3: []
    });
    const getCaseLabel = (lev, pid = 0) => {
      api_api.api.getCaseLabel({
        pid
      }).then((res) => {
        if (lev == 1) {
          labelObj.list1 = res.data.data;
        } else if (lev == 2) {
          labelObj.list2 = res.data.data;
        } else if (lev == 3) {
          labelObj.list3 = res.data.data;
        }
        level.value = lev;
      });
    };
    const openCase = () => {
      getCaseLabel(1, 0);
      showCase.value = true;
    };
    const confirmCase = () => {
      if (level.value == 1 && caseValue1.value == "") {
        common_vendor.index.showToast({ title: "请选择疾病", icon: "none" });
        return false;
      }
      if (level.value == 2 && caseValue2.value == "") {
        common_vendor.index.showToast({ title: "请选择疾病", icon: "none" });
        return false;
      }
      if (level.value == 3 && caseValue3.value == "") {
        common_vendor.index.showToast({ title: "请选择疾病", icon: "none" });
        return false;
      }
      showCase.value = false;
      if (level.value == 1) {
        label_iden.value = caseValue1.value;
      }
      if (level.value == 2) {
        label_iden.value = caseValue2.value;
      }
      if (level.value == 3) {
        label_iden.value = caseValue3.value;
      }
    };
    const continueCase = () => {
      if (level.value == 1 && caseValue1.value == "") {
        common_vendor.index.showToast({ title: "请选择疾病", icon: "none" });
        return false;
      }
      if (level.value == 2 && caseValue2.value == "") {
        common_vendor.index.showToast({ title: "请选择疾病", icon: "none" });
        return false;
      }
      if (level.value == 3 && caseValue3.value == "") {
        common_vendor.index.showToast({ title: "请选择疾病", icon: "none" });
        return false;
      }
      if (level.value == 1) {
        getCaseLabel(2, caseValue1.value);
      } else if (level.value == 2) {
        getCaseLabel(3, caseValue2.value);
      }
      paging.value.reload();
    };
    const closeCase = () => {
      showCase.value = false;
    };
    const changeWord = (value) => {
      keyWord.value = value;
      isSearch.value = true;
      paging.value.reload();
    };
    common_vendor.onLoad((options2) => {
      if (options2.keyWord) {
        keyWord.value = options2.keyWord;
      }
      if (options2.order == "new") {
        order.push_date = "asc";
      }
      if (options2.order == "read") {
        order.read_num = "desc";
      }
      if (options2.order == "video") {
        isArticle.value = false;
      }
      if (options2.doctor_id) {
        doctor_id.value = options2.doctor_id;
        doctor_name.value = options2.doctor_name;
        navName.value = doctor_name.value + "临床病例库";
        getStaticDoctor(doctor_id.value);
      }
      if (options2.hospital_id) {
        hospital_id.value = options2.hospital_id;
        hospital_name.value = options2.hospital_name;
        navName.value = hospital_name.value + "临床病例库";
        getStaticHospital(hospital_id.value);
      }
      if (options2.case_id) {
        label_iden.value = options2.case_id;
        navName.value = options2.case_name + "临床病例库";
        getStaticSick(label_iden.value);
      } else {
        canOpenCase.value = true;
      }
    });
    const change = (e) => {
      paging.value.reload();
    };
    const formatdate = (date) => {
      return common_vendor.dayjs(date).format("YYYY-MM-DD");
    };
    const goDetail = (id) => {
      common_vendor.index.__f__("log", "at pages/search/search.vue:322", 11111);
      common_vendor.index.__f__("log", "at pages/search/search.vue:323", id);
      let type = isArticle.value ? "article" : "video";
      utils_navTo.navTo({
        url: `/pages/detail/detail?id=${id}&type=${type}`
      });
    };
    const swicthType = () => {
      isArticle.value = !isArticle.value;
      dataList.value = [];
      order.read_num = "";
      order.push_date = "";
      paging.value.reload();
    };
    const searchArticle = (params) => {
      let searchForm = {
        keyword: keyWord.value,
        hospital_id: hospital_id.value,
        doctor_id: doctor_id.value
      };
      if (isSearch.value) {
        searchForm.is_need_num = 1;
      }
      if (!order.read_num) {
        delete order.read_num;
      }
      if (!order.push_date) {
        delete order.push_date;
      }
      if (order.read_num || order.push_date) {
        searchForm.order = order;
      }
      api_api.api.searchArticle({
        ...searchForm,
        ...params
      }).then((res) => {
        paging.value.complete(res.data.data.data);
        total.value = res.data.data.total;
        searchInfo.search_video_num = res.data.data.search_video_num;
        searchInfo.search_article_num = res.data.data.search_article_num;
      }).catch((err) => {
        paging.value.complete(false);
      });
    };
    const searchVideo = async (params) => {
      let searchForm = {
        keyword: keyWord.value,
        hospital_id: hospital_id.value,
        doctor_id: doctor_id.value
      };
      if (isSearch.value) {
        searchForm.is_need_num = 1;
      }
      if (!order.read_num) {
        delete order.read_num;
      }
      if (!order.push_date) {
        delete order.push_date;
      }
      if (order.read_num || order.push_date) {
        searchForm.order = order;
      }
      api_api.api.searchVideo({
        ...searchForm,
        ...params
      }).then((res) => {
        paging.value.complete(res.data.data.data);
        total.value = res.data.data.total;
        searchInfo.search_video_num = res.data.data.search_video_num;
        searchInfo.search_article_num = res.data.data.search_article_num;
      }).catch((err) => {
        paging.value.complete(false);
      });
    };
    const getStaticDoctor = (id) => {
      api_api.api.getStaticDoctor(id).then((res) => {
        let result = res.data.data;
        if (result) {
          Object.assign(numInfo, result);
        } else {
          Object.assign(numInfo, {
            article_num: 0,
            article_read_num: 0,
            video_collect_num: 0,
            video_num: 0,
            video_read_num: 0
          });
        }
      });
    };
    const getStaticSick = (id) => {
      api_api.api.getStaticSick({
        label_iden: id
      }).then((res) => {
        let result = res.data.data;
        if (result) {
          Object.assign(numInfo, result);
        } else {
          Object.assign(numInfo, {
            article_num: 0,
            article_read_num: 0,
            video_collect_num: 0,
            video_num: 0,
            video_read_num: 0
          });
        }
      });
    };
    const getStaticHospital = (id) => {
      api_api.api.getStaticHospital(id).then((res) => {
        let result = res.data.data;
        if (result) {
          Object.assign(numInfo, result);
        } else {
          Object.assign(numInfo, {
            article_num: 0,
            article_read_num: 0,
            video_collect_num: 0,
            video_num: 0,
            video_read_num: 0
          });
        }
      });
    };
    const queryList = (pageNo, pageSize) => {
      common_vendor.index.__f__("log", "at pages/search/search.vue:451", 666666);
      const params = {
        page: pageNo,
        page_size: pageSize
      };
      isArticle.value ? searchArticle(params) : searchVideo(params);
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.o(changeWord),
        b: common_vendor.p({
          searchWord: keyWord.value,
          navName: navName.value
        }),
        c: hospital_id.value || doctor_id.value || label_iden.value && !canOpenCase.value
      }, hospital_id.value || doctor_id.value || label_iden.value && !canOpenCase.value ? {
        d: common_vendor.t(numInfo.article_collect_num),
        e: common_vendor.t(numInfo.video_collect_num),
        f: common_vendor.t(numInfo.video_read_num + numInfo.article_read_num)
      } : {}, {
        g: isSearch.value
      }, isSearch.value ? common_vendor.e({
        h: common_vendor.t(searchInfo.search_article_num),
        i: common_vendor.t(searchInfo.search_video_num),
        j: keyWord.value
      }, keyWord.value ? {
        k: common_vendor.t(keyWord.value)
      } : {}) : {}, {
        l: common_vendor.t(!isArticle.value ? "文章" : "视频"),
        m: common_vendor.p({
          src: common_vendor.unref(common_assets.switchImg),
          width: "31rpx",
          height: "31rpx"
        }),
        n: common_vendor.o(swicthType),
        o: canOpenCase.value
      }, canOpenCase.value ? {
        p: common_vendor.p({
          src: common_vendor.unref(common_assets.caseImg),
          width: "31rpx",
          height: "31rpx"
        }),
        q: common_vendor.o(openCase)
      } : {}, {
        r: common_vendor.o(change),
        s: common_vendor.o(($event) => order.push_date = $event),
        t: common_vendor.p({
          title: "发布时间",
          options: options.value,
          modelValue: order.push_date
        }),
        v: common_vendor.o(change),
        w: common_vendor.o(($event) => order.read_num = $event),
        x: common_vendor.p({
          title: "阅读量",
          options: options.value,
          modelValue: order.read_num
        }),
        y: common_vendor.sr(uDropdownRef, "c10c040c-4,c10c040c-0", {
          "k": "uDropdownRef"
        }),
        z: canOpenCase.value ? 1 : "",
        A: common_vendor.f(dataList.value, (item, index, i0) => {
          return {
            a: common_vendor.t(isArticle.value ? item.article_title : item.video_title),
            b: common_vendor.f(item.author, (tag, k1, i1) => {
              return {
                a: common_vendor.t(tag.doctor_name),
                b: tag.author_id
              };
            }),
            c: "c10c040c-7-" + i0 + ",c10c040c-0",
            d: common_vendor.t(item.read_num),
            e: "c10c040c-8-" + i0 + ",c10c040c-0",
            f: common_vendor.t(item.collect_num),
            g: "c10c040c-9-" + i0 + ",c10c040c-0",
            h: common_vendor.t(formatdate(item.push_date)),
            i: index,
            j: common_vendor.o(($event) => isArticle.value ? goDetail(item.article_id) : goDetail(item.video_id), index)
          };
        }),
        B: common_vendor.p({
          name: "eye",
          color: "#6B7280",
          size: "28rpx"
        }),
        C: common_vendor.p({
          name: "heart",
          color: "#6B7280",
          size: "28rpx"
        }),
        D: common_vendor.p({
          name: "clock",
          color: "#6B7280",
          size: "28rpx"
        }),
        E: common_vendor.sr(paging, "c10c040c-0", {
          "k": "paging"
        }),
        F: common_vendor.o(queryList),
        G: common_vendor.o(($event) => dataList.value = $event),
        H: common_vendor.p({
          ["inside-more"]: true,
          ["loading-more-no-more-text"]: "咱也是有底线的！",
          ["auto-show-back-to-top"]: true,
          modelValue: dataList.value
        }),
        I: common_vendor.o(($event) => showCase.value = false),
        J: common_vendor.o(continueCase),
        K: level.value != 3,
        L: common_vendor.o(confirmCase),
        M: common_vendor.f(labelObj.list1, (item, k0, i0) => {
          return {
            a: "c10c040c-12-" + i0 + ",c10c040c-11",
            b: common_vendor.p({
              activeColor: "#3CC7C0 ",
              label: item.label_name,
              name: item.app_iden
            }),
            c: item.app_iden
          };
        }),
        N: common_vendor.o(($event) => caseValue1.value = $event),
        O: common_vendor.p({
          iconPlacement: "right",
          placement: "column",
          modelValue: caseValue1.value
        }),
        P: level.value == 1,
        Q: common_vendor.f(labelObj.list2, (item, k0, i0) => {
          return {
            a: "c10c040c-14-" + i0 + ",c10c040c-13",
            b: common_vendor.p({
              activeColor: "#3CC7C0 ",
              label: item.label_name,
              name: item.app_iden
            }),
            c: item.app_iden
          };
        }),
        R: common_vendor.o(($event) => caseValue2.value = $event),
        S: common_vendor.p({
          iconPlacement: "right",
          placement: "column",
          modelValue: caseValue2.value
        }),
        T: level.value == 2,
        U: common_vendor.f(labelObj.list2, (item, k0, i0) => {
          return {
            a: "c10c040c-16-" + i0 + ",c10c040c-15",
            b: common_vendor.p({
              activeColor: "#3CC7C0 ",
              label: item.label_name,
              name: item.app_iden
            }),
            c: item.app_iden
          };
        }),
        V: common_vendor.o(($event) => caseValue3.value = $event),
        W: common_vendor.p({
          iconPlacement: "right",
          placement: "column",
          modelValue: caseValue3.value
        }),
        X: level.value == 3,
        Y: common_vendor.o(closeCase),
        Z: common_vendor.p({
          round: 10,
          zIndex: "9",
          show: showCase.value,
          mode: "bottom"
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-c10c040c"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/search/search.js.map
