WIN-2308041133\Administrator 20 hours ago
parent
commit
57dd6a2236
1 changed files with 5 additions and 0 deletions
  1. 5 0
      app/model/api/ForumComment.php

+ 5 - 0
app/model/api/ForumComment.php

@@ -84,9 +84,14 @@ class ForumComment extends BaseModel
                 return [0, '帖子不存在或已被禁用'];
             }
 
+            // 获取用户昵称,如果为空则取手机号
+            $user = Db::name('user')->where('uid', $uid)->find();
+            $userName = !empty($user['nickname']) ? $user['nickname'] : ($user['mobile'] ?? '匿名用户');
+
             $insertData = [
                 'post_id' => $postId,
                 'uid' => $uid,
+                'user_name' => $userName,
                 'content' => trim($content),
                 'status' => 1,
                 'create_time' => time(),