修复:求婚按钮异性判断 - 统一 sex 字段格式
根因:sex 字段数据库存整数(0/1/2),但前后端判断混用了
字符串('男'/'女')导致比较永远错误。
修复三处:
1. UserController::show() - sex 返回统一转字符串(1→'男' 2→'女' 其他→'')
2. frame.blade.php - chatContext.userSex 注入时同样转字符串
3. MarriageService::propose() - 后端性别校验改用整数(1/2)比较
逻辑链路:
- 未设置性别(sex=0) → '' → x-show && userInfo.sex 为'' falsy → 按钮隐藏 ✓
- 同性(如两个男) → '男'==='男' → !== 为false → 按钮隐藏 ✓
- 异性(男+女) → '男'!=='女' → 按钮显示 ✓
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
roomId: {{ $room->id }},
|
||||
userId: {{ $user->id }},
|
||||
username: "{{ $user->username }}",
|
||||
userSex: "{{ $user->sex }}",
|
||||
userSex: "{{ match ((int) $user->sex) {1 => '男',2 => '女',default => ''} }}",
|
||||
userLevel: {{ $user->user_level }},
|
||||
superLevel: {{ $superLevel }},
|
||||
levelKick: {{ $levelKick }},
|
||||
|
||||
Reference in New Issue
Block a user