From b106703f9179657e678df7fe68a43f9de1ac7f69 Mon Sep 17 00:00:00 2001 From: tianyongbao Date: Tue, 20 Jan 2026 13:57:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E4=B8=BB=E5=AD=90?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E5=8F=8A=E8=A7=A3=E7=BB=91=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=9A=84=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/custom-navigation-bar/index.vue | 11 +++++++++-- src/home/ctr.vue | 13 ++++++++++++- src/home/wqm.vue | 13 ++++++++++++- 3 files changed, 33 insertions(+), 4 deletions(-) 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(() => { // 默认