2024-01-12 19:12:30 +08:00
|
|
|
|
<template>
|
2024-07-17 12:25:33 +08:00
|
|
|
|
<div class="comment-box">
|
|
|
|
|
<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> -->
|
|
|
|
|
|
|
|
|
|
<div class="input-box" v-if="false">
|
|
|
|
|
<div class="top flexflex">
|
|
|
|
|
<img class="avatar" v-if="user.avatar" :src="user.avatar" />
|
|
|
|
|
<textarea class="input-textarea flex1" maxlength="500" v-model="commentInputTop" @input="autoResize" @paste="handleInputPaste" placeholder="说说你的想法或疑问…"></textarea>
|
|
|
|
|
</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">
|
|
|
|
|
<div class="item" :class="{ 'pitch': emojiState }">
|
|
|
|
|
<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>
|
|
|
|
|
<div class="item flexacenter">
|
|
|
|
|
<input class="file" type="file" @change="handleFileUpload($event)" accept=".png, .jpg, .jpeg" />
|
|
|
|
|
<img class="icon" style="border-radius: 0;" src="@/assets/img/picture-icon.png" alt="" />
|
|
|
|
|
<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>
|
|
|
|
|
<img class="comments-title" v-if="item['groupid'] === 14" src="@/assets/img/title.png" />
|
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" />
|
|
|
|
|
<div class="report-box flexcenter" @click="report(item['token'])">举报</div>
|
|
|
|
|
</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 -->
|
|
|
|
|
<div class="comment-text" @click="!item['childState'] ? openAnswerCommentsChild(index) : closeAnswerCommentsChild()">{{ item["content"] }}</div>
|
|
|
|
|
<div class="alreadyVoted" v-if="item.voteoption">已投:{{ item.voteoption }}</div>
|
|
|
|
|
<div class="comments-input-masking" @click="closeAnswerCommentsChild()" v-if="item['childState']"></div>
|
|
|
|
|
<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>
|
2024-01-12 19:12:30 +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>
|
|
|
|
|
<img class="comments-title" v-if="ite['groupid'] == 14" src="@/assets/img/title.png" />
|
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" />
|
|
|
|
|
<div class="report-box flexcenter" @click="report(ite['token'])">举报</div>
|
|
|
|
|
</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>
|
2024-07-17 12:25:33 +08:00
|
|
|
|
<div class="comment-text" @click="!ite['childState'] ? openAnswerCommentsChild(index, i) : closeAnswerCommentsChild()">
|
|
|
|
|
<div class="comments-reply" v-if="ite?.reply?.nickname">@{{ ite?.reply?.nickname }}</div>
|
|
|
|
|
{{ ite["content"] }}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="alreadyVoted" v-if="ite.voteoption">已投:{{ ite.voteoption }}</div>
|
|
|
|
|
<div class="comments-input-masking" @click="closeAnswerCommentsChild()" v-if="ite['childState']"></div>
|
|
|
|
|
<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>
|
|
|
|
|
</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>
|
2024-01-12 19:12:30 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { ElMessage } from "element-plus"
|
2024-01-18 17:25:40 +08:00
|
|
|
|
import { isEmpty } from "element-plus/es/utils"
|
|
|
|
|
|
2024-01-24 17:20:53 +08:00
|
|
|
|
let haveVotedValue = inject("haveVotedValue")
|
|
|
|
|
|
2024-01-12 19:12:30 +08:00
|
|
|
|
let isNeedLogin = inject("isNeedLogin")
|
|
|
|
|
const goLogin = inject("goLogin")
|
2024-01-18 17:25:40 +08:00
|
|
|
|
|
|
|
|
|
const props = defineProps({ token: String })
|
2025-02-10 19:04:24 +08:00
|
|
|
|
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 }
|
2024-01-12 19:12:30 +08:00
|
|
|
|
)
|
2024-01-15 19:02:10 +08:00
|
|
|
|
|
|
|
|
|
onMounted(() => window.addEventListener("scroll", handleScroll))
|
2024-01-12 19:12:30 +08:00
|
|
|
|
|
2025-02-10 19:04:24 +08:00
|
|
|
|
onMounted(() => {
|
|
|
|
|
setInterval(() => {
|
|
|
|
|
console.log("userInfoWin", userInfoWin.value)
|
|
|
|
|
}, 2000)
|
|
|
|
|
})
|
|
|
|
|
|
2024-01-12 19:12:30 +08:00
|
|
|
|
const sendMessage = inject("sendMessage")
|
|
|
|
|
const TAHomePage = inject("TAHomePage")
|
|
|
|
|
|
2024-01-23 19:10:57 +08:00
|
|
|
|
let postCommentFocusState = ref(false)
|
|
|
|
|
|
2024-01-12 19:12:30 +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-07-17 12:25:33 +08:00
|
|
|
|
const emit = defineEmits(["update:commentComments"])
|
|
|
|
|
|
2024-01-12 19:12:30 +08:00
|
|
|
|
// 获取详情评论数据
|
|
|
|
|
const getCommentList = () => {
|
2024-01-24 17:20:53 +08:00
|
|
|
|
if (commentPage.value == 0 || commentLoading || !props.token) return
|
2024-01-12 19:12:30 +08:00
|
|
|
|
commentLoading = true
|
|
|
|
|
|
|
|
|
|
commentListHttp({
|
|
|
|
|
page: commentPage.value,
|
|
|
|
|
childlimit: 1,
|
|
|
|
|
limit: 10,
|
|
|
|
|
token: props.token,
|
|
|
|
|
})
|
|
|
|
|
.then(res => {
|
|
|
|
|
if (res.code != 200) return
|
|
|
|
|
|
|
|
|
|
let data = res.data
|
|
|
|
|
commentCount.value = data["count"]
|
|
|
|
|
if (data["count"] == 0) isEmptyState.value = true
|
|
|
|
|
else isEmptyState.value = false
|
|
|
|
|
|
|
|
|
|
commentList.value = commentList.value.concat(data["data"])
|
|
|
|
|
|
|
|
|
|
commentComments.value = data["comments"]
|
|
|
|
|
|
2024-07-17 12:25:33 +08:00
|
|
|
|
emit("update:commentComments", data["comments"])
|
|
|
|
|
|
2024-01-12 19:12:30 +08:00
|
|
|
|
if (commentList.value.length == data["count"]) commentPage.value = 0
|
|
|
|
|
else commentPage.value++
|
|
|
|
|
})
|
|
|
|
|
.finally(() => (commentLoading = false))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 评论点赞
|
|
|
|
|
const commentLike = (index, i) => {
|
2024-01-18 17:25:40 +08:00
|
|
|
|
if (isNeedLogin.value) {
|
|
|
|
|
goLogin()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-12 19:12:30 +08:00
|
|
|
|
const targetCommentList = [...commentList.value]
|
|
|
|
|
|
|
|
|
|
let token = ""
|
|
|
|
|
if (i != null) token = targetCommentList[index]["child"][i].token
|
|
|
|
|
else token = targetCommentList[index].token
|
|
|
|
|
|
|
|
|
|
detailsLikeCommentHttp({ token }).then(res => {
|
|
|
|
|
if (res.code != 200) return
|
|
|
|
|
let data = res.data
|
|
|
|
|
|
|
|
|
|
if (i != null) {
|
|
|
|
|
targetCommentList[index]["child"][i].islike = data["status"]
|
|
|
|
|
targetCommentList[index]["child"][i].likenum = data["likenum"]
|
|
|
|
|
} else {
|
|
|
|
|
targetCommentList[index].islike = data["status"]
|
|
|
|
|
targetCommentList[index].likenum = data["likenum"]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ElMessage.success(res.message)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 打开 回答-评论 的子评论
|
|
|
|
|
const openAnswerCommentsChild = (index, i) => {
|
2024-01-18 17:25:40 +08:00
|
|
|
|
if (isNeedLogin.value) {
|
|
|
|
|
goLogin()
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-01-29 15:18:58 +08:00
|
|
|
|
closeAnswerCommentsChild()
|
2024-01-23 19:10:57 +08:00
|
|
|
|
|
2024-01-12 19:12:30 +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 = () => {
|
2024-01-12 19:12:30 +08:00
|
|
|
|
commentList.value.forEach(ele => {
|
|
|
|
|
ele["childState"] = false
|
|
|
|
|
if (ele["child"] && ele["child"].length != 0) ele["child"].forEach(el => (el["childState"] = false))
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 讨论的输入框
|
|
|
|
|
let commentInputTop = ref("")
|
|
|
|
|
let commentInput = ref("")
|
|
|
|
|
|
|
|
|
|
// 提交回答-评论
|
2024-01-24 17:20:53 +08:00
|
|
|
|
const submitAnswerComments = (content, index, i) => {
|
2024-01-12 19:12:30 +08:00
|
|
|
|
if (isNeedLogin.value) {
|
|
|
|
|
goLogin()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const targetCommentList = [...commentList.value]
|
2024-01-24 17:20:53 +08:00
|
|
|
|
// let content = ""
|
2024-01-12 19:12:30 +08:00
|
|
|
|
let parentid = null
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
if (i != null) parentid = targetCommentList[index]["child"][i]["id"]
|
|
|
|
|
else if (index != null) parentid = targetCommentList[index]["id"]
|
|
|
|
|
|
2024-01-23 19:10:57 +08:00
|
|
|
|
if (!content) {
|
|
|
|
|
ElMessage.error("请填写评论内容")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
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,
|
|
|
|
|
}).then(res => {
|
|
|
|
|
if (res.code != 200) {
|
|
|
|
|
ElMessage.error(res.message)
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-01-24 17:20:53 +08:00
|
|
|
|
|
2024-01-12 19:12:30 +08:00
|
|
|
|
let data = res.data
|
|
|
|
|
|
|
|
|
|
if (i != null) {
|
2024-01-29 11:53:50 +08:00
|
|
|
|
console.log("data", data)
|
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,
|
2024-01-12 19:12:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
targetCommentList[index]["child"].unshift(targetData)
|
|
|
|
|
targetCommentList[index]["childnum"]++
|
|
|
|
|
} 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,
|
2024-01-12 19:12:30 +08:00
|
|
|
|
}
|
|
|
|
|
if (index != null) {
|
|
|
|
|
targetCommentList[index]["child"].unshift(targetData)
|
|
|
|
|
targetCommentList[index]["childnum"]++
|
|
|
|
|
} else {
|
|
|
|
|
targetCommentList.unshift(targetData)
|
|
|
|
|
commentCount.value++
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-01-15 19:02:10 +08:00
|
|
|
|
|
2024-01-12 19:12:30 +08:00
|
|
|
|
commentComments.value++
|
|
|
|
|
commentList.value = targetCommentList
|
|
|
|
|
|
|
|
|
|
// 请求 输入框的数据
|
|
|
|
|
commentInputTop.value = ""
|
|
|
|
|
commentInput.value = ""
|
2024-01-24 17:20:53 +08:00
|
|
|
|
reviewsPopoverInput.value = ""
|
|
|
|
|
reviewsPopoverState.value = false
|
2024-01-12 19:12:30 +08:00
|
|
|
|
isEmptyState.value = false // 取消有可能的 没有评论
|
|
|
|
|
|
|
|
|
|
closeAnswerCommentsChild()
|
|
|
|
|
|
2024-01-24 17:20:53 +08:00
|
|
|
|
if (bottomNavigationState) {
|
|
|
|
|
bottomNavigationState = false
|
|
|
|
|
floorCommentBtn("back")
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-12 19:12:30 +08:00
|
|
|
|
ElMessage.success(res.message)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取剩下的子评论
|
|
|
|
|
const alsoCommentsData = (index, ind) => {
|
2024-01-18 17:25:40 +08:00
|
|
|
|
if (isNeedLogin.value) {
|
|
|
|
|
goLogin()
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-01-12 19:12:30 +08:00
|
|
|
|
let targetCommentItem = { ...commentList.value[index] }
|
|
|
|
|
const token = targetCommentItem["token"]
|
|
|
|
|
const parentid = targetCommentItem["id"]
|
|
|
|
|
let page = targetCommentItem["childPage"] ?? 1
|
|
|
|
|
|
|
|
|
|
detailsChildCommentListHttp({
|
|
|
|
|
childlimit: 1,
|
|
|
|
|
limit: 10,
|
|
|
|
|
page,
|
|
|
|
|
parentid,
|
2024-01-15 19:02:10 +08:00
|
|
|
|
token: props.token,
|
2024-01-12 19:12:30 +08:00
|
|
|
|
}).then(res => {
|
|
|
|
|
if (res.code != 200) return
|
|
|
|
|
let data = res.data
|
|
|
|
|
let childData = targetCommentItem.child.concat(data.data)
|
|
|
|
|
|
|
|
|
|
const filteredData = childData.filter((obj, index, self) => {
|
|
|
|
|
// 检查当前对象在数组中的第一个索引是否与当前索引相等
|
|
|
|
|
return self.findIndex(item => item.id == obj.id) == index
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
targetCommentItem.child = filteredData
|
|
|
|
|
targetCommentItem["childnum"] = data.count
|
|
|
|
|
|
|
|
|
|
if (targetCommentItem.child.length == data["count"]) page = 0
|
|
|
|
|
else page++
|
|
|
|
|
|
|
|
|
|
targetCommentItem["childPage"] = page
|
|
|
|
|
|
|
|
|
|
commentList.value[index] = targetCommentItem
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let reportAlertShow = ref(false)
|
|
|
|
|
let reportToken = ref("")
|
|
|
|
|
|
|
|
|
|
// 点击打开举报
|
|
|
|
|
const report = token => {
|
|
|
|
|
if (isNeedLogin.value) {
|
|
|
|
|
goLogin()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reportToken.value = token
|
|
|
|
|
reportAlertShow.value = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 打开评论的 信息框
|
|
|
|
|
const openAvatarPopover = (index, i) => {
|
2024-01-18 17:25:40 +08:00
|
|
|
|
if (isNeedLogin.value) {
|
|
|
|
|
goLogin()
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-01-12 19:12:30 +08:00
|
|
|
|
if (i != null) commentList.value[index]["child"][i]["popoverState"] = true
|
|
|
|
|
else commentList.value[index]["popoverState"] = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 监听滚动到底部
|
|
|
|
|
const handleScroll = () => {
|
|
|
|
|
// return
|
|
|
|
|
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop
|
|
|
|
|
|
|
|
|
|
const scrollHeight = document.documentElement.scrollHeight
|
|
|
|
|
const clientHeight = document.documentElement.clientHeight
|
|
|
|
|
// 列表下 滑动到底部 获取新数据
|
|
|
|
|
if (scrollTop + clientHeight >= scrollHeight - 40) getCommentList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
provide("reportAlertShow", reportAlertShow)
|
2024-01-18 17:25:40 +08:00
|
|
|
|
|
|
|
|
|
// 登录判断
|
|
|
|
|
const loginJudgment = () => {
|
|
|
|
|
if (isNeedLogin.value) goLogin()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 修改投票的值
|
|
|
|
|
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
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 修改投票的值
|
|
|
|
|
const wipeCommentVoteoption = () => {
|
|
|
|
|
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
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-24 17:20:53 +08:00
|
|
|
|
let reviewsPopoverState = ref(false) // 自动投票弹窗状态
|
|
|
|
|
let reviewsPopoverInput = ref("") // 自动投票理由
|
|
|
|
|
|
|
|
|
|
// 调用自动评论
|
|
|
|
|
const reviewsComment = value => {
|
|
|
|
|
reviewsPopoverState.value = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let bottomNavigationState = false
|
|
|
|
|
|
|
|
|
|
// 底部导航栏的 评论
|
|
|
|
|
const bottomNavigationBar = value => {
|
|
|
|
|
bottomNavigationState = true
|
|
|
|
|
submitAnswerComments(value)
|
|
|
|
|
}
|
|
|
|
|
const floorCommentBtn = inject("floorCommentBtn")
|
|
|
|
|
|
|
|
|
|
const postInputRef = ref(null)
|
|
|
|
|
const postCommentFocusBlur = () => {
|
|
|
|
|
const refref = postInputRef.value
|
2024-01-25 19:29:12 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
postCommentFocusState.value = false
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
let targetDom = refref.querySelector(".el-textarea__inner")
|
2024-01-29 11:53:50 +08:00
|
|
|
|
targetDom.style.height = "41px"
|
2024-01-25 19:29:12 +08:00
|
|
|
|
})
|
|
|
|
|
}, 200)
|
2024-01-24 17:20:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-31 14:54:10 +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;
|
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>
|