diff --git a/src/components/custom-navigation-bar/index.vue b/src/components/custom-navigation-bar/index.vue index 10b223c..bcb3038 100644 --- a/src/components/custom-navigation-bar/index.vue +++ b/src/components/custom-navigation-bar/index.vue @@ -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 diff --git a/src/home/ctr.vue b/src/home/ctr.vue index 8bec9e8..054496a 100644 --- a/src/home/ctr.vue +++ b/src/home/ctr.vue @@ -95,7 +95,7 @@ borderRadius: '10px', }" @click="unbind" - v-if="Uid == rootuserid" + v-if="isMainAccount" >解除绑定 @@ -838,6 +838,17 @@ const vTypeList = [ const voltageType = ref(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(() => { // 默认 diff --git a/src/home/wqm.vue b/src/home/wqm.vue index f7c79d5..b3a79a0 100644 --- a/src/home/wqm.vue +++ b/src/home/wqm.vue @@ -95,7 +95,7 @@ }" @click="unbind" :loading="b_isLoading" - v-if="Uid==rootuserid" + v-if="isMainAccount" >解除绑定 @@ -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(() => { // 默认