Ver código fonte

点赞回复功能调整

canghailong 7 meses atrás
pai
commit
c75fefce30

+ 4 - 4
src/components/Comment/index.vue

@@ -9,10 +9,10 @@
 				<span key="comment-basic-like">
 					<a-tooltip title="点赞">
 						<template v-if="item.isLike == 1">
-							<HeartOutlined :style="{ color: '#fa6c8d' }" @click="like(item)" />
+							<HeartOutlined :style="{ color: '#fa6c8d' }" @click="like(item,0)" />
 						</template>
 						<template v-else>
-							<HeartOutlined @click="like(item)" />
+							<HeartOutlined @click="like(item,1)" />
 						</template>
 					</a-tooltip>
 					<span style="padding-left: 8px; cursor: auto">
@@ -92,7 +92,7 @@
 		if (!val) return ''
 		return parseTime(val, '{y}-{m}-{d} {h}:{i}:{s}')
 	}
-	const like = (item) => {
+	const like = (item,l) => {
 		forumApi
 			.postlikeSubmit(
 				{
@@ -102,7 +102,7 @@
 				item.isLike
 			)
 			.then((data) => {
-				item.isLike = !item.isLike
+				item.isLike = l
 			})
 	}
 	const showDeleteConfirm = (item) => {

+ 5 - 5
src/views/forum/detail.vue

@@ -20,11 +20,11 @@
 		<div>
 			<span>
 				<a-tooltip title="点赞">
-					<template v-if="detailObj.isLike">
-						<HeartOutlined :style="{ color: '#fa6c8d' }" @click="like" />
+					<template v-if="detailObj.isLike == 1">
+						<HeartOutlined :style="{ color: '#fa6c8d' }" @click="like(item, 0)" />
 					</template>
 					<template v-else>
-						<HeartOutlined @click="like" />
+						<HeartOutlined @click="like(item, 1)" />
 					</template>
 				</a-tooltip>
 				<span style="padding-left: 8px">
@@ -78,9 +78,9 @@
 		current: 1,
 		size: 10
 	})
-	function like(item) {
+	function like(item, l) {
 		forumApi.postlikeSubmit({ likeType: 0, targetId: route.query.postId }, item.isLike).then((data) => {
-			item.isLike = !item.isLike
+			item.isLike = l
 			resetGetList()
 		})
 	}

+ 2 - 2
src/views/forum/index.vue

@@ -89,13 +89,13 @@
 			width: 100
 		},
 		{
-			title: '回复',
+			title: '回复',
 			dataIndex: 'replyCount',
 			align: 'center',
 			width: 100
 		},
 		{
-			title: '浏览',
+			title: '浏览',
 			dataIndex: 'viewCount',
 			align: 'center',
 			width: 100