fix: youhua
This commit is contained in:
@@ -37,7 +37,7 @@ const props = defineProps({
|
||||
}
|
||||
});
|
||||
|
||||
const emit = defineEmits(['need-login']);
|
||||
const emit = defineEmits(['need-login', 'like-change']);
|
||||
const userStore = useUserStore();
|
||||
const isLoggedIn = computed(() => !!userStore.token || !!userStore.userInfo?.nickName);
|
||||
|
||||
@@ -70,6 +70,11 @@ const handleLike = async () => {
|
||||
} else {
|
||||
currentLikes.value -= 1;
|
||||
}
|
||||
emit('like-change', {
|
||||
id: props.comment.id,
|
||||
isLiked: isLiked.value,
|
||||
likes: currentLikes.value
|
||||
});
|
||||
|
||||
try {
|
||||
// 调用点赞接口 (点赞和取消点赞为同一个接口)
|
||||
@@ -85,7 +90,6 @@ const handleLike = async () => {
|
||||
page: 'rating_detail'
|
||||
}
|
||||
});
|
||||
uni.showToast({ title: '操作成功', icon: 'success' });
|
||||
} catch (error) {
|
||||
// 接口调用失败,回滚 UI 状态
|
||||
isLiked.value = !isLiked.value;
|
||||
@@ -94,6 +98,11 @@ const handleLike = async () => {
|
||||
} else {
|
||||
currentLikes.value -= 1;
|
||||
}
|
||||
emit('like-change', {
|
||||
id: props.comment.id,
|
||||
isLiked: isLiked.value,
|
||||
likes: currentLikes.value
|
||||
});
|
||||
uni.showToast({ title: '操作失败', icon: 'none' });
|
||||
} finally {
|
||||
isLiking = false;
|
||||
|
||||
Reference in New Issue
Block a user