"use strict";
const common_vendor = require("../../../../../common/vendor.js");
const hook_useOnLoad_index = require("../../../../../hook/use-on-load/index.js");
const pagesAdmin_article_service_article_index = require("../../../service/article/index.js");
const utils_icon = require("../../../../../utils/icon.js");
if (!Array) {
  const _easycom_mp_html2 = common_vendor.resolveComponent("mp-html");
  _easycom_mp_html2();
}
const _easycom_mp_html = () => "../../../../../uni_modules/mp-html/components/mp-html/mp-html.js";
if (!Math) {
  (_easycom_mp_html + ZyRate + ZyHalfScreenDialog)();
}
const ZyHalfScreenDialog = () => "../../../components/half-screen-dialog/index.js";
const ZyRate = () => "../../../components/rate/index.js";
const _sfc_defineComponent = common_vendor.defineComponent({
  __name: "detail",
  setup(__props) {
    const domain = common_vendor.useDomain();
    const { token } = common_vendor.mapState({
      token: "token"
    });
    const id = common_vendor.ref();
    const _msgUUID = common_vendor.ref();
    const articleInfo = common_vendor.ref({});
    const commentList = common_vendor.ref([]);
    const commentCount = common_vendor.ref(0);
    common_vendor.ref(false);
    common_vendor.reactive({
      PIndex: 1,
      PSize: 10
    });
    const convenientServices = common_vendor.ref({
      DoctorVideocons: {
        title: "视频问诊",
        show: false,
        pagePath: "",
        icon: utils_icon.icon.article_video_cons
      },
      DoctorServiceCons: {
        title: "图文咨询",
        show: false,
        pagePath: "",
        icon: utils_icon.icon.article_service_cons
      },
      DoctorServiceGh: {
        title: "预约挂号",
        show: false,
        pagePath: "",
        icon: utils_icon.icon.article_service_gh
      }
    });
    const doctorDeptList = common_vendor.ref([]);
    const showConvenientServices = common_vendor.ref(false);
    const getArticleDetail = async () => {
      var _a, _b;
      const { resp } = await pagesAdmin_article_service_article_index.ArticleDetail({
        Id: id.value,
        Uuid: _msgUUID.value
      });
      if (resp && resp.length) {
        const info = resp[0];
        const content = unescape(info.Content);
        info.Content = content;
        common_vendor.index.__f__("log", "at pagesAdmin/article/business/article/detail/detail.vue:251", content);
        info.PublishTime = formatDate2(info.PublishTime);
        let articleConvenientServices = ((_a = info.Config) == null ? void 0 : _a.ConvenientServices) || {};
        if (articleConvenientServices) {
          for (const field in articleConvenientServices) {
            convenientServices.value[field].show = articleConvenientServices[field].Checked;
          }
        }
        articleInfo.value = info;
        doctorDeptList.value = ((_b = info.DoctorInfo) == null ? void 0 : _b.DoctorInfo) || [];
        setConvenientServices();
      }
    };
    const formatDate2 = (date) => {
      if (!date) {
        return "";
      }
      return date.substring(5, 16);
    };
    const setConvenientServices = () => {
      showConvenientServices.value = Object.keys(convenientServices.value).find((field) => {
        var _a;
        return ((_a = convenientServices.value[field]) == null ? void 0 : _a.show) === true;
      }) != void 0;
    };
    const like = async () => {
      const { Id: id2, MyLike: like2 = false } = articleInfo.value;
      if (like2) {
        common_vendor.showModal("已点赞");
      } else {
        const res = await pagesAdmin_article_service_article_index.LikeArticle(id2);
        if (res.resData.RespCode === "10000") {
          articleInfo.value.MyLike = true;
          articleInfo.value.LikeCount++;
        }
      }
    };
    hook_useOnLoad_index.useOnLoad((options) => {
      if (common_vendor.index.onCopyUrl) {
        common_vendor.index.onCopyUrl(() => {
          pagesAdmin_article_service_article_index.ShareArticle({ Id: id.value, OptType: "copy_url" });
          return { query: `id=${options.id}` };
        });
      }
      id.value = options.id;
      _msgUUID.value = options.msgId || null;
      getArticleDetail();
    });
    common_vendor.onShareAppMessage(() => {
      pagesAdmin_article_service_article_index.ShareArticle({ Id: id.value, OptType: "send" });
      return {
        title: articleInfo.value.Title,
        path: `/pagesAdmin/article/business/article/detail/detail?id=${id.value}`
      };
    });
    common_vendor.onShareTimeline(() => {
      pagesAdmin_article_service_article_index.ShareArticle({ Id: id.value, OptType: "share" });
      return {
        title: articleInfo.value.Title
      };
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.t(articleInfo.value.Title),
        b: common_vendor.t(articleInfo.value.SourceType == 1 ? "原创" : "转载"),
        c: common_vendor.t(articleInfo.value.Author),
        d: common_vendor.f(articleInfo.value.Depts, (item, k0, i0) => {
          return {
            a: common_vendor.t(item.Value),
            b: item.Key
          };
        }),
        e: common_vendor.t(articleInfo.value.PublishTime),
        f: common_vendor.f(articleInfo.value.ArticleTypeList, (item, index, i0) => {
          return {
            a: common_vendor.t(item.Title),
            b: index
          };
        }),
        g: common_vendor.f(articleInfo.value.Diseases, (item, index, i0) => {
          return {
            a: common_vendor.t(item.Value),
            b: index
          };
        }),
        h: common_vendor.f(articleInfo.value.Tags, (item, index, i0) => {
          return {
            a: common_vendor.t(item.Value),
            b: index
          };
        }),
        i: common_vendor.t(articleInfo.value.Description),
        j: articleInfo.value.ContentType != 1
      }, articleInfo.value.ContentType != 1 ? {
        k: common_vendor.p({
          domain: common_vendor.unref(domain),
          content: articleInfo.value.Content,
          token: common_vendor.unref(token)
        })
      } : {}, {
        l: articleInfo.value.SourceType == 2
      }, articleInfo.value.SourceType == 2 ? common_vendor.e({
        m: common_vendor.t(articleInfo.value.OriginalSource),
        n: articleInfo.value.OriginalLink != ""
      }, articleInfo.value.OriginalLink != "" ? {} : {}) : {}, {
        o: common_vendor.t(articleInfo.value.SeeCount),
        p: articleInfo.value.MyLike ? common_vendor.unref(utils_icon.icon).article_like_active : common_vendor.unref(utils_icon.icon).article_like,
        q: common_vendor.t(articleInfo.value.LikeCount > 999 ? "999+" : articleInfo.value.LikeCount || 0),
        r: common_vendor.o(like),
        s: common_vendor.unref(utils_icon.icon).article_share,
        t: articleInfo.value.EnableComment
      }, articleInfo.value.EnableComment ? common_vendor.e({
        v: common_vendor.t(commentCount.value),
        w: commentList.value.length > 0
      }, commentList.value.length > 0 ? {} : {}, {
        x: commentList.value.length > 0
      }, commentList.value.length > 0 ? {
        y: common_vendor.f(commentList.value, (item, k0, i0) => {
          return {
            a: common_vendor.t(item.MemberName),
            b: common_vendor.t(item.CreateTime),
            c: "0d4701ec-1-" + i0,
            d: item.Id
          };
        }),
        z: common_vendor.p({
          max: "{{5}}",
          score: "{{item.Score}}",
          disabled: "{{true}}",
          size: "{{20}}"
        })
      } : {}) : {}, {
        A: showConvenientServices.value
      }, showConvenientServices.value ? {
        B: common_vendor.f(convenientServices.value, (item, k0, i0) => {
          return common_vendor.e({
            a: item.show
          }, item.show ? {
            b: item.icon,
            c: common_vendor.t(item.title)
          } : {});
        })
      } : {}, {
        C: common_vendor.p({
          max: "{{5}}",
          ["model:score"]: "{{commentScore}}",
          size: "{{20}}"
        }),
        D: common_vendor.p({
          height: "25%",
          extClass: "zy_half_screen_dialog",
          ["model:show"]: "{{articleCommentDialogVisible}}",
          maskClosable: "{{true}}"
        })
      });
    };
  }
});
_sfc_defineComponent.__runtimeHooks = 6;
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_defineComponent, [["__scopeId", "data-v-0d4701ec"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/pagesAdmin/article/business/article/detail/detail.js.map
