PC-vote/components/DetailsComments.vue

1057 lines
44 KiB
Vue
Raw Permalink Normal View History

2024-01-12 19:12:30 +08:00
<template>
2024-07-17 12:25:33 +08:00
<div class="comment-box">
2025-02-17 19:01:20 +08:00
<!-- 编辑评论 -->
<div v-if="editCommentState" class="edit-comment flexcenter">
<div class="box">
<div class="text">编辑评论</div>
<div class="input-box">
<div class="top flexflex">
<textarea ref="editInputRef" class="input-textarea flex1" maxlength="500" v-model="editInput" @focus="judgeLogin" @input="autoResize" @paste="handleInputPaste" placeholder="说说你的想法或疑问…"></textarea>
</div>
<div class="picture-box" v-if="editPicture.url">
<div class="picture">
<img class="close" @click="closeEditFileUpload()" src="@/assets/img/close-icon.png" />
<img class="img" @click="handleAnswerText" :src="editPicture.base64 || editPicture.url" />
</div>
</div>
<div class="bottom flexacenter">
<div class="operate flexacenter">
2025-04-10 17:03:51 +08:00
<div class="item" :class="{ pitch: editEmojiState }">
2025-02-17 19:01:20 +08:00
<img class="icon" src="@/assets/img/smiling-face.png" @click="openEditEmoji()" alt="" />
<div class="emoji-box">
<div class="emoji-icon" v-for="item in emojiData" :key="item" @click="selectEditEmoji(item)">{{ item }}</div>
</div>
</div>
<div class="item flexacenter" @click="judgeLogin()">
<input class="file" type="file" @change="handleFileUpload($event)" accept=".png, .jpg, .jpeg" />
2025-04-10 17:03:51 +08:00
<img class="icon" style="border-radius: 0" src="@/assets/img/picture-icon.png" alt="" />
2025-02-17 19:01:20 +08:00
<span class="file-hint">最多可上传1张图片支持在输入框中直接粘贴图片</span>
</div>
</div>
</div>
</div>
<div class="btn-list flexacenter">
<div class="btn" @click="closeEdit()">取消</div>
<div class="btn send" @click="postEditComment()">发送</div>
</div>
</div>
</div>
2024-07-17 12:25:33 +08:00
<div class="comment-title flexacenter">
讨论
<span class="comment-amount">{{ commentComments || "" }}</span>
2024-01-29 11:53:50 +08:00
</div>
2025-02-10 19:04:24 +08:00
<!-- <div class="post-comment" ref="postInputRef" :class="{ 'post-comment-focus': postCommentFocusState }" @click="loginJudgment()">
2024-07-17 12:25:33 +08:00
<div class="post-comment-input">
<el-input class="post-input flex1" type="textarea" :autosize="postCommentFocusState" :maxlength="500" show-word-limit placeholder="说说你的想法或疑问…" v-model="commentInputTop" @blur="postCommentFocusBlur" @focus="postCommentFocusState = true"></el-input>
</div>
2024-01-25 19:29:12 +08:00
2024-07-17 12:25:33 +08:00
<div class="post-ok flexcenter" @click="submitAnswerComments(commentInputTop)">发送</div>
2025-02-10 19:04:24 +08:00
</div> -->
2025-02-17 19:01:20 +08:00
<div class="input-box">
2025-02-10 19:04:24 +08:00
<div class="top flexflex">
2025-02-13 19:05:38 +08:00
<img class="avatar" v-if="userInfoWin.avatar" :src="userInfoWin.avatar" />
2025-02-17 19:01:20 +08:00
<textarea class="input-textarea flex1" maxlength="500" v-model="commentInputTop" @focus="judgeLogin" @input="autoResize" @paste="handleInputPaste" placeholder="说说你的想法或疑问…"></textarea>
2025-02-10 19:04:24 +08:00
</div>
<div class="picture-box" v-if="picture.url">
<div class="picture">
<img class="close" @click="closeFileUpload()" src="@/assets/img/close-icon.png" />
<img class="img" @click="handleAnswerText" :src="picture.base64 || picture.url" />
</div>
</div>
<div class="bottom flexacenter">
<div class="operate flexacenter">
2025-04-10 17:03:51 +08:00
<div class="item" :class="{ pitch: emojiState }">
2025-02-10 19:04:24 +08:00
<img class="icon" src="@/assets/img/smiling-face.png" @click="openEmoji()" alt="" />
<div class="emoji-box">
<div class="emoji-icon" v-for="item in emojiData" :key="item" @click="selectEmoji(item)">{{ item }}</div>
</div>
</div>
2025-02-17 19:01:20 +08:00
<div class="item flexacenter" @click="judgeLogin()">
2025-02-10 19:04:24 +08:00
<input class="file" type="file" @change="handleFileUpload($event)" accept=".png, .jpg, .jpeg" />
2025-02-13 19:05:38 +08:00
<img class="icon" src="@/assets/img/picture-icon.png" alt="" />
2025-02-10 19:04:24 +08:00
<span class="file-hint">最多可上传1张图片支持在输入框中直接粘贴图片</span>
</div>
</div>
<div class="btn" @click="submitAnswerComments(commentInputTop)">发送</div>
</div>
2024-07-17 12:25:33 +08:00
</div>
2024-01-12 19:12:30 +08:00
2024-07-17 12:25:33 +08:00
<div class="empty-box" v-if="isEmptyState">
<Empty hint="说说你的观点吧"></Empty>
</div>
<template v-else>
<div class="comment-list">
<div class="comment-item flexflex" v-for="(item, index) in commentList" :key="item.id">
<el-popover placement="bottom-start" :width="140" trigger="click" popper-class="avatar-box-popper" :show-arrow="false" v-model:visible="item['popoverState']">
<template #reference>
<img class="comment-avatar" :src="item['avatar']" />
</template>
<div class="avatar-box flexflex" v-if="item['uin']">
<a class="avatar-item flexcenter" target="_blank" @click.prevent="sendMessage(item['uin'])">
<img class="avatar-icon" src="@/assets/img/send-messages-icon.png" />
发送信息
</a>
<a class="avatar-item flexcenter" target="_blank" @click.prevent="TAHomePage(item['uin'])">
<img class="avatar-icon" src="@/assets/img/homepage-icon.png" />
TA的主页
</a>
2024-01-12 19:12:30 +08:00
</div>
2024-07-17 12:25:33 +08:00
</el-popover>
<div class="comment-content flex1">
<div class="comment-header flexacenter">
<div class="comment-header-left flexacenter">
<div class="comments-username" @click="openAvatarPopover(index)">{{ item["nickname"] }}</div>
<div class="comments-time">{{ item["timestampnow"] || handleDate(item["timestamp"]) }}</div>
<div class="comments-identity" v-if="item['isauthor']">作者</div>
2025-03-21 15:49:12 +08:00
<!-- <img class="comments-title" v-if="item['groupid'] === 14" src="@/assets/img/title.png" /> -->
<img class="comments-title" v-if="item['groupimage']" :src="item.groupimage" :alt="item.grouptitle" />
2024-01-12 19:12:30 +08:00
</div>
2024-07-17 12:25:33 +08:00
<div class="comment-header-right flexacenter">
<div class="menu-box flexacenter">
<img class="menu-icon" src="@/assets/img/menu-icon-gray.svg" />
2025-02-13 19:05:38 +08:00
<div class="operate-box">
<div class="item flexcenter" @click="report(item['token'])">举报</div>
2025-02-17 19:01:20 +08:00
<div class="item flexcenter" v-if="permissions.includes('comment.edit')" @click="openEdit(item['token'], index)">编辑</div>
<div class="item flexcenter" v-if="permissions.includes('comment.delete')" @click="commentDelete(item['token'], index)">删除</div>
2025-02-13 19:05:38 +08:00
</div>
2024-07-17 12:25:33 +08:00
</div>
<!-- <img class="comment-icon" title="回复" @click="openAnswerCommentsChild(index)" src="@/assets/img/comment-icon-gray.svg" /> -->
<img class="comment-icon" title="回复" @click="!item['childState'] ? openAnswerCommentsChild(index) : closeAnswerCommentsChild()" src="@/assets/img/comment-icon-gray.svg" />
<div class="flexacenter like-box" @click="commentLike(index)">
<img class="like-icon" v-if="item['islike'] == 1" src="@/assets/img/like-icon-colours.png" />
<img class="like-icon" v-else src="@/assets/img/like-icon-gray.png" />
<div class="like-quantity">{{ item["likenum"] || 0 }}</div>
</div>
2024-01-12 19:12:30 +08:00
</div>
</div>
2024-07-17 12:25:33 +08:00
<!-- shutAnswerCommentsChild openAnswerCommentsChild -->
2025-02-18 19:05:50 +08:00
<div class="comment-text" v-if="item['content']" @click="!item['childState'] ? openAnswerCommentsChild(index) : closeAnswerCommentsChild()">{{ item["content"] }}</div>
2025-02-13 19:05:38 +08:00
<img class="comments-img" @click="handleAnswerText" :src="item.image?.base64 || item.image?.url" v-if="item.image?.url" />
2024-07-17 12:25:33 +08:00
<div class="alreadyVoted" v-if="item.voteoption">已投{{ item.voteoption }}</div>
2025-02-13 19:05:38 +08:00
<div class="input-box" v-if="item['childState']">
<img class="cross" @click="closeAnswerCommentsChild()" src="@/assets/img/cross-icon.png" />
<div class="top flexflex">
<textarea class="input-textarea flex1" maxlength="500" placeholder="说说你的想法或疑问…" v-model="item['commentInput']" @input="autoResize" @paste="handleInputPaste($event, index)"></textarea>
</div>
<div class="picture-box" v-if="item.picture?.url">
<div class="picture">
<img class="close" @click="closeFileUpload(index)" src="@/assets/img/close-icon.png" />
<img class="img" @click="handleAnswerText" :src="item.picture?.base64 || item.picture.url" />
</div>
</div>
<div class="bottom flexacenter">
<div class="operate flexacenter">
2025-04-10 17:03:51 +08:00
<div class="item" :class="{ pitch: item.emojiState }">
2025-02-13 19:05:38 +08:00
<img class="icon" src="@/assets/img/smiling-face.png" @click="openEmoji(index)" alt="" />
<div class="emoji-box">
<div class="emoji-icon" v-for="item in emojiData" :key="item" @click="selectEmoji(item, index)">{{ item }}</div>
</div>
</div>
<div class="item flexacenter">
<input class="file" type="file" @change="handleFileUpload($event, index)" accept=".png, .jpg, .jpeg" />
<img class="icon" src="@/assets/img/picture-icon.png" alt="" />
<span class="file-hint">最多可上传1张图片支持在输入框中直接粘贴图片</span>
</div>
</div>
<div class="btn" @click="submitAnswerComments(item['commentInput'], index)">发送</div>
</div>
</div>
<!-- <div class="comments-input-masking" @click="closeAnswerCommentsChild()" v-if="item['childState']"></div>
2024-07-17 12:25:33 +08:00
<div class="comments-input-box" :class="{ 'comments-input-box-show': item['childState'] }">
<div class="comments-input">
<el-input v-model="commentInput" type="textarea" placeholder="回复" :maxlength="500" show-word-limit></el-input>
<div class="operate-bottom flexacenter">
<div class="comments-btn comments-btn-cancel flexcenter" @click="closeAnswerCommentsChild()">取消</div>
<div class="comments-btn flexcenter" @click="submitAnswerComments(commentInput, index)">发送</div>
</div>
2024-01-29 15:18:58 +08:00
</div>
2025-02-13 19:05:38 +08:00
</div> -->
2024-07-17 12:25:33 +08:00
<!-- 子评论 -->
<div class="child-comments" v-if="item['child'].length > 0">
<div class="comment-item flexflex" v-for="(ite, i) in item['child']" :key="ite.id">
<el-popover placement="bottom-start" :width="140" trigger="click" popper-class="avatar-box-popper" :show-arrow="false" v-model:visible="ite['popoverState']">
<template #reference>
<img class="comment-avatar" :src="ite['avatar']" />
</template>
<div class="avatar-box flexflex" v-if="ite['uin']">
<a class="avatar-item flexcenter" target="_blank" @click.prevent="sendMessage(ite['uin'])">
<img class="avatar-icon" src="@/assets/img/send-messages-icon.png" />
发送信息
</a>
<a class="avatar-item flexcenter" target="_blank" @click.prevent="TAHomePage(ite['uin'])">
<img class="avatar-icon" src="@/assets/img/homepage-icon.png" />
TA的主页
</a>
2024-01-12 19:12:30 +08:00
</div>
2024-07-17 12:25:33 +08:00
</el-popover>
<div class="comment-content flex1">
<div class="comment-header flexacenter">
<div class="comment-header-left flexacenter">
<div class="comments-username" @click="openAvatarPopover(index, i)">{{ ite["nickname"] }}</div>
<div class="comments-time">{{ ite["timestampnow"] || handleDate(ite["timestamp"]) }}</div>
<div class="comments-identity" v-if="ite['isauthor']">作者</div>
2025-03-21 15:49:12 +08:00
<img class="comments-title" v-if="ite['groupimage']" :src="ite.groupimage" :alt="ite.grouptitle" />
2024-01-12 19:12:30 +08:00
</div>
2024-07-17 12:25:33 +08:00
<div class="comment-header-right flexacenter">
<div class="menu-box flexacenter">
<img class="menu-icon" src="@/assets/img/menu-icon-gray.svg" />
2025-02-13 19:05:38 +08:00
<div class="operate-box">
<div class="item flexcenter" @click="report(ite['token'])">举报</div>
2025-02-17 19:01:20 +08:00
<div class="item flexcenter" v-if="permissions.includes('comment.edit')" @click="openEdit(ite['token'], index, i)">编辑</div>
<div class="item flexcenter" v-if="permissions.includes('comment.delete')" @click="commentDelete(ite['token'], index, i)">删除</div>
2025-02-13 19:05:38 +08:00
</div>
2024-07-17 12:25:33 +08:00
</div>
<img class="comment-icon" title="回复" @click="!ite['childState'] ? openAnswerCommentsChild(index, i) : closeAnswerCommentsChild()" src="@/assets/img/comment-icon-gray.svg" />
<div class="flexacenter like-box" @click="commentLike(index, i)">
<img class="like-icon" v-if="ite['islike'] == 1" src="@/assets/img/like-icon-colours.png" />
<img class="like-icon" v-else src="@/assets/img/like-icon-gray.png" />
<div class="like-quantity">{{ ite["likenum"] || 0 }}</div>
</div>
2024-01-12 19:12:30 +08:00
</div>
</div>
2025-02-18 19:05:50 +08:00
<div class="comment-text" v-if="ite['content']" @click="!ite['childState'] ? openAnswerCommentsChild(index, i) : closeAnswerCommentsChild()">
2024-07-17 12:25:33 +08:00
<div class="comments-reply" v-if="ite?.reply?.nickname">@{{ ite?.reply?.nickname }}</div>
{{ ite["content"] }}
</div>
2025-02-13 19:05:38 +08:00
<img class="comments-img" @click="handleAnswerText" :src="ite.image?.base64 || ite.image?.url" v-if="ite.image?.url" />
2024-07-17 12:25:33 +08:00
<div class="alreadyVoted" v-if="ite.voteoption">已投{{ ite.voteoption }}</div>
2025-02-13 19:05:38 +08:00
<div class="input-box" v-if="ite['childState']">
<img class="cross" @click="closeAnswerCommentsChild()" src="@/assets/img/cross-icon.png" />
<div class="top flexflex">
<textarea class="input-textarea flex1" maxlength="500" :placeholder="'回复“' + (ite['nickname'] || '匿名用户') + '”:'" v-model="ite['commentInput']" @input="autoResize" @paste="handleInputPaste($event, index)"></textarea>
</div>
<div class="picture-box" v-if="ite.picture?.url">
<div class="picture">
<img class="close" @click="closeFileUpload(index, i)" src="@/assets/img/close-icon.png" />
<img class="img" @click="handleAnswerText" :src="ite.picture.base64 || ite.picture.url" />
</div>
</div>
<div class="bottom flexacenter">
<div class="operate flexacenter">
2025-04-10 17:03:51 +08:00
<div class="item" :class="{ pitch: ite.emojiState }">
2025-02-13 19:05:38 +08:00
<img class="icon" src="@/assets/img/smiling-face.png" @click="openEmoji(index, i)" alt="" />
<div class="emoji-box">
<div class="emoji-icon" v-for="item in emojiData" :key="item" @click="selectEmoji(item, index, i)">{{ item }}</div>
</div>
</div>
<div class="item flexacenter">
<input class="file" type="file" @change="handleFileUpload($event, index, i)" accept=".png, .jpg, .jpeg" />
<img class="icon" src="@/assets/img/picture-icon.png" alt="" />
<span class="file-hint">最多可上传1张图片支持在输入框中直接粘贴图片</span>
</div>
</div>
<div class="btn" @click="submitAnswerComments(ite['commentInput'], index, i)">发送</div>
</div>
</div>
<!-- <div class="comments-input-masking" @click="closeAnswerCommentsChild()" v-if="ite['childState']"></div>
2024-07-17 12:25:33 +08:00
<div class="comments-input-box" :class="{ 'comments-input-box-show': ite['childState'] }">
<div class="comments-input">
<el-input v-model="commentInput" type="textarea" placeholder="回复" :maxlength="500" show-word-limit></el-input>
<div class="operate-bottom flexacenter">
<div class="comments-btn comments-btn-cancel flexcenter" @click="closeAnswerCommentsChild()">取消</div>
<div class="comments-btn flexcenter" @click="submitAnswerComments(commentInput, index, i)">发送</div>
</div>
2024-01-29 15:18:58 +08:00
</div>
2025-02-13 19:05:38 +08:00
</div> -->
2024-01-12 19:12:30 +08:00
</div>
</div>
</div>
2024-07-17 12:25:33 +08:00
<!-- 还有几个 -->
<div class="comments-also flexacenter" v-if="item['childnum'] > item['child'].length" @click="alsoCommentsData(index)">
<div class="">还有{{ item["childnum"] - item["child"].length }}条回复</div>
<img class="also-icon" src="@/assets/img/arrow-circular-gray.png" />
</div>
2024-01-12 19:12:30 +08:00
</div>
</div>
</div>
2024-07-17 12:25:33 +08:00
<div class="comment-end" v-if="commentPage == 0 && commentList.length != 0">· End ·</div>
</template>
</div>
2024-01-12 19:12:30 +08:00
<Report v-if="reportAlertShow" :reportToken="reportToken"></Report>
2024-01-24 17:20:53 +08:00
<!-- 投票后自动评论 -->
2024-01-29 11:53:50 +08:00
<el-dialog class="default-popup automatic-reviews-popup" v-model="reviewsPopoverState" width="720px" align-center autosize :close-on-click-modal="false">
2024-01-24 17:20:53 +08:00
<div class="automatic-header">
<div class="automatic-title">说说您的投票理由</div>
<div class="automatic-have">已投{{ haveVotedValue }}</div>
</div>
2024-01-29 15:18:58 +08:00
<el-input class="automatic-input" placeholder="请输入…" v-model="reviewsPopoverInput" type="textarea" maxlength="500" show-word-limit></el-input>
2024-01-24 17:20:53 +08:00
<div class="automatic-bottom flexflex">
<div class="automatic-send flexcenter" @click="submitAnswerComments(reviewsPopoverInput)">发送</div>
</div>
</el-dialog>
2025-02-13 19:05:38 +08:00
<!-- 大图 -->
<div class="detail-image-mask flexcenter" v-if="dialogSrc" @click="dialogSrc = ''">
<div class="detail-image flexcenter">
<img class="detail-img" :src="dialogSrc" />
</div>
</div>
2025-02-18 19:05:50 +08:00
<el-dialog v-model="dialogVisible" title="提示" width="500">
<span>确定删除该讨论吗</span>
<template #footer>
<div class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="confirmCommentDelete"> </el-button>
</div>
</template>
</el-dialog>
2024-01-12 19:12:30 +08:00
</template>
<script setup>
2025-04-10 17:03:51 +08:00
import { ElMessage } from "element-plus";
import { isEmpty } from "element-plus/es/utils";
2024-01-18 17:25:40 +08:00
2025-04-10 17:03:51 +08:00
let haveVotedValue = inject("haveVotedValue");
2024-01-24 17:20:53 +08:00
2025-04-10 17:03:51 +08:00
let isNeedLogin = inject("isNeedLogin");
const goLogin = inject("goLogin");
2024-01-18 17:25:40 +08:00
2025-04-10 17:03:51 +08:00
const props = defineProps({ token: String });
const userInfoWin = inject("userInfoWin");
2024-01-12 19:12:30 +08:00
watch(
() => props.token,
2024-01-15 19:02:10 +08:00
() => getCommentList(),
{ immediate: false }
2025-04-10 17:03:51 +08:00
);
2024-01-15 19:02:10 +08:00
2025-04-10 17:03:51 +08:00
onMounted(() => window.addEventListener("scroll", handleScroll));
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
let permissions = ref([]);
2025-02-17 19:01:20 +08:00
onMounted(() => {
setTimeout(() => {
2025-04-10 17:03:51 +08:00
permissions.value = window["permissions"] || [];
2025-02-18 19:05:50 +08:00
// permissions.value = ["comment.edit", "comment.delete"]
2025-04-10 17:03:51 +08:00
}, 1000);
});
2025-02-10 19:04:24 +08:00
2025-04-10 17:03:51 +08:00
const sendMessage = inject("sendMessage");
const TAHomePage = inject("TAHomePage");
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
let postCommentFocusState = ref(false);
2024-01-23 19:10:57 +08:00
2025-04-10 17:03:51 +08:00
let commentCount = ref(0);
let commentComments = ref(0); // 所有的评论数
let commentPage = ref(1);
let commentList = ref([]);
let commentLoading = false;
let isEmptyState = ref(false); // 评论是否为空
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
const emit = defineEmits(["update:commentComments"]);
2024-07-17 12:25:33 +08:00
2024-01-12 19:12:30 +08:00
// 获取详情评论数据
const getCommentList = () => {
2025-04-10 17:03:51 +08:00
if (commentPage.value == 0 || commentLoading || !props.token) return;
commentLoading = true;
2024-01-12 19:12:30 +08:00
commentListHttp({
page: commentPage.value,
childlimit: 1,
limit: 10,
token: props.token,
})
2025-04-10 17:03:51 +08:00
.then((res) => {
if (res.code != 200) return;
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
let data = res.data;
commentCount.value = data["count"];
if (data["count"] == 0) isEmptyState.value = true;
else isEmptyState.value = false;
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
commentList.value = commentList.value.concat(data["data"]);
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
commentComments.value = data["comments"];
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
emit("update:commentComments", data["comments"]);
2024-07-17 12:25:33 +08:00
2025-04-10 17:03:51 +08:00
if (commentList.value.length == data["count"]) commentPage.value = 0;
else commentPage.value++;
2024-01-12 19:12:30 +08:00
})
2025-04-10 17:03:51 +08:00
.finally(() => (commentLoading = false));
};
2024-01-12 19:12:30 +08:00
// 评论点赞
const commentLike = (index, i) => {
2024-01-18 17:25:40 +08:00
if (isNeedLogin.value) {
2025-04-10 17:03:51 +08:00
goLogin();
return;
2024-01-18 17:25:40 +08:00
}
2025-04-10 17:03:51 +08:00
const targetCommentList = [...commentList.value];
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
let token = "";
if (i != null) token = targetCommentList[index]["child"][i].token;
else token = targetCommentList[index].token;
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
detailsLikeCommentHttp({ token }).then((res) => {
if (res.code != 200) return;
let data = res.data;
2024-01-12 19:12:30 +08:00
if (i != null) {
2025-04-10 17:03:51 +08:00
targetCommentList[index]["child"][i].islike = data["status"];
targetCommentList[index]["child"][i].likenum = data["likenum"];
2024-01-12 19:12:30 +08:00
} else {
2025-04-10 17:03:51 +08:00
targetCommentList[index].islike = data["status"];
targetCommentList[index].likenum = data["likenum"];
2024-01-12 19:12:30 +08:00
}
2025-04-10 17:03:51 +08:00
ElMessage.success(res.message);
});
};
2024-01-12 19:12:30 +08:00
// 打开 回答-评论 的子评论
const openAnswerCommentsChild = (index, i) => {
2024-01-18 17:25:40 +08:00
if (isNeedLogin.value) {
2025-04-10 17:03:51 +08:00
goLogin();
return;
2024-01-18 17:25:40 +08:00
}
2025-04-10 17:03:51 +08:00
closeAnswerCommentsChild();
2024-01-23 19:10:57 +08:00
2025-04-10 17:03:51 +08:00
if (i == null) commentList.value[index]["childState"] = true;
else commentList.value[index]["child"][i]["childState"] = true;
};
2024-01-29 15:18:58 +08:00
2024-01-18 17:25:40 +08:00
// 关闭 回答-评论 的子评论 isempty 是否需要清空输入框 默认需要清空
2024-01-23 19:10:57 +08:00
const closeAnswerCommentsChild = () => {
2025-04-10 17:03:51 +08:00
commentList.value.forEach((ele) => {
ele["childState"] = false;
if (ele["child"] && ele["child"].length != 0) ele["child"].forEach((el) => (el["childState"] = false));
});
};
2024-01-12 19:12:30 +08:00
// 讨论的输入框
2025-04-10 17:03:51 +08:00
let commentInputTop = ref("");
let commentInput = ref("");
2024-01-12 19:12:30 +08:00
// 提交回答-评论
2024-01-24 17:20:53 +08:00
const submitAnswerComments = (content, index, i) => {
2024-01-12 19:12:30 +08:00
if (isNeedLogin.value) {
2025-04-10 17:03:51 +08:00
goLogin();
return;
2024-01-12 19:12:30 +08:00
}
2025-04-10 17:03:51 +08:00
const targetCommentList = [...commentList.value];
2024-01-24 17:20:53 +08:00
// let content = ""
2025-04-10 17:03:51 +08:00
let parentid = null;
2024-01-12 19:12:30 +08:00
2024-01-24 17:20:53 +08:00
// if (index == null) content = commentInputTop.value
// else content = commentInput.value
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
let image = {};
2024-01-12 19:12:30 +08:00
2025-02-13 19:05:38 +08:00
if (i != null) {
2025-04-10 17:03:51 +08:00
parentid = targetCommentList[index]["child"][i]["id"];
image = commentList.value[index]["child"][i]["picture"] || {};
2025-02-13 19:05:38 +08:00
} else if (index != null) {
2025-04-10 17:03:51 +08:00
parentid = targetCommentList[index]["id"];
image = commentList.value[index]["picture"] || {};
} else image = picture.value;
2025-02-13 19:05:38 +08:00
// if (!content) {
// ElMessage.error("请填写评论内容")
// return
// }
2024-01-23 19:10:57 +08:00
2024-01-12 19:12:30 +08:00
detailsSubmitommentListHttp({
content,
2024-01-15 19:02:10 +08:00
token: props.token,
2024-01-12 19:12:30 +08:00
parentid,
2025-02-13 19:05:38 +08:00
image: image ? { aid: image.aid, url: image.url } : null,
2025-04-10 17:03:51 +08:00
}).then((res) => {
2024-01-12 19:12:30 +08:00
if (res.code != 200) {
2025-04-10 17:03:51 +08:00
ElMessage.error(res.message);
return;
2024-01-12 19:12:30 +08:00
}
2024-01-24 17:20:53 +08:00
2025-04-10 17:03:51 +08:00
let data = res.data;
2024-01-12 19:12:30 +08:00
if (i != null) {
2025-02-20 14:19:15 +08:00
// console.log("targetCommentList[index]", targetCommentList[index])
2025-04-10 17:03:51 +08:00
targetCommentList[index]["child"][i]["commentInput"] = "";
targetCommentList[index]["child"][i]["picture"] = {};
2025-02-13 19:05:38 +08:00
2024-01-12 19:12:30 +08:00
let targetData = {
id: data["commentid"],
content,
isauthor: 1,
islike: 0,
likenum: 0,
reply: {
nickname: targetCommentList[index]["child"][i]["nickname"],
},
2024-01-24 17:20:53 +08:00
voteoption: haveVotedValue.value || null,
2024-01-12 19:12:30 +08:00
...data,
2024-01-29 11:53:50 +08:00
// ...data.data
timestampnow: "刚刚",
uin: data.data?.uin,
2025-02-13 19:05:38 +08:00
image,
2025-04-10 17:03:51 +08:00
};
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
targetCommentList[index]["child"].unshift(targetData);
targetCommentList[index]["childnum"]++;
2024-01-12 19:12:30 +08:00
} else {
let targetData = {
id: data["commentid"],
content,
isauthor: 1,
islike: 0,
likenum: 0,
...data,
2024-01-29 11:53:50 +08:00
// ...data.data,
timestampnow: "刚刚",
uin: data.data?.uin,
2024-01-12 19:12:30 +08:00
child: [],
2024-01-24 17:20:53 +08:00
voteoption: haveVotedValue.value || null,
2025-02-13 19:05:38 +08:00
image,
2025-04-10 17:03:51 +08:00
};
2024-01-12 19:12:30 +08:00
if (index != null) {
2025-04-10 17:03:51 +08:00
targetCommentList[index]["commentInput"] = "";
targetCommentList[index]["picture"] = {};
targetCommentList[index]["child"].unshift(targetData);
targetCommentList[index]["childnum"]++;
2024-01-12 19:12:30 +08:00
} else {
2025-04-10 17:03:51 +08:00
targetCommentList.unshift(targetData);
commentCount.value++;
2024-01-12 19:12:30 +08:00
}
}
2024-01-15 19:02:10 +08:00
2025-04-10 17:03:51 +08:00
commentComments.value++;
commentList.value = targetCommentList;
2024-01-12 19:12:30 +08:00
// 请求 输入框的数据
2025-04-10 17:03:51 +08:00
commentInputTop.value = "";
commentInput.value = "";
reviewsPopoverInput.value = "";
reviewsPopoverState.value = false;
isEmptyState.value = false; // 取消有可能的 没有评论
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
closeAnswerCommentsChild();
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
picture.value = {};
2025-02-13 19:05:38 +08:00
2024-01-24 17:20:53 +08:00
if (bottomNavigationState) {
2025-04-10 17:03:51 +08:00
bottomNavigationState = false;
floorCommentBtn("back");
2024-01-24 17:20:53 +08:00
}
2025-04-10 17:03:51 +08:00
ElMessage.success(res.message);
});
};
2024-01-12 19:12:30 +08:00
// 获取剩下的子评论
const alsoCommentsData = (index, ind) => {
2024-01-18 17:25:40 +08:00
if (isNeedLogin.value) {
2025-04-10 17:03:51 +08:00
goLogin();
return;
2024-01-18 17:25:40 +08:00
}
2025-04-10 17:03:51 +08:00
let targetCommentItem = { ...commentList.value[index] };
const token = targetCommentItem["token"];
const parentid = targetCommentItem["id"];
let page = targetCommentItem["childPage"] ?? 1;
2024-01-12 19:12:30 +08:00
detailsChildCommentListHttp({
childlimit: 1,
limit: 10,
page,
parentid,
2024-01-15 19:02:10 +08:00
token: props.token,
2025-04-10 17:03:51 +08:00
}).then((res) => {
if (res.code != 200) return;
let data = res.data;
let childData = targetCommentItem.child.concat(data.data);
2024-01-12 19:12:30 +08:00
const filteredData = childData.filter((obj, index, self) => {
// 检查当前对象在数组中的第一个索引是否与当前索引相等
2025-04-10 17:03:51 +08:00
return self.findIndex((item) => item.id == obj.id) == index;
});
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
targetCommentItem.child = filteredData;
targetCommentItem["childnum"] = data.count;
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
if (targetCommentItem.child.length == data["count"]) page = 0;
else page++;
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
targetCommentItem["childPage"] = page;
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
commentList.value[index] = targetCommentItem;
});
};
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
let reportAlertShow = ref(false);
let reportToken = ref("");
2024-01-12 19:12:30 +08:00
// 点击打开举报
2025-04-10 17:03:51 +08:00
const report = (token) => {
2024-01-12 19:12:30 +08:00
if (isNeedLogin.value) {
2025-04-10 17:03:51 +08:00
goLogin();
return;
2024-01-12 19:12:30 +08:00
}
2025-04-10 17:03:51 +08:00
reportToken.value = token;
reportAlertShow.value = true;
};
2024-01-12 19:12:30 +08:00
// 打开评论的 信息框
const openAvatarPopover = (index, i) => {
2024-01-18 17:25:40 +08:00
if (isNeedLogin.value) {
2025-04-10 17:03:51 +08:00
goLogin();
return;
2024-01-18 17:25:40 +08:00
}
2025-04-10 17:03:51 +08:00
if (i != null) commentList.value[index]["child"][i]["popoverState"] = true;
else commentList.value[index]["popoverState"] = true;
};
2024-01-12 19:12:30 +08:00
// 监听滚动到底部
const handleScroll = () => {
// return
2025-04-10 17:03:51 +08:00
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
const scrollHeight = document.documentElement.scrollHeight;
const clientHeight = document.documentElement.clientHeight;
2024-01-12 19:12:30 +08:00
// 列表下 滑动到底部 获取新数据
2025-04-10 17:03:51 +08:00
if (scrollTop + clientHeight >= scrollHeight - 40) getCommentList();
};
2024-01-12 19:12:30 +08:00
2025-04-10 17:03:51 +08:00
provide("reportAlertShow", reportAlertShow);
2024-01-18 17:25:40 +08:00
// 登录判断
const loginJudgment = () => {
2025-04-10 17:03:51 +08:00
if (isNeedLogin.value) goLogin();
};
2024-01-18 17:25:40 +08:00
// 修改投票的值
2025-04-10 17:03:51 +08:00
const changeCommentVoteoption = (voteoption) => {
const uin = window["userInfoWin"]["uin"];
commentList.value.forEach((element) => {
if (uin == element["uin"]) element["voteoption"] = voteoption;
element.child.forEach((el) => {
if (uin == element["uin"]) el["voteoption"] = voteoption;
});
});
};
2024-01-18 17:25:40 +08:00
// 修改投票的值
const wipeCommentVoteoption = () => {
2025-04-10 17:03:51 +08:00
const uin = window["userInfoWin"]["uin"];
commentList.value.forEach((element) => {
if (uin == element["uin"]) element["voteoption"] = null;
element.child.forEach((el) => {
if (uin == element["uin"]) el["voteoption"] = null;
});
});
};
let reviewsPopoverState = ref(false); // 自动投票弹窗状态
let reviewsPopoverInput = ref(""); // 自动投票理由
2024-01-24 17:20:53 +08:00
// 调用自动评论
2025-04-10 17:03:51 +08:00
const reviewsComment = (value) => {
reviewsPopoverState.value = true;
};
2024-01-24 17:20:53 +08:00
2025-04-10 17:03:51 +08:00
let bottomNavigationState = false;
2024-01-24 17:20:53 +08:00
// 底部导航栏的 评论
2025-04-10 17:03:51 +08:00
const bottomNavigationBar = (value) => {
bottomNavigationState = true;
submitAnswerComments(value);
};
const floorCommentBtn = inject("floorCommentBtn");
2024-01-24 17:20:53 +08:00
2025-04-10 17:03:51 +08:00
const postInputRef = ref(null);
2024-01-24 17:20:53 +08:00
const postCommentFocusBlur = () => {
2025-04-10 17:03:51 +08:00
const refref = postInputRef.value;
2024-01-25 19:29:12 +08:00
setTimeout(() => {
2025-04-10 17:03:51 +08:00
postCommentFocusState.value = false;
2024-01-25 19:29:12 +08:00
nextTick(() => {
2025-04-10 17:03:51 +08:00
let targetDom = refref.querySelector(".el-textarea__inner");
targetDom.style.height = "41px";
});
}, 200);
};
2024-01-24 17:20:53 +08:00
2025-04-10 17:03:51 +08:00
let picture = ref({});
2025-02-13 19:05:38 +08:00
2025-04-10 17:03:51 +08:00
let emojiState = ref(false);
let emojiMaskState = ref(false);
2025-02-13 19:05:38 +08:00
2025-04-10 17:03:51 +08:00
const emojiData = ["😀", "😁", "😆", "😅", "😂", "😉", "😍", "🥰", "😋", "😜", "🤪", "😎", "🤩", "🥳", "😔", "🙁", "😭", "😡", "😳", "🤗", "🤔", "🤭", "🤫", "😯", "😵", "🙄", "🥴", "🤢", "🤑", "🤠", "👌", "✌️", "🤟", "🤘", "🤙", "👍", "👎", "✊", "👏", "🤝", "🙏", "💪", "❤️", "💔", "🌹", "🥀", "🎉", "🎁", "🧧", "🌙", "⭐", "🌍", "💌", "📬", "🚗", "🚕", "🚲", "🛵", "🚀", "🚁", "⛵", "🚢", "🍎", "🍐", "🍊", "🍉", "🍓", "🍑", "🍔", "🍟", "🍕", "🥪", "🍜", "🍡", "🍨", "🍦", "🎂", "🍰", "🍭", "🍿", "🍩", "🧃", "🍹"];
2025-02-13 19:05:38 +08:00
// 打开 Emoji
const openEmoji = (index, i) => {
2025-02-17 19:01:20 +08:00
if (isNeedLogin.value) {
2025-04-10 17:03:51 +08:00
goLogin();
return;
2025-02-17 19:01:20 +08:00
}
2025-04-10 17:03:51 +08:00
if (i != undefined) commentList.value[index].child[i]["emojiState"] = true;
else if (index != undefined) commentList.value[index]["emojiState"] = true;
2025-02-13 19:05:38 +08:00
else {
2025-04-10 17:03:51 +08:00
closeEmoji();
closeAnswerCommentsChild();
emojiState.value = true;
2025-02-13 19:05:38 +08:00
}
2025-04-10 17:03:51 +08:00
emojiMaskState.value = true;
};
2025-02-13 19:05:38 +08:00
// 关闭 Emoji
const closeEmoji = (index, i) => {
2025-04-10 17:03:51 +08:00
commentList.value.forEach((ele) => {
ele["emojiState"] = false;
2025-02-13 19:05:38 +08:00
if (ele["child"] && ele["child"].length != 0) {
2025-04-10 17:03:51 +08:00
ele["child"].forEach((el) => {
el["emojiState"] = false;
});
2025-02-13 19:05:38 +08:00
}
2025-04-10 17:03:51 +08:00
});
2025-02-13 19:05:38 +08:00
2025-04-10 17:03:51 +08:00
emojiState.value = false;
emojiMaskState.value = false;
editEmojiState.value = false;
};
2025-02-13 19:05:38 +08:00
// 选择 Emoji
const selectEmoji = (key, index, i) => {
2025-04-10 17:03:51 +08:00
closeEmoji();
2025-02-13 19:05:38 +08:00
if (i != undefined) {
2025-04-10 17:03:51 +08:00
if (!commentList.value[index]["child"][i]["commentInput"]) commentList.value[index]["child"][i]["commentInput"] = "";
commentList.value[index]["child"][i]["commentInput"] += key;
2025-02-13 19:05:38 +08:00
} else if (index != undefined) {
2025-04-10 17:03:51 +08:00
if (!commentList.value[index]["commentInput"]) commentList.value[index]["commentInput"] = "";
commentList.value[index]["commentInput"] += key;
2025-02-13 19:05:38 +08:00
} else {
2025-04-10 17:03:51 +08:00
commentInputTop.value += key;
2025-02-13 19:05:38 +08:00
}
2025-04-10 17:03:51 +08:00
};
2025-02-13 19:05:38 +08:00
// 自动输入框增高
2025-04-10 17:03:51 +08:00
const autoResize = (e) => {
e.target.style.height = "auto"; // 重置高度
e.target.style.height = `${e.target.scrollHeight}px`; // 设置为内容高度
};
2025-02-13 19:05:38 +08:00
2025-04-10 17:03:51 +08:00
const maxSize = 20 * 1024 * 1024; // 20MB
2025-02-13 19:05:38 +08:00
const handleInputPaste = (event, index, ii) => {
2025-04-10 17:03:51 +08:00
const items = event.clipboardData.items; // 获取粘贴的内容
2025-02-13 19:05:38 +08:00
for (let i = 0; i < items.length; i++) {
2025-04-10 17:03:51 +08:00
const item = items[i];
2025-02-13 19:05:38 +08:00
if (item.type.startsWith("image/")) {
2025-04-10 17:03:51 +08:00
event.preventDefault();
const file = item.getAsFile(); // 获取文件
2025-02-13 19:05:38 +08:00
if (file.size > maxSize) {
ElMessage({
message: "文件大小不能超过 20MB",
type: "error",
2025-04-10 17:03:51 +08:00
});
return;
2025-02-13 19:05:38 +08:00
}
2025-04-10 17:03:51 +08:00
const reader = new FileReader();
reader.onload = (e) => {
const base64 = e.target.result;
2025-02-13 19:05:38 +08:00
2025-04-10 17:03:51 +08:00
uploadImg(base64).then((res) => {
2025-02-13 19:05:38 +08:00
const obj = {
base64,
...res,
2025-04-10 17:03:51 +08:00
};
2025-02-17 19:01:20 +08:00
2025-04-10 17:03:51 +08:00
if (editCommentState.value) editPicture.value = obj;
2025-02-17 19:01:20 +08:00
else {
2025-04-10 17:03:51 +08:00
if (ii != undefined) commentList.value[index].child[ii]["picture"] = obj;
else if (index != undefined) commentList.value[index]["picture"] = obj;
else picture.value = obj;
2025-02-17 19:01:20 +08:00
}
2025-02-13 19:05:38 +08:00
ElMessage({
message: "上传成功",
type: "success",
2025-04-10 17:03:51 +08:00
});
});
};
reader.readAsDataURL(file);
2025-02-13 19:05:38 +08:00
}
}
2025-04-10 17:03:51 +08:00
};
2025-02-13 19:05:38 +08:00
const handleFileUpload = (event, index, i) => {
2025-04-10 17:03:51 +08:00
closeEmoji();
const file = event.target.files[0]; // 获取选择的文件
2025-02-13 19:05:38 +08:00
2025-04-10 17:03:51 +08:00
if (!file) return;
2025-02-13 19:05:38 +08:00
if (file.size > maxSize) {
ElMessage({
message: "文件大小不能超过 20MB",
type: "error",
2025-04-10 17:03:51 +08:00
});
return;
2025-02-13 19:05:38 +08:00
}
2025-04-10 17:03:51 +08:00
const reader = new FileReader();
reader.onload = (e) => {
const base64 = e.target.result;
uploadImg(base64).then((res) => {
2025-02-13 19:05:38 +08:00
const obj = {
base64,
...res,
2025-04-10 17:03:51 +08:00
};
if (editCommentState.value) editPicture.value = obj;
2025-02-17 19:01:20 +08:00
else {
2025-04-10 17:03:51 +08:00
if (i != undefined) commentList.value[index].child[i]["picture"] = obj;
else if (index != undefined) commentList.value[index]["picture"] = obj;
else picture.value = obj;
2025-02-17 19:01:20 +08:00
}
2025-02-13 19:05:38 +08:00
ElMessage({
message: "上传成功",
type: "success",
2025-04-10 17:03:51 +08:00
});
});
};
reader.readAsDataURL(file);
};
2025-02-13 19:05:38 +08:00
// 删除上传的图片
const closeFileUpload = (index, i) => {
2025-04-10 17:03:51 +08:00
if (i != undefined) commentList.value[index].child[i]["picture"] = {};
else if (index != undefined) commentList.value[index]["picture"] = {};
else picture.value = {};
};
2025-02-13 19:05:38 +08:00
// 上传图片 获取图片url
2025-04-10 17:03:51 +08:00
const uploadImg = (base64) => {
2025-02-13 19:05:38 +08:00
return new Promise((resolve, reject) => {
// detailLoading.value = true
commonUploadHttp({
data: base64,
2025-04-10 17:03:51 +08:00
}).then((res) => {
2025-02-13 19:05:38 +08:00
if (res.code != 200) {
ElMessage({
message: res.message || "上传失败",
type: "error",
2025-04-10 17:03:51 +08:00
});
return;
2025-02-13 19:05:38 +08:00
}
2025-04-10 17:03:51 +08:00
let data = res.data;
resolve(data);
});
});
};
2025-02-13 19:05:38 +08:00
2025-04-10 17:03:51 +08:00
let dialogSrc = ref(""); // 大图的src
2025-02-13 19:05:38 +08:00
// 处理点击答案图片 展开大图
2025-04-10 17:03:51 +08:00
const handleAnswerText = (e) => {
2025-02-13 19:05:38 +08:00
if (e.target.tagName === "IMG") {
2025-04-10 17:03:51 +08:00
var src = e.target.getAttribute("src");
dialogSrc.value = src;
window.addEventListener("keydown", handleKeydown);
2025-02-13 19:05:38 +08:00
}
2025-04-10 17:03:51 +08:00
};
2025-02-13 19:05:38 +08:00
// 大图的监听 esc 键盘按钮
2025-04-10 17:03:51 +08:00
const handleKeydown = (event) => {
if (event.key !== "Escape") return;
dialogSrc.value = "";
window.removeEventListener("keydown", handleKeydown); // 取消监听
};
let dialogVisible = ref(false);
let commemtDelete = {};
2025-02-13 19:05:38 +08:00
// 点击删除
const commentDelete = (token, index, i) => {
2025-02-18 19:05:50 +08:00
commemtDelete = {
2025-02-13 19:05:38 +08:00
token,
2025-02-18 19:05:50 +08:00
index,
i,
2025-04-10 17:03:51 +08:00
};
dialogVisible.value = true;
};
2025-02-18 19:05:50 +08:00
const confirmCommentDelete = () => {
commentDeleteHttp({
token: commemtDelete.token,
2025-04-10 17:03:51 +08:00
}).then((res) => {
2025-02-13 19:05:38 +08:00
if (res.code != 200) {
2025-04-10 17:03:51 +08:00
ElMessage.error(res.message);
return;
2025-02-13 19:05:38 +08:00
}
2025-02-18 19:05:50 +08:00
if (commemtDelete.i >= 0) {
2025-04-10 17:03:51 +08:00
commentList.value[commemtDelete.index].child.splice(commemtDelete.i, 1);
commentList.value[commemtDelete.index].childnum -= 1;
2025-02-13 19:05:38 +08:00
} else {
2025-04-10 17:03:51 +08:00
commentComments.value -= commentList.value[commemtDelete.index].childnum;
commentList.value.splice(commemtDelete.index, 1);
2025-02-13 19:05:38 +08:00
}
2025-04-10 17:03:51 +08:00
commentComments.value -= 1;
dialogVisible.value = false;
2025-02-18 19:05:50 +08:00
2025-04-10 17:03:51 +08:00
ElMessage.success(res.message || "操作成功");
});
};
2025-02-13 19:05:38 +08:00
2025-02-17 19:01:20 +08:00
const judgeLogin = () => {
2025-04-10 17:03:51 +08:00
if (isNeedLogin.value) goLogin();
};
2025-02-17 19:01:20 +08:00
2025-04-10 17:03:51 +08:00
let editCommentState = ref(false);
let editToken = "";
let editPicture = ref({});
let editInput = ref("");
let editEmojiState = ref(false);
const editInputRef = ref(null);
2025-02-17 19:01:20 +08:00
const openEdit = (token, index, i) => {
2025-04-10 17:03:51 +08:00
const list = JSON.parse(JSON.stringify(commentList.value));
let target = {};
if (i != null) target = list[index]["child"][i];
else target = list[index];
2025-02-20 14:19:15 +08:00
// console.log(token, index, i, target)
2025-04-10 17:03:51 +08:00
editToken = target.token || "";
editInput.value = target.content || "";
editPicture.value = target.image || {};
2025-02-17 19:01:20 +08:00
2025-04-10 17:03:51 +08:00
editCommentState.value = true;
2025-02-17 19:01:20 +08:00
nextTick(() => {
2025-02-20 14:19:15 +08:00
// console.log("editInput.value", editInputRef.value)
2025-04-10 17:03:51 +08:00
editInputRef.value.style.height = `${editInputRef.value.scrollHeight}px`;
});
};
2025-02-17 19:01:20 +08:00
const closeEdit = () => {
2025-04-10 17:03:51 +08:00
editPicture.value = {};
editToken = "";
editInput.value = "";
editCommentState.value = false;
};
2025-02-17 19:01:20 +08:00
// 打开 Emoji
const openEditEmoji = (index, i) => {
if (isNeedLogin.value) {
2025-04-10 17:03:51 +08:00
goLogin();
return;
2025-02-17 19:01:20 +08:00
}
2025-04-10 17:03:51 +08:00
editEmojiState.value = true;
};
2025-02-17 19:01:20 +08:00
2025-04-10 17:03:51 +08:00
const selectEditEmoji = (key) => {
closeEmoji();
editInput.value += key;
};
2025-02-17 19:01:20 +08:00
const postEditComment = () => {
if (isNeedLogin.value) {
2025-04-10 17:03:51 +08:00
goLogin();
return;
2025-02-17 19:01:20 +08:00
}
2025-04-10 17:03:51 +08:00
const image = editPicture.value;
2025-02-17 19:01:20 +08:00
commentsEditSubmit({
content: editInput.value,
token: editToken,
image: image ? { aid: image.aid, url: image.url } : null,
2025-04-10 17:03:51 +08:00
}).then((res) => {
2025-02-17 19:01:20 +08:00
if (res.code != 200) {
2025-04-10 17:03:51 +08:00
ElMessage.error(res.message);
return;
2025-02-17 19:01:20 +08:00
}
2025-04-10 17:03:51 +08:00
commentList.value.forEach((element) => {
2025-02-17 19:01:20 +08:00
if (element.token == editToken) {
2025-04-10 17:03:51 +08:00
element["content"] = editInput.value;
element["image"] = image;
2025-02-17 19:01:20 +08:00
}
element.child &&
2025-04-10 17:03:51 +08:00
element.child.forEach((ele) => {
2025-02-17 19:01:20 +08:00
if (ele.token == editToken) {
2025-04-10 17:03:51 +08:00
ele["content"] = editInput.value;
ele["image"] = image;
2025-02-17 19:01:20 +08:00
}
2025-04-10 17:03:51 +08:00
});
});
2025-02-17 19:01:20 +08:00
2025-04-10 17:03:51 +08:00
editPicture.value = {};
editToken = "";
editCommentState.value = false;
editEmojiState.value = false;
ElMessage.success(res.message);
});
};
2025-02-17 19:01:20 +08:00
2025-04-10 17:03:51 +08:00
const closeEditFileUpload = () => (editPicture.value = {});
2025-02-17 19:01:20 +08:00
2025-04-10 17:03:51 +08:00
defineExpose({ changeCommentVoteoption, wipeCommentVoteoption, reviewsComment, bottomNavigationBar, closeAnswerCommentsChild });
2024-01-12 19:12:30 +08:00
</script>
<style scoped lang="less">
2025-02-10 19:04:24 +08:00
@import url(@/assets/css/DetailsComments.css);
2024-01-12 19:12:30 +08:00
</style>
2025-02-10 19:04:24 +08:00
2024-01-26 11:09:20 +08:00
<style lang="less">
2024-01-24 17:20:53 +08:00
.automatic-reviews-popup {
2024-01-29 15:18:58 +08:00
border-radius: 10px !important;
2025-04-10 17:03:51 +08:00
padding: 0 !important;
2024-01-24 17:20:53 +08:00
.automatic-header {
padding: 20px;
border-bottom: 1px dotted #ebebeb;
.automatic-title {
font-weight: 650;
font-size: 18px;
color: #000000;
margin-bottom: 12px;
}
.automatic-have {
background-color: rgba(246, 246, 246, 1);
font-size: 12px;
color: #aaa;
width: fit-content;
}
}
.automatic-input {
.el-textarea__inner {
min-height: 256px !important;
box-shadow: none;
padding: 20px;
resize: none;
}
2024-01-29 15:18:58 +08:00
.el-input__count {
left: 10px;
bottom: -40px;
width: fit-content;
}
2024-01-24 17:20:53 +08:00
}
.automatic-bottom {
justify-content: flex-end;
padding: 0 10px 10px;
.automatic-send {
background-color: var(--main-color);
color: #fff;
font-size: 16px;
width: 100px;
height: 40px;
border-radius: 6px;
cursor: pointer;
}
}
}
</style>