fix(JoinFamily): 修复被踢出家庭用户仍可直接加入的问题
检查家庭是否被踢出状态,如果是则显示选择弹窗而非直接加入
Showing
1 changed file
with
27 additions
and
17 deletions
| ... | @@ -128,8 +128,8 @@ | ... | @@ -128,8 +128,8 @@ |
| 128 | <view class="flex-1"> | 128 | <view class="flex-1"> |
| 129 | <view class="font-medium text-gray-900 mb-1"> | 129 | <view class="font-medium text-gray-900 mb-1"> |
| 130 | {{ family.name }} | 130 | {{ family.name }} |
| 131 | - <text v-if="family.is_kicked" class="text-xs text-red-500 ml-2">(被大家长移除后无法再加入)</text> | ||
| 132 | </view> | 131 | </view> |
| 132 | + <text v-if="family.is_kicked" class="text-xs text-red-500">被大家长移除后无法再加入</text> | ||
| 133 | <view class="text-sm text-gray-600 line-clamp-2">{{ family.note }}</view> | 133 | <view class="text-sm text-gray-600 line-clamp-2">{{ family.note }}</view> |
| 134 | </view> | 134 | </view> |
| 135 | 135 | ||
| ... | @@ -400,22 +400,32 @@ const handleJoinFamily = async () => { | ... | @@ -400,22 +400,32 @@ const handleJoinFamily = async () => { |
| 400 | } | 400 | } |
| 401 | 401 | ||
| 402 | if (families.length === 1) { | 402 | if (families.length === 1) { |
| 403 | - // 只有一个家庭,直接加入 | 403 | + // 只有一个家庭,检查是否被踢出 |
| 404 | - const joinFamily = await joinFamilyAPI({ | 404 | + const family = families[0]; |
| 405 | - family_id: families[0].id, | 405 | + |
| 406 | - role: selectedRole.value | 406 | + if (family.is_kicked) { |
| 407 | - }) | 407 | + // 被踢出状态,显示选择弹窗让用户知道 |
| 408 | - if (joinFamily.code) { | 408 | + showFamilySelector.value = true; |
| 409 | - Taro.showToast({ | 409 | + mockFamilies.value = families; |
| 410 | - title: '加入成功', | 410 | + } else { |
| 411 | - icon: 'success' | 411 | + // 未被踢出,直接加入 |
| 412 | - }) | 412 | + const joinFamily = await joinFamilyAPI({ |
| 413 | - | 413 | + family_id: family.id, |
| 414 | - setTimeout(() => { | 414 | + role: selectedRole.value |
| 415 | - Taro.redirectTo({ | 415 | + }); |
| 416 | - url: '/pages/Dashboard/index' | 416 | + |
| 417 | - }) | 417 | + if (joinFamily.code) { |
| 418 | - }, 1500) | 418 | + Taro.showToast({ |
| 419 | + title: '加入成功', | ||
| 420 | + icon: 'success' | ||
| 421 | + }); | ||
| 422 | + | ||
| 423 | + setTimeout(() => { | ||
| 424 | + Taro.redirectTo({ | ||
| 425 | + url: '/pages/Dashboard/index' | ||
| 426 | + }); | ||
| 427 | + }, 1500); | ||
| 428 | + } | ||
| 419 | } | 429 | } |
| 420 | } else { | 430 | } else { |
| 421 | // 多个家庭,显示选择弹窗 | 431 | // 多个家庭,显示选择弹窗 | ... | ... |
-
Please register or login to post a comment