| | |
| | | <script setup lang="ts"> |
| | | import { logoutMini } from '@/api/auth' |
| | | import { logoutMini, unbindMiniOpenId } from '@/api/auth' |
| | | import { fetchSystemSettings } from '@/api/systemSettings' |
| | | import { useMiniAuthStore } from '@/store/auth' |
| | | |
| | |
| | | { title: '预约审核', icon: '/static/mine/review.png', path: '/pages/reviewList/index', showFor: ['employee'] }, |
| | | { title: '来访记录', icon: '/static/mine/record.png', path: '/pages/visitRecord/index', showFor: ['employee'] }, |
| | | { title: '关于我们', icon: '/static/mine/aboutUs.png', path: '/pages/aboutUs/index', showFor: ['employee', 'normal'] }, |
| | | { title: '解除绑定', icon: '/static/mine/unbind.png', path: '', showFor: ['employee', 'normal'] }, |
| | | { title: '退出登录', icon: '/static/mine/logout.png', path: '', showFor: ['employee', 'normal'] }, |
| | | ]) |
| | | const visibleMenus = computed(() => menuList.value.filter((item) => { |
| | |
| | | } |
| | | } |
| | | |
| | | function handleUnbindOpenId() { |
| | | uni.showModal({ |
| | | title: '解除绑定', |
| | | content: '解除后将退出登录,下次登录需要重新授权手机号,确认解除绑定?', |
| | | confirmText: '解除', |
| | | confirmColor: '#FF4D4F', |
| | | success: (res) => { |
| | | if (res.confirm) { |
| | | void unbindOpenId() |
| | | } |
| | | }, |
| | | }) |
| | | } |
| | | |
| | | async function unbindOpenId() { |
| | | try { |
| | | await unbindMiniOpenId() |
| | | uni.showToast({ title: '已解除绑定', icon: 'none' }) |
| | | } |
| | | catch (error) { |
| | | uni.showToast({ |
| | | title: error instanceof Error ? error.message : '解除绑定失败', |
| | | icon: 'none', |
| | | }) |
| | | } |
| | | finally { |
| | | authStore.clearSession() |
| | | router.replaceAll({ name: 'home' }) |
| | | setTimeout(() => { |
| | | authStore.showLoginPrompt('请重新登录并授权手机号') |
| | | }, 300) |
| | | } |
| | | } |
| | | |
| | | function handleMenuClick(item: MenuItem) { |
| | | if (!isLoggedIn.value) { |
| | | authStore.showLoginPrompt('您还未登录,请先登录') |
| | |
| | | void handleLogout() |
| | | return |
| | | } |
| | | if (item.title === '解除绑定') { |
| | | handleUnbindOpenId() |
| | | return |
| | | } |
| | | |
| | | if (item.path) { |
| | | uni.navigateTo({ url: item.path }) |