puzhibing
2026-08-28 e92cd56bb56b111c1afe9922191f9897215ff6b0
yuyueMiniProgram/src/pages/mine/index.vue
@@ -1,5 +1,5 @@
<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'
@@ -57,6 +57,7 @@
  { 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) => {
@@ -102,6 +103,40 @@
  }
}
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('您还未登录,请先登录')
@@ -109,6 +144,10 @@
  }
  if (item.title === '退出登录') {
    void handleLogout()
    return
  }
  if (item.title === '解除绑定') {
    handleUnbindOpenId()
    return
  }
@@ -139,7 +178,7 @@
          :style="{ top: statusBarHeight + 'px', height: navBarHeight + 'px' }">
          <view class="relative z-10 flex h-full w-[88rpx] items-center justify-center" />
          <view class="absolute left-0 z-0 w-full text-center text-[34rpx] font-medium text-white">
            红宇精工访客预约
            红宇集团访客预约
          </view>
          <view class="w-[88rpx]" />
        </view>