|
@@ -1,7 +1,11 @@
|
|
|
<script setup lang="ts">
|
|
|
import { useUserStore } from '../../../store'
|
|
|
-import { createCircleReviewUpvote, getReviewReplay } from '../../../core/libs/requests'
|
|
|
-import { thumbsUp } from '../../../core/libs/svgs'
|
|
|
+import {
|
|
|
+ cancelCircleReviewUpvote,
|
|
|
+ createCircleReviewUpvote,
|
|
|
+ getReviewReplay,
|
|
|
+} from '../../../core/libs/requests'
|
|
|
+import { thumbsUp, thumbsUpActive } from '../../../core/libs/svgs'
|
|
|
import { Comment } from '../../../core/models/moment'
|
|
|
import { dayjs } from 'wot-design-uni'
|
|
|
import { storeToRefs } from 'pinia'
|
|
@@ -20,13 +24,22 @@ const emits = defineEmits<{ upvote: [] }>()
|
|
|
const userStore = useUserStore()
|
|
|
const { userInfo } = storeToRefs(userStore)
|
|
|
const handleUpvote = async () => {
|
|
|
- const { code, msg } = await createCircleReviewUpvote({
|
|
|
- circleId: props.options.circleId,
|
|
|
- userId: userInfo.value.userId,
|
|
|
- userName: userInfo.value.nickname,
|
|
|
- reviewId: props.options.id,
|
|
|
- })
|
|
|
- code === 0 && uni.showToast({ title: '点赞成功', icon: 'none' })
|
|
|
+ if (!props.options.upvote) {
|
|
|
+ const { code, msg } = await createCircleReviewUpvote({
|
|
|
+ circleId: props.options.circleId,
|
|
|
+ userId: userInfo.value.userId,
|
|
|
+ userName: userInfo.value.nickname,
|
|
|
+ reviewId: props.options.id,
|
|
|
+ })
|
|
|
+ code === 0 && uni.showToast({ title: '点赞成功', icon: 'none' })
|
|
|
+ } else {
|
|
|
+ const { code, msg } = await cancelCircleReviewUpvote({
|
|
|
+ circleId: props.options.circleId.toString(),
|
|
|
+ userId: userInfo.value.userId.toString(),
|
|
|
+ reviewId: props.options.id.toString(),
|
|
|
+ })
|
|
|
+ code === 0 && uni.showToast({ title: '取消点赞成功', icon: 'none' })
|
|
|
+ }
|
|
|
emits('upvote')
|
|
|
}
|
|
|
onMounted(async () => {
|
|
@@ -60,7 +73,7 @@ onMounted(async () => {
|
|
|
</view>
|
|
|
<view class="col-start-3 row-start-1 flex flex-col items-center" @click="handleUpvote">
|
|
|
<div class="w-[18px] h-[18px] relative">
|
|
|
- <wd-img :src="thumbsUp" width="18" height="18"></wd-img>
|
|
|
+ <wd-img :src="options.upvote ? thumbsUpActive : thumbsUp" width="18" height="18"></wd-img>
|
|
|
</div>
|
|
|
<div
|
|
|
class="mt-1.5 text-black/40 text-[10px] font-normal font-['PingFang SC'] leading-[10.18px]"
|