hookehuyr

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

检查家庭是否被踢出状态,如果是则显示选择弹窗而非直接加入
......@@ -128,8 +128,8 @@
<view class="flex-1">
<view class="font-medium text-gray-900 mb-1">
{{ family.name }}
<text v-if="family.is_kicked" class="text-xs text-red-500 ml-2">(被大家长移除后无法再加入)</text>
</view>
<text v-if="family.is_kicked" class="text-xs text-red-500">被大家长移除后无法再加入</text>
<view class="text-sm text-gray-600 line-clamp-2">{{ family.note }}</view>
</view>
......@@ -400,22 +400,32 @@ const handleJoinFamily = async () => {
}
if (families.length === 1) {
// 只有一个家庭,直接加入
const joinFamily = await joinFamilyAPI({
family_id: families[0].id,
role: selectedRole.value
})
if (joinFamily.code) {
Taro.showToast({
title: '加入成功',
icon: 'success'
})
setTimeout(() => {
Taro.redirectTo({
url: '/pages/Dashboard/index'
})
}, 1500)
// 只有一个家庭,检查是否被踢出
const family = families[0];
if (family.is_kicked) {
// 被踢出状态,显示选择弹窗让用户知道
showFamilySelector.value = true;
mockFamilies.value = families;
} else {
// 未被踢出,直接加入
const joinFamily = await joinFamilyAPI({
family_id: family.id,
role: selectedRole.value
});
if (joinFamily.code) {
Taro.showToast({
title: '加入成功',
icon: 'success'
});
setTimeout(() => {
Taro.redirectTo({
url: '/pages/Dashboard/index'
});
}, 1500);
}
}
} else {
// 多个家庭,显示选择弹窗
......