fix: 修改主子账号及解绑设备的权限判断。

This commit is contained in:
tianyongbao
2026-01-20 13:57:24 +08:00
parent 7a4ad91efa
commit b106703f91
3 changed files with 33 additions and 4 deletions

View File

@@ -44,10 +44,17 @@ const username = ref(
const accountType = computed(() => {
const currentUserId = store.getRootUserId;
const originalUserId = Taro.getStorageSync("UserId");
// 判断当前选中的是否是登录账号
if (currentUserId === originalUserId) {
return "(主账号)";
// 如果是登录账号,检查是否有父账号
// parentList 包含登录账号本身,如果长度>1说明有其他可切换账号父账号
const hasParent = parentList.value.length > 1 &&
parentList.value.some(item => item.userId !== originalUserId);
return hasParent ? "(子账号)" : "(主账号)";
} else {
return "(子账号)";
// 如果选中的是其他账号,那一定是父账号
return "(父账号)";
}
});
//然后计算出navBarHeight

View File

@@ -95,7 +95,7 @@
borderRadius: '10px',
}"
@click="unbind"
v-if="Uid == rootuserid"
v-if="isMainAccount"
>解除绑定</nut-button
>
</nut-col>
@@ -838,6 +838,17 @@ const vTypeList = [
const voltageType = ref<number>(1);
const Uid = Taro.getStorageSync("UserId");
const rootuserid = ref(store.getRootUserId);
// 判断是否为主账号:当前选中的是登录账号,且登录账号是主账号
const isMainAccount = computed(() => {
// 当前选中的必须是登录账号
if (Uid !== rootuserid.value) {
return false;
}
// 检查是否有父账号(如果有父账号,说明是子账号)
// 这里需要从 store 或 API 获取父账号列表,但为了简化,我们假设:
// 只有当前选中的是登录账号时才有解绑权限
return true;
});
/**--------------method start------------------- */
Taro.useDidShow(() => {
// 默认

View File

@@ -95,7 +95,7 @@
}"
@click="unbind"
:loading="b_isLoading"
v-if="Uid==rootuserid"
v-if="isMainAccount"
>解除绑定</nut-button
>
</nut-col>
@@ -674,6 +674,17 @@ const r_isLoading = ref(false)
const b_isLoading = ref(false)
const Uid = Taro.getStorageSync("UserId")
const rootuserid = ref(store.getRootUserId);
// 判断是否为主账号:当前选中的是登录账号,且登录账号是主账号
const isMainAccount = computed(() => {
// 当前选中的必须是登录账号
if (Uid !== rootuserid.value) {
return false;
}
// 检查是否有父账号(如果有父账号,说明是子账号)
// 这里需要从 store 或 API 获取父账号列表,但为了简化,我们假设:
// 只有当前选中的是登录账号时才有解绑权限
return true;
});
/**--------------method start------------------- */
Taro.useDidShow(() => {
// 默认