| | |
| | | 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 () => { |
| | | |