|
@@ -1,5 +1,5 @@
|
|
<script setup>
|
|
<script setup>
|
|
-import { ref, onMounted } from 'vue';
|
|
|
|
|
|
+import { ref, onMounted, watch } from 'vue';
|
|
import { ElMessage,ElMessageBox } from 'element-plus'
|
|
import { ElMessage,ElMessageBox } from 'element-plus'
|
|
import {ArrowUp} from "@element-plus/icons-vue";
|
|
import {ArrowUp} from "@element-plus/icons-vue";
|
|
import * as $api from '@/api/question'
|
|
import * as $api from '@/api/question'
|
|
@@ -8,8 +8,16 @@ const props = defineProps({
|
|
item: Object
|
|
item: Object
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+
|
|
const dataInfo = ref({...props.item,commentInfo: {}});
|
|
const dataInfo = ref({...props.item,commentInfo: {}});
|
|
|
|
|
|
|
|
+watch(
|
|
|
|
+ ()=>props.item,
|
|
|
|
+ (newval)=>{
|
|
|
|
+ console.log(newval)
|
|
|
|
+ dataInfo.value=props.item
|
|
|
|
+ }
|
|
|
|
+)
|
|
|
|
|
|
/* 点赞/吐槽 */
|
|
/* 点赞/吐槽 */
|
|
const setLikeHandle = async(type) => {
|
|
const setLikeHandle = async(type) => {
|
|
@@ -32,12 +40,8 @@ const setLikeHandle = async(type) => {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-// 展开收起评论
|
|
|
|
|
|
+// 展开评论
|
|
const openCommentHandle = () => {
|
|
const openCommentHandle = () => {
|
|
- if(dataInfo.value.commentInfo.show) {
|
|
|
|
- closeComment()
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
dataInfo.value.commentInfo = {
|
|
dataInfo.value.commentInfo = {
|
|
show: true,
|
|
show: true,
|
|
commentList: [],
|
|
commentList: [],
|
|
@@ -46,6 +50,7 @@ const openCommentHandle = () => {
|
|
}
|
|
}
|
|
getComment(1)
|
|
getComment(1)
|
|
}
|
|
}
|
|
|
|
+const comment_total = ref({});//评论数量
|
|
/* 获取评论 */
|
|
/* 获取评论 */
|
|
const getComment = async(type) => {
|
|
const getComment = async(type) => {
|
|
dataInfo.value.commentInfo.default_type = type;
|
|
dataInfo.value.commentInfo.default_type = type;
|
|
@@ -60,6 +65,10 @@ const getComment = async(type) => {
|
|
|
|
|
|
if(code !== 200) return
|
|
if(code !== 200) return
|
|
dataInfo.value.commentInfo.commentList = data.list || [];
|
|
dataInfo.value.commentInfo.commentList = data.list || [];
|
|
|
|
+ comment_total.value = {
|
|
|
|
+ hot_num: data.hot_total,
|
|
|
|
+ my_num: data.my_total
|
|
|
|
+ }
|
|
}
|
|
}
|
|
/* 收起评论 */
|
|
/* 收起评论 */
|
|
const closeComment = () => {
|
|
const closeComment = () => {
|
|
@@ -149,9 +158,14 @@ const delCommentHandle = ({community_question_comment_id},index) => {
|
|
<img src="@/assets/question/tease.png" alt="" v-else class="icon">
|
|
<img src="@/assets/question/tease.png" alt="" v-else class="icon">
|
|
<text v-if="dataInfo.tease_total">{{dataInfo.tease_total}}</text>
|
|
<text v-if="dataInfo.tease_total">{{dataInfo.tease_total}}</text>
|
|
</view>
|
|
</view>
|
|
- <view class="commetn-item-wrap" @click="openCommentHandle">
|
|
|
|
- <img src="@/assets/question/comment.png" alt="" class="icon">
|
|
|
|
- <text v-if="dataInfo.comment_total">{{dataInfo.comment_total}}</text>
|
|
|
|
|
|
+ <view class="commetn-item-wrap" >
|
|
|
|
+ <span
|
|
|
|
+ @click="closeComment"
|
|
|
|
+ v-if="dataInfo.commentInfo &&dataInfo.commentInfo.show"
|
|
|
|
+ style="cursor:pointer;color:#F3A52F"
|
|
|
|
+ >收起评论 <el-icon><ArrowUp /></el-icon></span>
|
|
|
|
+ <img src="@/assets/question/comment.png" alt="" class="icon" v-else @click="openCommentHandle">
|
|
|
|
+ <!-- <text v-if="dataInfo.comment_total">{{dataInfo.comment_total}}</text> -->
|
|
</view>
|
|
</view>
|
|
<view class="commetn-item-wrap" @click="setLikeHandle(1)">
|
|
<view class="commetn-item-wrap" @click="setLikeHandle(1)">
|
|
<img src="@/assets/question/like_act.png" alt="" v-if="dataInfo.op_type===1" class="icon">
|
|
<img src="@/assets/question/like_act.png" alt="" v-if="dataInfo.op_type===1" class="icon">
|
|
@@ -179,8 +193,8 @@ const delCommentHandle = ({community_question_comment_id},index) => {
|
|
|
|
|
|
<div class="list-cont">
|
|
<div class="list-cont">
|
|
<ul class="list-tab">
|
|
<ul class="list-tab">
|
|
- <li :class="dataInfo.commentInfo.default_type===1 && 'act'" @click="getComment(1)">精选评论</li>
|
|
|
|
- <li :class="dataInfo.commentInfo.default_type===2 && 'act'" @click="getComment(2)">我的评论</li>
|
|
|
|
|
|
+ <li :class="dataInfo.commentInfo.default_type===1 && 'act'" @click="getComment(1)">精选评论({{comment_total.hot_num}})</li>
|
|
|
|
+ <li :class="dataInfo.commentInfo.default_type===2 && 'act'" @click="getComment(2)">我的评论({{comment_total.my_num}})</li>
|
|
</ul>
|
|
</ul>
|
|
<ul class="list-ul" v-if="dataInfo.commentInfo.commentList.length">
|
|
<ul class="list-ul" v-if="dataInfo.commentInfo.commentList.length">
|
|
<li class="list-item" v-for="(item,index) in dataInfo.commentInfo.commentList" :key="item.community_question_comment_id">
|
|
<li class="list-item" v-for="(item,index) in dataInfo.commentInfo.commentList" :key="item.community_question_comment_id">
|
|
@@ -193,18 +207,13 @@ const delCommentHandle = ({community_question_comment_id},index) => {
|
|
</ul>
|
|
</ul>
|
|
<div class="nodata" v-else>暂无评论</div>
|
|
<div class="nodata" v-else>暂无评论</div>
|
|
</div>
|
|
</div>
|
|
- <div class="slide-up" @click="closeComment">
|
|
|
|
|
|
+ <!-- <div class="slide-up" @click="closeComment">
|
|
收起评论 <el-icon><ArrowUp /></el-icon>
|
|
收起评论 <el-icon><ArrowUp /></el-icon>
|
|
- </div>
|
|
|
|
|
|
+ </div> -->
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<style lang='scss' scoped>
|
|
<style lang='scss' scoped>
|
|
-.btn-sty {
|
|
|
|
- width: 140px;
|
|
|
|
- height: 40px;
|
|
|
|
- line-height: 40px;
|
|
|
|
-}
|
|
|
|
.question-comment-wrapper {
|
|
.question-comment-wrapper {
|
|
color: #999;
|
|
color: #999;
|
|
display: flex;
|
|
display: flex;
|
|
@@ -240,6 +249,11 @@ const delCommentHandle = ({community_question_comment_id},index) => {
|
|
display: flex;
|
|
display: flex;
|
|
align-items: center;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
justify-content: space-between;
|
|
|
|
+ .btn-sty {
|
|
|
|
+ width: 140px;
|
|
|
|
+ height: 40px !important;
|
|
|
|
+ line-height: 40px !important;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
.list-cont {
|
|
.list-cont {
|
|
border-top: 1px solid #F2F2F2;
|
|
border-top: 1px solid #F2F2F2;
|