diff --git a/src/subpages/mdugc/note-detail.js b/src/subpages/mdugc/note-detail.js
index efa7cb0b3..5c921d938 100644
--- a/src/subpages/mdugc/note-detail.js
+++ b/src/subpages/mdugc/note-detail.js
@@ -222,8 +222,12 @@ function UgcNoteDetail(props) {
})
}
- // 点赞评论
+ // 点赞评论(入口已由 SpLogin 包裹,此处兜底防未登录)
const handleCommentLike = async (comment_id, pindex, index) => {
+ if (!userInfo?.user_id) {
+ showToast('请先登录')
+ return
+ }
const { action, likes } = await mdugcApi.commentlike({
user_id: userInfo.user_id,
post_id,
@@ -245,20 +249,31 @@ function UgcNoteDetail(props) {
})
}
- // 提交回复
+ // 提交回复(需已登录;未登录时应在输入前经 SpLogin)
const onSubmitComment = async (e) => {
- console.log('onSubmitComment:', e)
+ if (!S.getAuthToken() || !userInfo?.user_id) {
+ showToast('请先登录')
+ setState((draft) => {
+ draft.showCommentInput = false
+ })
+ return
+ }
+ const raw = e?.detail?.value ?? e?.detail ?? comment
+ const content = String(raw ?? '').trim()
+ if (!content) {
+ return
+ }
let params = {
user_id: userInfo.user_id,
post_id,
- content: e.detail.value
+ content
}
if (parentCommentId) {
params.parent_comment_id = parentCommentId
}
const res = await mdugcApi.commentcreate(params)
showToast(res.message)
- listRef.current.reset()
+ listRef.current?.reset()
setState((draft) => {
draft.comment = ''
draft.showCommentInput = false
@@ -317,10 +332,12 @@ function UgcNoteDetail(props) {
}
renderFooter={
-
-
- 留言评论...
-
+
+
+
+ 留言评论...
+
+
@@ -512,9 +529,8 @@ function UgcNoteDetail(props) {
{item.username}
- {
+ {
setState((draft) => {
draft.showCommentInput = true
draft.parentCommentId = item.commentId
@@ -522,18 +538,21 @@ function UgcNoteDetail(props) {
})
}}
>
- {item.content}
- {item.created}
-
+
+ {item.content}
+ {item.created}
+
+
-
+ handleCommentLike(item.commentId, index)}>
+
+
{item.likes}
@@ -552,18 +571,18 @@ function UgcNoteDetail(props) {
-
+
+ handleCommentLike(citem.commentId, index, cindex)
+ }
+ >
+
+
{citem.likes}
diff --git a/src/subpages/mdugc/note-detail.scss b/src/subpages/mdugc/note-detail.scss
index 449c495c6..e74f008aa 100644
--- a/src/subpages/mdugc/note-detail.scss
+++ b/src/subpages/mdugc/note-detail.scss
@@ -358,6 +358,12 @@
padding: 20px;
display: flex;
+ /* SpLogin 包裹留言框时保持与原 .comment-input 同宽 */
+ > .sp-login {
+ flex-shrink: 0;
+ width: 244px;
+ }
+
.comment-input {
width: 244px;
height: 60px;