From c31a8def0ac90d86b8e8e345441bd28002a9ef2f Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期一, 16 六月 2025 20:14:52 +0800
Subject: [PATCH] add: 分享

---
 components/comment/comment-popup.vue |   74 +++++++++++++++++++++++++++---------
 1 files changed, 55 insertions(+), 19 deletions(-)

diff --git a/components/comment/comment-popup.vue b/components/comment/comment-popup.vue
index 48fbdc3..a7eac02 100644
--- a/components/comment/comment-popup.vue
+++ b/components/comment/comment-popup.vue
@@ -169,29 +169,65 @@
   fileList.value.splice(index, 1);
 };
 
+// const sendComment = async () => {
+//   if (!canSend.value) return;
+
+//   try {
+//     const res = await $http.request('post', '/api/comment/create', {
+//       data: comment.value
+//     })
+    
+//     if (res.code == 0) {
+//       emit('success')
+//       emit('update:modelValue', false)
+      
+//       // 清除评论内容
+//       comment.value.content = ''
+//       fileList.value = []
+//       pictureList.value = []
+//     } else {
+//       $message.showToast('评论失败')
+//     }
+//   } catch (error) {
+//     console.error('评论失败:', error)
+//     $message.showToast('评论失败')
+//   }
+// }
 const sendComment = async () => {
   if (!canSend.value) return;
 
-  console.log("评论添加:", comment.value)
-  const {
-    code, data
-  } = await $http.request('post', '/api/comment/create', {
-    data: comment.value
-  })
-  if (code == 0) {
-    // 保存成功,返回评论?
-    console.log("评论新增成功")
-    emit('success'); // 告诉父组件刷新列表
-    emit('update:modelValue', false); // 关闭弹窗
-
-  } else {
-    $message.showToast('系统异常,无法获取当前微信是否已经绑定过账号')
+  try {
+    // 构建评论数据
+    const commentData = {
+      ...comment.value,
+      parentId: props.parentId || undefined, // 如果有parentId则使用,没有则为undefined
+      filmId: props.filmId,
+      content: comment.value.content,
+      fileList: comment.value.fileList,
+      filmPictures: comment.value.filmPictures
+    }
+	  console.log("commentData",commentData);
+    console.log("当前 parentId:", props.parentId); // 检查是否收到值
+    const res = await $http.request('post', '/api/comment/create', {
+      data: commentData
+    })
+    
+    if (res.code == 0) {
+      emit('success')
+      emit('update:modelValue', false)
+      
+      // 清除评论内容
+      comment.value.content = ''
+      fileList.value = []
+      pictureList.value = []
+    } else {
+      $message.showToast('评论失败')
+    }
+  } catch (error) {
+    console.error('评论失败:', error)
+    $message.showToast('评论失败')
   }
-
-  fileList.value = [];
-  // handleClose();
-};
-
+}
 
 const submitComment = async () => {
   

--
Gitblit v1.9.3