From 500078714411487af00161e01bd7e0b5efdc3414 Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期四, 07 八月 2025 13:32:32 +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..eccefc0 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 || void 0, // 如果有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