hookehuyr

fix(JoinFamily): 修复被踢出家庭用户仍可直接加入的问题

检查家庭是否被踢出状态,如果是则显示选择弹窗而非直接加入
...@@ -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 family = families[0];
405 +
406 + if (family.is_kicked) {
407 + // 被踢出状态,显示选择弹窗让用户知道
408 + showFamilySelector.value = true;
409 + mockFamilies.value = families;
410 + } else {
411 + // 未被踢出,直接加入
404 const joinFamily = await joinFamilyAPI({ 412 const joinFamily = await joinFamilyAPI({
405 - family_id: families[0].id, 413 + family_id: family.id,
406 role: selectedRole.value 414 role: selectedRole.value
407 - }) 415 + });
416 +
408 if (joinFamily.code) { 417 if (joinFamily.code) {
409 Taro.showToast({ 418 Taro.showToast({
410 title: '加入成功', 419 title: '加入成功',
411 icon: 'success' 420 icon: 'success'
412 - }) 421 + });
413 422
414 setTimeout(() => { 423 setTimeout(() => {
415 Taro.redirectTo({ 424 Taro.redirectTo({
416 url: '/pages/Dashboard/index' 425 url: '/pages/Dashboard/index'
417 - }) 426 + });
418 - }, 1500) 427 + }, 1500);
428 + }
419 } 429 }
420 } else { 430 } else {
421 // 多个家庭,显示选择弹窗 431 // 多个家庭,显示选择弹窗
......