"use strict";
const common_vendor = require("../../common/vendor.js");
const api_api = require("../../api/api.js");
const utils_navTo = require("../../utils/navTo.js");
if (!Array) {
  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");
  (_easycom_up_dropdown_item2 + _easycom_up_dropdown2 + _easycom_up_icon2 + _easycom_z_paging2)();
}
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";
if (!Math) {
  (navBarSearch + _easycom_up_dropdown_item + _easycom_up_dropdown + _easycom_up_icon + _easycom_z_paging)();
}
const navBarSearch = () => "../../components/navBarSearch/navBarSearch.js";
const _sfc_main = {
  __name: "videoList",
  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 isArticle = common_vendor.ref(false);
    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 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;
      }
      getStatic();
      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 + "临床病例库";
        getStaticDoctor(hospital_id.value);
      }
    });
    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/videoList/videoList.vue:162", 11111);
      common_vendor.index.__f__("log", "at pages/videoList/videoList.vue:163", id);
      let type = isArticle.value ? "article" : "video";
      utils_navTo.navTo({
        url: `/pages/detail/detail?id=${id}&type=${type}`
      });
    };
    const getStatic = () => {
      api_api.api.getHomeStatics().then((res) => {
        let result = res.data.data;
        Object.assign(numInfo, result);
      });
    };
    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 queryList = (pageNo, pageSize) => {
      common_vendor.index.__f__("log", "at pages/videoList/videoList.vue:238", 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,
          type: "video"
        }),
        c: isArticle.value
      }, isArticle.value ? {
        d: common_vendor.t(numInfo.article_collect_num)
      } : {
        e: common_vendor.t(numInfo.video_collect_num)
      }, {
        f: isArticle.value
      }, isArticle.value ? {
        g: common_vendor.t(numInfo.article_read_num)
      } : {
        h: common_vendor.t(numInfo.video_read_num)
      }, {
        i: common_vendor.o(change),
        j: common_vendor.o(($event) => order.push_date = $event),
        k: common_vendor.p({
          title: "发布时间",
          options: options.value,
          modelValue: order.push_date
        }),
        l: common_vendor.o(change),
        m: common_vendor.o(($event) => order.read_num = $event),
        n: common_vendor.p({
          title: "阅读量",
          options: options.value,
          modelValue: order.read_num
        }),
        o: common_vendor.sr(uDropdownRef, "acc011bc-2,acc011bc-0", {
          "k": "uDropdownRef"
        }),
        p: 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: "acc011bc-5-" + i0 + ",acc011bc-0",
            d: common_vendor.t(item.read_num),
            e: "acc011bc-6-" + i0 + ",acc011bc-0",
            f: common_vendor.t(item.collect_num),
            g: "acc011bc-7-" + i0 + ",acc011bc-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)
          };
        }),
        q: common_vendor.p({
          name: "eye",
          color: "#6B7280",
          size: "28rpx"
        }),
        r: common_vendor.p({
          name: "heart",
          color: "#6B7280",
          size: "28rpx"
        }),
        s: common_vendor.p({
          name: "clock",
          color: "#6B7280",
          size: "28rpx"
        }),
        t: common_vendor.sr(paging, "acc011bc-0", {
          "k": "paging"
        }),
        v: common_vendor.o(queryList),
        w: common_vendor.o(($event) => dataList.value = $event),
        x: common_vendor.p({
          ["inside-more"]: true,
          ["loading-more-no-more-text"]: "咱也是有底线的！",
          ["auto-show-back-to-top"]: true,
          modelValue: dataList.value
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-acc011bc"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/videoList/videoList.js.map
