fix:修改点赞

feature/comment-0620-ch
ch 2 years ago
parent 5c62b79812
commit 8f0bc44425

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-06-20 11:38:48
* @LastEditors: ch
* @LastEditTime: 2022-06-22 20:53:16
* @LastEditTime: 2022-06-24 11:15:09
* @Description: file content
*/
@ -48,3 +48,11 @@ export const ApiPostComment = (data) =>
ToAsyncAwait(MsbRequestTk.post(`${BASE_URL}/app/comment`, data));
/**
* 更新评论有用数
* @param {*} param0
*/
export const ApiPutCommentUseful = (data) =>
ToAsyncAwait(MsbRequestTk.put(`${BASE_URL}/app/comment/updateUsefulCount`,data));

@ -2,14 +2,15 @@
* @Author: ch
* @Date: 2022-06-21 16:01:19
* @LastEditors: ch
* @LastEditTime: 2022-06-22 16:05:27
* @LastEditTime: 2022-06-24 11:14:52
* @Description: file content
-->
<template>
<view class="thumb">
<view class="thumb--item">
<u-icon name="thumb-up"></u-icon>
<text>2</text>
<view class="thumb--item" @click="handleUseful">
<u-icon name="thumb-up-fill" v-if="isLike"></u-icon>
<u-icon name="thumb-up" v-else></u-icon>
<text>{{usefulCount}}</text>
</view>
<view class="thumb--item" @click="$Router.push(`/goodsCommentDetail?id=${commentDetail.id}`)">
<u-icon name="chat"></u-icon>
@ -18,6 +19,8 @@
</view>
</template>
<script>
import {Debounce} from '@/common/utils';
import {ApiPutCommentUseful} from '@/common/api/comment'
export default {
props : {
commentDetail : {
@ -25,11 +28,48 @@ export default {
default : ()=>({})
}
},
data(){
return {
debounce : null,
isLike : false,
usefulCount : 0
}
},
computed : {
answerCount (){
const arr = this.commentDetail.answerCommentList || []
const arr = this.commentDetail.answerCommentList || [];
return arr.length;
}
},
watch :{
commentDetail (){
this.isLike = this.commentDetail.isLike;
this.usefulCount = this.commentDetail.usefulCount;
}
},
methods:{
handleUseful(){
this.isLike = !this.isLike
if(this.isLike){
this.usefulCount++;
}else{
this.usefulCount--;
}
if(!this.debounce){
this.debounce = Debounce(this.updateUseFul, 500);
}
this.debounce();
},
async updateUseFul(){
if(this.isLike === this.commentDetail.isLike){
return false
}
const {error, result} = await ApiPutCommentUseful({
commentId : this.commentDetail.id,
isLike : this.isLike
});
}
}
}
</script>

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-06-21 16:51:03
* @LastEditors: ch
* @LastEditTime: 2022-06-23 11:14:27
* @LastEditTime: 2022-06-24 11:12:05
* @Description: file content
-->
<template>
@ -19,10 +19,12 @@
<image v-else class="header--sort" src="@/static/comment/sort.png"/>
</view>
</view>
<view class="comment" v-for="item in list" :key="item.id" @click="$Router.push(`/goodsCommentDetail?id=${item.id}`)">
<BsCommentUserInfo :userData="item"/>
<BsCommentInfo :commentDetail="item"/>
<BsCommentFollowInfo :commentTime="item.createTime" :followComment="item.followComment"/>
<view class="comment" v-for="item in list" :key="item.id" >
<view @click="$Router.push(`/goodsCommentDetail?id=${item.id}`)">
<BsCommentUserInfo :userData="item"/>
<BsCommentInfo :commentDetail="item"/>
<BsCommentFollowInfo v-if="item.followComment" :commentTime="item.createTime" :followComment="item.followComment"/>
</view>
<BsCommentThumbup :commentDetail="item"/>
</view>
<u-loadmore :status="loadingStatus" v-if="loadingStatus === 'loading'"/>

Loading…
Cancel
Save