"use strict"; const common_vendor = require("../../common/vendor.js"); const hooks_useToast = require("../../hooks/useToast.js"); const api_index = require("../../api/index.js"); const utils_ifApp = require("../../utils/ifApp.js"); if (!Array) { const _component_up_overlay = common_vendor.resolveComponent("up-overlay"); const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons"); const _component_up_tabbar = common_vendor.resolveComponent("up-tabbar"); const _component_up_popup = common_vendor.resolveComponent("up-popup"); (_component_up_overlay + _easycom_uni_icons2 + _component_up_tabbar + _component_up_popup)(); } const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js"; if (!Math) { (common_vendor.unref(Comment) + _easycom_uni_icons)(); } const Comment = () => "../../components/comment/index.js"; const _sfc_main = { __name: "index", setup(__props) { const { Toast } = hooks_useToast.useToast(); const goShuiBei = () => { alert(utils_ifApp.browser.versions.iPhone); if (utils_ifApp.browser.versions.android) { window.open("appmarket://details?id=com.tencent.mm"); } else { common_vendor.index.navigateTo({ url: "/pages/index/index" }); } }; const instance = common_vendor.getCurrentInstance(); const articleId = common_vendor.ref(""); const detail = common_vendor.ref(null); common_vendor.computed(() => { }); common_vendor.onLoad((options) => { articleId.value = options.id || "101"; fetchArticleDetail(); }); common_vendor.onReady(() => { common_vendor.index.onKeyboardHeightChange && common_vendor.index.onKeyboardHeightChange(listenerKeybord); }); common_vendor.onShow(() => { common_vendor.index.$on("followStateChanged", handleFollowStateChanged); }); common_vendor.onHide(() => { common_vendor.index.offKeyboardHeightChange && common_vendor.index.offKeyboardHeightChange(listenerKeybord); common_vendor.index.$off("followStateChanged", handleFollowStateChanged); }); function listenerKeybord(res) { if (res.height === 0) { keybordHeight.value = 0; } else { common_vendor.index.getSystemInfo({ success(systemRes) { const screenHeight = systemRes.screenHeight; const windowHeight = systemRes.windowHeight; const disHeight = screenHeight - windowHeight; keybordHeight.value = res.height - disHeight; } }); } } async function fetchArticleDetail() { try { common_vendor.index.showLoading({ title: "加载中", mask: true }); const { data } = await api_index.getGoodDetailId(articleId.value); detail.value = data; common_vendor.index.hideLoading(); } catch (error) { common_vendor.index.__f__("error", "at pages/article_details/index.vue:263", "fetchArticleDetail", error); common_vendor.index.hideLoading(); } } const commentText = common_vendor.ref(""); const showActionPopup = common_vendor.ref(false); function handleDelete() { showActionPopup.value = false; common_vendor.index.showModal({ title: "提示", content: "确认删除?", success: async function(res) { if (res.confirm) ; } }); } const commentType = common_vendor.ref("add"); const commentInputPl = common_vendor.ref("说点什么..."); function clickComment(comment) { const username = comment.userName; commentType.value = "reply"; commentInputPl.value = `回复 @${username}`; keybordFocus.value = true; } const confirmHold = common_vendor.ref(true); const commentRef = common_vendor.ref(); function handleInputConfirm(event) { var _a; if (((_a = commentText.value) == null ? void 0 : _a.trim()) === "") { confirmHold.value = true; return Toast({ title: "有内容才能发送哦" }); } confirmHold.value = false; commentRef.value.handleAddComment(commentText.value); } function inputDone() { commentText.value = ""; } common_vendor.ref(); const commentOffsetTop = common_vendor.ref(0); common_vendor.watch( () => detail.value, async (val, oldVal) => { if (val && !oldVal) { await common_vendor.nextTick$1(); const query = common_vendor.index.createSelectorQuery().in(instance.proxy); query.select(".comment-section").boundingClientRect((data) => { if (data.top) { commentOffsetTop.value = data.top - 60; } }).exec(); } } ); function clickMessageIcon() { common_vendor.index.pageScrollTo({ scrollTop: commentOffsetTop.value, // selector: ".fixed-view", success() { common_vendor.index.__f__("log", "at pages/article_details/index.vue:376", "success"); }, fail(e) { common_vendor.index.__f__("error", "at pages/article_details/index.vue:379", `scrollTo error ${e}`); } }); } const collectionLoading = common_vendor.ref(false); async function handleCollection() { try { if (collectionLoading.value) return; collectionLoading.value = true; await setUserState({ type: 1, bookId: detail.value.id }); detail.value.collectMark = !detail.value.collectMark; if (detail.value.collectMark) { detail.value.collectCount += 1; } else { detail.value.collectCount -= 1; } collectionLoading.value = false; } catch (error) { common_vendor.index.__f__("error", "at pages/article_details/index.vue:404", "collection error", error); collectionLoading.value = false; } } const likeLoading = common_vendor.ref(false); const likeAnimation = common_vendor.ref(false); async function handleLike() { try { if (likeLoading.value) return; likeLoading.value = true; await setUserState({ type: 0, bookId: detail.value.id }); detail.value.likeMark = !detail.value.likeMark; if (detail.value.likeMark) { likeAnimation.value = true; detail.value.likeCount += 1; } else { likeAnimation.value = false; detail.value.likeCount -= 1; } likeLoading.value = false; } catch (error) { likeLoading.value = false; Toast({ title: "点赞失败" }); common_vendor.index.__f__("error", "at pages/article_details/index.vue:437", "handleLike", error); } } const keybordHeight = common_vendor.ref(0); const keybordOverlay = common_vendor.ref(true); const keybordFocus = common_vendor.ref(false); function commentInputFocus(event) { } function commentInputBlur() { keybordHeight.value = 0; keybordFocus.value = false; } function clickFooterInput() { common_vendor.index.__f__("log", "at pages/article_details/index.vue:465", "点击了底部Input"); commentInputPl.value = "说点什么..."; commentType.value = "add"; keybordFocus.value = true; } function handleFollowStateChanged(data) { var _a; if (Number(data.userId) === Number((_a = detail.value) == null ? void 0 : _a.userId)) { detail.value.followMark = data.followMark; } } return (_ctx, _cache) => { return common_vendor.e({ a: detail.value }, detail.value ? { b: detail.value.coverImage, c: common_vendor.t(detail.value.title), d: common_vendor.t(detail.value.content), e: common_vendor.t(detail.value.publishTime), f: common_vendor.t(detail.value.commentCount), g: common_vendor.sr(commentRef, "04f1b7e6-0", { "k": "commentRef" }), h: common_vendor.o(clickComment), i: common_vendor.o(clickMessageIcon), j: common_vendor.o(inputDone), k: common_vendor.p({ commentType: commentType.value }), l: keybordFocus.value, m: confirmHold.value, n: commentInputPl.value, o: common_vendor.o(commentInputFocus), p: common_vendor.o(commentInputBlur), q: common_vendor.o(handleInputConfirm), r: commentText.value, s: common_vendor.o(($event) => commentText.value = $event.detail.value), t: common_vendor.o(handleInputConfirm), v: common_vendor.s(keybordHeight.value > 0 ? "--tabbar-bottom:" + keybordHeight.value + "px" : ""), w: common_vendor.o(($event) => keybordHeight.value = 0), x: common_vendor.p({ show: keybordOverlay.value }), y: common_vendor.n(keybordHeight.value > 0 ? "keybord-fixed" : ""), z: common_vendor.o(goShuiBei), A: common_vendor.o(clickFooterInput), B: common_vendor.p({ type: "heart", size: "24" }), C: common_vendor.t(detail.value.likeCount), D: common_vendor.o(handleLike), E: common_vendor.p({ type: "star", size: "24" }), F: common_vendor.t(detail.value.collectCount), G: common_vendor.o(handleCollection), H: common_vendor.p({ type: "chat", size: "24" }), I: common_vendor.t(detail.value.commentCount), J: common_vendor.o(clickMessageIcon), K: common_vendor.p({ type: "closeempty", size: "28" }), L: common_vendor.o(($event) => showActionPopup.value = false), M: common_vendor.p({ type: "trash", size: "28" }), N: common_vendor.o(handleDelete), O: common_vendor.o(($event) => showActionPopup.value = false), P: common_vendor.p({ show: showActionPopup.value }) } : {}); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-04f1b7e6"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/article_details/index.js.map