"use strict"; const common_vendor = require("../../common/vendor.js"); const apis_cast = require("../../apis/cast.js"); const apis_user = require("../../apis/user.js"); const apis_comments = require("../../apis/comments.js"); const apis_likes = require("../../apis/likes.js"); const apis_collections = require("../../apis/collections.js"); require("../../utils/http.js"); require("../../utils/Auth.js"); if (!Array) { const _easycom_up_avatar2 = common_vendor.resolveComponent("up-avatar"); const _easycom_up_text2 = common_vendor.resolveComponent("up-text"); const _easycom_CommentsBox2 = common_vendor.resolveComponent("CommentsBox"); const _easycom_InputBox2 = common_vendor.resolveComponent("InputBox"); const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon"); (_easycom_up_avatar2 + _easycom_up_text2 + _easycom_CommentsBox2 + _easycom_InputBox2 + _easycom_up_icon2)(); } const _easycom_up_avatar = () => "../../node-modules/uview-plus/components/u-avatar/u-avatar.js"; const _easycom_up_text = () => "../../node-modules/uview-plus/components/u-text/u-text.js"; const _easycom_CommentsBox = () => "../../components/CommentsBox/CommentsBox.js"; const _easycom_InputBox = () => "../../components/InputBox/InputBox.js"; const _easycom_up_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js"; if (!Math) { (_easycom_up_avatar + _easycom_up_text + _easycom_CommentsBox + _easycom_InputBox + _easycom_up_icon)(); } const _sfc_main = { __name: "newsInfo", setup(__props) { const id = common_vendor.ref(null); common_vendor.ref(""); common_vendor.ref("path/to/avatar"); const inputVisible = common_vendor.ref(false); const inputContent = common_vendor.ref(""); common_vendor.ref("40px"); const info = common_vendor.reactive({ caseId: null, title: null, content: null, description: null, imageUrl: null, userId: null, name: null, createTime: null, isLike: false, isCollection: false, iamge: null }); const commentList = common_vendor.ref([]); const currParentCommentId = common_vendor.ref(null); const currReplyUseId = common_vendor.ref(null); const getInfo = async (id2) => { let res = await apis_cast.getCastInfo(id2); if (res.code == 200) { console.log("详细数据", res.data); return res; } return null; }; const addComment = (data) => { if (data != void 0) { currParentCommentId.value = data.parentCommentId | null; currReplyUseId.value = data.replyUseId | null; } else { currParentCommentId.value = null; currReplyUseId.value = null; } showInputBox(); }; const submitNote = (text) => { inputContent.value = text; submitComment(); inputContent.value = null; }; const blurCom = () => { inputVisible.value = false; }; const showInputBox = () => { inputVisible.value = true; common_vendor.index.nextTick(() => { }); }; const submitComment = async () => { console.log("提交评论", currParentCommentId.value, currReplyUseId.value); let res = await apis_comments.addComments({ relatedPostId: info.caseId, commentContent: inputContent.value, parentCommentId: currParentCommentId.value, replyUseId: currReplyUseId.value }); currParentCommentId.value = null; currReplyUseId.value = null; console.log("保存评论", res); inputContent.value = ""; getData(id.value); }; const getData = async () => { let com = await getInfo(id.value); com = com.data; let list = await apis_comments.getCommentsByRelatedPostId(id.value); let image = await apis_user.getImageById(com.userId); list = list.data; console.log("接口", com, list); commentList.value = list; info.iamge = image.msg; info.caseId = com.caseId; info.title = com.title; info.content = com.content; info.description = com.description; info.imageUrl = com.imageUrl; info.userId = com.userId; info.createTime = com.createTime; info.isLike = com.extField4 == "1"; info.isCollection = com.extField5 == "1"; }; const clickLike = () => { info.isLike = !info.isLike; let bo = "0"; if (info.isLike) { bo = "1"; } apis_likes.addLike({ contentType: 0, contentId: info.caseId, extField1: bo }); }; const clickCollection = () => { info.isCollection = !info.isCollection; let bo = "0"; if (info.isCollection) { bo = "1"; } apis_collections.addCollections({ contentType: 0, contentId: info.caseId, extField1: bo }); }; common_vendor.onLoad((e) => { console.log("进入", e); id.value = e.id; getData(); }); return (_ctx, _cache) => { return common_vendor.e({ a: common_vendor.p({ src: info.iamge, size: "70" }), b: common_vendor.p({ text: "作者名", size: "33rpx", bold: true }), c: common_vendor.p({ text: "发布于-" + info.createTime }), d: common_vendor.p({ text: info.title, bold: "true", size: "47rpx" }), e: common_vendor.p({ text: info.content, color: "#8f8f8f" }), f: common_vendor.p({ text: info.description, size: "40rpx" }), g: info.imageUrl, h: common_vendor.f(commentList.value, (item, index, i0) => { return { a: common_vendor.o(addComment, item.id), b: item.id, c: "5ecea49e-6-" + i0, d: common_vendor.p({ data: item }) }; }), i: inputVisible.value }, inputVisible.value ? { j: common_vendor.o(submitNote), k: common_vendor.o(blurCom) } : {}, { l: info.isLike }, info.isLike ? { m: common_vendor.o(clickLike), n: common_vendor.p({ name: "heart-fill", color: "red", size: "28" }) } : { o: common_vendor.o(clickLike), p: common_vendor.p({ name: "heart", color: "#000", size: "28" }) }, { q: info.isCollection }, info.isCollection ? { r: common_vendor.o(clickCollection), s: common_vendor.p({ name: "star-fill", color: "#ffe135", size: "28" }) } : { t: common_vendor.o(clickCollection), v: common_vendor.p({ name: "star", color: "#000", size: "28" }) }, { w: common_vendor.o(($event) => addComment()) }); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/uniapp1/gree_leran/pages/newsInfo/newsInfo.vue"]]); wx.createPage(MiniProgramPage);