Files
dvcp_v2_wechat_app/src/components/AiComment/AiComment.vue

179 lines
4.1 KiB
Vue
Raw Normal View History

2022-02-14 17:25:54 +08:00
<template>
<div class="AiComment">
2022-05-25 17:04:52 +08:00
<div class="pageTitle flex">
评论
<div class="mar-l16" v-text="total"/>
2022-02-14 17:25:54 +08:00
</div>
2022-05-25 17:04:52 +08:00
<div class="flex item" v-for="row in list" :key="row.id">
<img :src="row.avatar"/>
<div class="fill">
<div class="flex font-32">
<div class="fill font600 font-28" v-text="row.name"/>
<AiThumbsUp :bid="row.id" type="comment" :count.sync="row.hotCount"/>
</div>
<div class="font-32 mar-t8 mar-b24" v-text="row.content"/>
<div class="flex mar-b24">
<div class="color-999" v-text="[row.areaName,row.commentTime].join(' ')"/>
<comment-editor class="mar-l16" :bid="row.id" type="2">回复TA</comment-editor>
</div>
<div v-if="getArrayLength(row.replyList)>0" class="replyList">
<div v-if="row.showAllReply">
<div class="flex color-666 mar-t8" v-for="reply in row.replyList" :key="reply.id">
<div class="font600" v-text="reply.name+''"/>
<div v-text="reply.content"/>
</div>
<div v-if="getArrayLength(row.replyList)>2" class="color-687DA6 mar-t8" v-text="`收起`" @click="handleExpand(row)"/>
</div>
<div v-else>
<div class="flex color-666 mar-t8" v-for="reply in getReplies(row.replyList)" :key="reply.id">
<div class="font600" v-text="reply.name+''"/>
<div v-text="reply.content"/>
</div>
<div v-if="getArrayLength(row.replyList)>2" class="color-687DA6 mar-t8" v-text="`查看全部${getArrayLength(row.replyList)}条回复 >`"
@click="handleExpand(row)"/>
</div>
</div>
</div>
2022-02-14 17:25:54 +08:00
</div>
2022-05-25 17:04:52 +08:00
<comment-editor class="fixedBottom" :bid="bid" :comment-count="total"/>
<u-gap height="128"/>
2022-02-14 17:25:54 +08:00
</div>
</template>
<script>
2022-05-25 17:04:52 +08:00
import CommentEditor from "./commentEditor";
import AiThumbsUp from "../AiThumbsUp/AiThumbsUp";
2022-02-14 17:25:54 +08:00
export default {
name: "AiComment",
2022-05-25 17:04:52 +08:00
components: {AiThumbsUp, CommentEditor},
2022-02-14 17:25:54 +08:00
props: {
2022-05-25 17:04:52 +08:00
bid: {default: ""}
2022-02-14 17:25:54 +08:00
},
data() {
return {
2022-05-25 17:04:52 +08:00
list: [],
current: 1,
total: 0
2022-02-14 17:25:54 +08:00
}
},
methods: {
2022-05-25 17:04:52 +08:00
getComments() {
let {current, total, bid: contentId} = this
if (!total || this.list.length < total) {
this.$instance.post("/app/appcontentcomment/list", null, {
params: {current, contentId}
}).then(res => {
if (res?.data) {
res.data.records.map(e => e.showAllReply = false)
this.list = [current == 1 ? [] : this.list, res.data.records].flat()
this.total = res.data.total
}
})
2022-02-14 17:25:54 +08:00
}
},
2022-05-25 17:04:52 +08:00
getReplies(list, showAll) {
return list?.slice(0, showAll ? this.getArrayLength(list) : 2) || []
2022-02-14 17:25:54 +08:00
},
2022-05-25 17:04:52 +08:00
getArrayLength(list) {
return list?.length || 0
2022-02-14 17:25:54 +08:00
},
2022-05-25 17:04:52 +08:00
handleExpand(row) {
console.log(row)
row.showAllReply = !row.showAllReply
2022-02-14 17:25:54 +08:00
}
2022-05-25 17:04:52 +08:00
},
created() {
this.getComments()
uni.$on("moreComments", flag => {
flag ? this.current = 1 : this.current++
this.getComments()
})
},
destroyed() {
uni.$off("moreComments")
2022-02-14 17:25:54 +08:00
}
}
</script>
<style lang="scss" scoped>
.AiComment {
2022-05-25 17:04:52 +08:00
background: #fff;
.item {
2022-02-14 17:25:54 +08:00
padding: 24px 32px;
2022-05-25 17:04:52 +08:00
align-items: flex-start;
color: #333;
font-size: 26px;
2022-02-14 17:25:54 +08:00
2022-05-25 17:04:52 +08:00
& > img {
2022-02-14 17:25:54 +08:00
height: 64px;
2022-05-25 17:04:52 +08:00
width: 64px;
border-radius: 50%;
margin-right: 16px;
2022-02-14 17:25:54 +08:00
}
2022-05-25 17:04:52 +08:00
.content {
margin: 8px 0 24px;
2022-02-14 17:25:54 +08:00
}
2022-05-25 17:04:52 +08:00
}
2022-02-14 17:25:54 +08:00
2022-05-25 17:04:52 +08:00
.font600 {
font-weight: 600;
2022-02-14 17:25:54 +08:00
}
2022-05-25 17:04:52 +08:00
.font-32 {
font-size: 32px;
2022-02-14 17:25:54 +08:00
}
2022-05-25 17:04:52 +08:00
.font-28 {
font-size: 28px;
}
2022-02-14 17:25:54 +08:00
2022-05-25 17:04:52 +08:00
.mar-t8 {
margin-top: 8px;
}
.mar-b24 {
margin-bottom: 24px;
}
.mar-r16 {
margin-right: 16px;
}
.mar-l16 {
margin-left: 16px;
}
.color-999 {
color: #999;
}
.color-666 {
color: #666;
}
.color-687DA6 {
color: #687DA6;
}
.replyList {
padding: 8px 16px 16px;
background: #F4F5FA;
border-radius: 8px;
font-size: 28px;
2022-02-14 17:25:54 +08:00
}
2022-05-25 17:04:52 +08:00
.pageTitle {
height: 100px;
padding: 0 32px;
font-size: 34px;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #333333;
2022-02-14 17:25:54 +08:00
}
}
</style>