"use strict"; const common_vendor = require("../../common/vendor.js"); const apis_user = require("../../apis/user.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"); (_easycom_up_avatar2 + _easycom_up_text2)(); } 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"; if (!Math) { (_easycom_up_avatar + _easycom_up_text)(); } const _sfc_main = { __name: "CommentsBox", props: { data: { type: Object, default: () => ({ id: null, commentId: null, relatedPostId: null, userId: null, replyUserName: "名称", replyUserId: null, replyName: null, commentContent: "内容", type: null, children: [ { id: null, relatedPostId: null, userId: null, replyUserName: "名称", replyUserId: null, replyName: "名称2", commentContent: "内容", type: null }, { id: null, relatedPostId: null, userId: null, replyUserName: "名称", replyUserId: null, replyName: "名称2", commentContent: "内容", type: null }, { id: null, relatedPostId: null, userId: null, replyUserName: "名称", replyUserId: null, replyName: "名称2", commentContent: "内容", type: null } ] }) } }, emits: ["addComment"], setup(__props, { emit: __emit }) { const props = __props; const emit = __emit; const addComment = (itme) => { let data = { //帖子id relatedPostId: info.relatedPostId, // parentCommentId: info.id | null, replyUseId: itme.userId | null }; emit("addComment", data); }; const isZkai = common_vendor.ref(false); const zhankai = () => { isZkai.value = !isZkai.value; }; const info = common_vendor.reactive({ id: null, commentId: null, relatedPostId: null, imageUrl: null, userId: null, replyUserName: "名称", replyUserId: null, replyName: null, commentContent: "内容", type: null, children: [ { id: null, relatedPostId: null, commentId: null, userId: null, replyUserName: "名称", replyUserId: null, replyName: "名称2", commentContent: "内容", type: null }, { id: null, relatedPostId: null, userId: null, replyUserName: "名称", replyUserId: null, replyName: "名称2", commentContent: "内容", type: null }, { id: null, relatedPostId: null, userId: null, replyUserName: "名称", replyUserId: null, replyName: "名称2", commentContent: "内容", type: null } ] }); const getUserImage = async (id) => { let res = await apis_user.getImageById(id); if (res.code == 200) { info.imageUrl = res.msg; } }; common_vendor.onMounted(() => { console.log("评论数据", props.data); info.id = props.data.id; info.commentId = props.data.commentId; info.relatedPostId = props.data.relatedPostId; info.userId = props.data.userId; info.replyUserName = props.data.replyUserName; info.replyUserId = props.data.replyUserId; info.replyName = props.data.replyName; info.commentContent = props.data.commentContent; info.type = props.data.type; info.children = props.data.children | []; getUserImage(info.userId); console.log("长度", info.children, props.data.children); }); return (_ctx, _cache) => { return common_vendor.e({ a: common_vendor.p({ src: info.imageUrl, size: "30" }), b: common_vendor.p({ text: info.replyName }), c: common_vendor.p({ text: info.commentContent, size: "36rpx" }), d: common_vendor.o(($event) => addComment(info)), e: isZkai.value }, isZkai.value ? { f: common_vendor.f(props.data.children, (item, index, i0) => { return { a: "408006a6-3-" + i0, b: common_vendor.p({ text: item.replyName + ">" + item.replyUserName }), c: "408006a6-4-" + i0, d: common_vendor.p({ text: item.commentContent, size: "36rpx" }), e: item.id, f: common_vendor.o(($event) => addComment(item), item.id) }; }) } : {}, { g: props.data.children.length > 0 }, props.data.children.length > 0 ? { h: common_vendor.t(isZkai.value ? "收起" : "展开"), i: common_vendor.o(zhankai) } : {}); }; } }; const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-408006a6"], ["__file", "D:/uniapp1/gree_leran/components/CommentsBox/CommentsBox.vue"]]); wx.createComponent(Component);