fix: youhua

This commit is contained in:
zzc
2026-06-10 01:24:41 +08:00
parent 1e5bbbbf9e
commit aa88eef08e
3 changed files with 164 additions and 26 deletions

View File

@@ -20,10 +20,13 @@
class="comment-input"
type="text"
v-model="commentText"
:disabled="sending"
placeholder="说点什么吧..."
placeholder-class="input-placeholder"
/>
<button class="send-btn" @tap="handleSend">发送</button>
<button class="send-btn" :class="{ 'is-disabled': sending }" :disabled="sending" @tap="handleSend">
{{ sending ? '发送中...' : '发送' }}
</button>
</view>
</view>
</template>
@@ -35,6 +38,10 @@ const props = defineProps({
initialAction: {
type: String,
default: ''
},
sending: {
type: Boolean,
default: false
}
});
@@ -62,19 +69,28 @@ const handleAction = (action) => {
};
const handleSend = () => {
if (!commentText.value.trim()) {
const content = commentText.value.trim();
if (!content) {
uni.showToast({
title: '请输入评论内容',
icon: 'none'
});
return;
}
if (props.sending) return;
emit('send-comment', {
action: currentAction.value,
content: commentText.value
content
});
commentText.value = ''; // 发送后清空
};
const resetComment = () => {
commentText.value = '';
};
defineExpose({
resetComment
});
</script>
<style lang="scss" scoped>
@@ -162,7 +178,11 @@ const handleSend = () => {
margin: 0;
}
.send-btn.is-disabled {
opacity: 0.7;
}
.send-btn::after {
border: none;
}
</style>
</style>

View File

@@ -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;