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