"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: "myCollect",
  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);
    common_vendor.ref("");
    const keyWord = common_vendor.ref("");
    const isArticle = common_vendor.ref(true);
    const navName = common_vendor.ref("肝胆相照临床病例库");
    const type1 = common_vendor.ref(0);
    const type2 = common_vendor.ref(1);
    const title2 = common_vendor.ref("文章病例库");
    const options = common_vendor.ref([
      {
        label: "收藏",
        value: 0
      },
      {
        label: "浏览",
        value: 1
      }
    ]);
    const options1 = common_vendor.ref([
      {
        label: "文章病例库",
        value: 1
      },
      {
        label: "视频病例库",
        value: 2
      },
      {
        label: "病例交流",
        value: 3
      }
    ]);
    common_vendor.reactive({
      read_num: "",
      push_date: ""
    });
    common_vendor.onLoad((options2) => {
      if (options2.keyWord) {
        keyWord.value = options2.keyWord;
      }
    });
    const changetype1 = (e) => {
      type1.value = e;
      paging.value.reload();
    };
    const changetype2 = (e) => {
      type2.value = e;
      title2.value = options1.value[e - 1].label;
      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/myCollect/myCollect.vue:126", 11111);
      common_vendor.index.__f__("log", "at pages/myCollect/myCollect.vue:127", id);
      let type = isArticle.value ? "article" : "video";
      utils_navTo.navTo({
        url: `/pages/detail/detail?id=${id}&type=${type}`
      });
    };
    const changeWord = (val) => {
      keyWord.value = val;
      paging.value.reload();
    };
    const searchCollect = (params) => {
      let searchForm = {
        keyword: keyWord.value,
        type: type2.value
      };
      api_api.api.getMyCollect({
        ...searchForm,
        ...params
      }).then((res) => {
        paging.value.complete(res.data.data.data);
        total.value = res.data.data.total;
      }).catch((err) => {
        paging.value.complete(false);
      });
    };
    const searchRead = async (params) => {
      let searchForm = {
        keyword: keyWord.value,
        type: type2.value
      };
      api_api.api.getMyRead({
        ...searchForm,
        ...params
      }).then((res) => {
        paging.value.complete(res.data.data.data);
        total.value = res.data.data.total;
      }).catch((err) => {
        paging.value.complete(false);
      });
    };
    const queryList = (pageNo, pageSize) => {
      const params = {
        page: pageNo,
        page_size: pageSize
      };
      type1.value == 1 ? searchRead(params) : searchCollect(params);
    };
    return (_ctx, _cache) => {
      return {
        a: common_vendor.o(changeWord),
        b: common_vendor.p({
          searchWord: keyWord.value,
          navName: navName.value
        }),
        c: common_vendor.o(changetype1),
        d: common_vendor.o(($event) => type1.value = $event),
        e: common_vendor.p({
          title: type1.value == 0 ? "收藏" : "浏览",
          options: options.value,
          modelValue: type1.value
        }),
        f: common_vendor.o(changetype2),
        g: common_vendor.o(($event) => type2.value = $event),
        h: common_vendor.p({
          title: title2.value,
          options: options1.value,
          modelValue: type2.value
        }),
        i: common_vendor.sr(uDropdownRef, "1cf734f5-2,1cf734f5-0", {
          "k": "uDropdownRef"
        }),
        j: common_vendor.f(dataList.value, (item, index, i0) => {
          return {
            a: common_vendor.t(item.data.title),
            b: common_vendor.f(item.data.author, (tag, k1, i1) => {
              return {
                a: common_vendor.t(tag.doctor_name),
                b: tag.author_id
              };
            }),
            c: "1cf734f5-5-" + i0 + ",1cf734f5-0",
            d: common_vendor.t(item.data.read_num),
            e: "1cf734f5-6-" + i0 + ",1cf734f5-0",
            f: common_vendor.t(item.data.collect_num),
            g: "1cf734f5-7-" + i0 + ",1cf734f5-0",
            h: common_vendor.t(formatdate(item.data.push_date)),
            i: common_vendor.o(($event) => goDetail(), item.collect_id),
            j: item.collect_id
          };
        }),
        k: common_vendor.p({
          name: "eye",
          color: "#6B7280",
          size: "28rpx"
        }),
        l: common_vendor.p({
          name: "heart",
          color: "#6B7280",
          size: "28rpx"
        }),
        m: common_vendor.p({
          name: "clock",
          color: "#6B7280",
          size: "28rpx"
        }),
        n: common_vendor.sr(paging, "1cf734f5-0", {
          "k": "paging"
        }),
        o: common_vendor.o(queryList),
        p: common_vendor.o(($event) => dataList.value = $event),
        q: 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-1cf734f5"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/myCollect/myCollect.js.map
