Explorar el Código

完成个人页面登录逻辑校验

yuanmingze hace 2 meses
padre
commit
669f225392
Se han modificado 3 ficheros con 100 adiciones y 24 borrados
  1. 7 0
      src/pages-auth/settlement-channel-sign/index.vue
  2. 7 0
      src/pages.json
  3. 86 24
      src/pages/mine/index.vue

+ 7 - 0
src/pages-auth/settlement-channel-sign/index.vue

@@ -0,0 +1,7 @@
+<template>
+  <view>签约结算渠道</view>
+</template>
+
+<script setup lang="ts"></script>
+
+<style lang="scss" scoped></style>

+ 7 - 0
src/pages.json

@@ -233,6 +233,13 @@
             "navigationBarTitleText": "银行卡认证",
             "navigationBarTitleText": "银行卡认证",
             "navigationStyle": "default"
             "navigationStyle": "default"
           }
           }
+        },
+        {
+          "path": "settlement-channel-sign/index",
+          "style": {
+            "navigationBarTitleText": "签约结算渠道",
+            "navigationStyle": "default"
+          }
         }
         }
       ]
       ]
     }
     }

+ 86 - 24
src/pages/mine/index.vue

@@ -57,6 +57,7 @@
         </template>
         </template>
       </view>
       </view>
     </view>
     </view>
+
     <view class="mine-content">
     <view class="mine-content">
       <view class="auth card">
       <view class="auth card">
         <view class="auth-item" @click="navigateToAuth">
         <view class="auth-item" @click="navigateToAuth">
@@ -77,7 +78,7 @@
           </view>
           </view>
         </view>
         </view>
 
 
-        <view class="auth-item auth-item-last">
+        <view class="auth-item auth-item-last" @click="navigateToSettlementChannelSign">
           <view class="auth-item-content">
           <view class="auth-item-content">
             <image class="auth-item-icon" mode="aspectFit" />
             <image class="auth-item-icon" mode="aspectFit" />
             <view class="auth-item-text">
             <view class="auth-item-text">
@@ -92,6 +93,7 @@
           </view>
           </view>
         </view>
         </view>
       </view>
       </view>
+
       <view class="card menu-list">
       <view class="card menu-list">
         <view
         <view
           class="menu-item"
           class="menu-item"
@@ -109,6 +111,7 @@
           </view>
           </view>
         </view>
         </view>
       </view>
       </view>
+
       <view class="card common-panel">
       <view class="card common-panel">
         <view class="common-panel-title">常用功能</view>
         <view class="common-panel-title">常用功能</view>
         <view class="common-grid">
         <view class="common-grid">
@@ -121,6 +124,7 @@
             <image class="common-grid-icon" :src="item.icon" mode="aspectFit" />
             <image class="common-grid-icon" :src="item.icon" mode="aspectFit" />
             <view class="common-grid-text">{{ item.txt }}</view>
             <view class="common-grid-text">{{ item.txt }}</view>
           </view>
           </view>
+
           <view
           <view
             class="common-grid-item common-grid-item-message"
             class="common-grid-item common-grid-item-message"
             @click="navigateTo('/pages-mine/notification/index')"
             @click="navigateTo('/pages-mine/notification/index')"
@@ -135,6 +139,7 @@
             </view>
             </view>
             <view class="common-grid-text">消息通知</view>
             <view class="common-grid-text">消息通知</view>
           </view>
           </view>
+
           <view class="common-grid-item common-grid-item-osais">
           <view class="common-grid-item common-grid-item-osais">
             <image
             <image
               class="common-grid-icon"
               class="common-grid-icon"
@@ -145,8 +150,10 @@
           </view>
           </view>
         </view>
         </view>
       </view>
       </view>
+
       <view class="login-out" v-if="isLoggedIn" @click="handleLogoutClick">退出登录</view>
       <view class="login-out" v-if="isLoggedIn" @click="handleLogoutClick">退出登录</view>
     </view>
     </view>
+
     <!-- 切换企业 -->
     <!-- 切换企业 -->
     <wd-action-sheet
     <wd-action-sheet
       title="选择企业"
       title="选择企业"
@@ -170,24 +177,30 @@ import { useUserStore } from '@/stores/modules/user'
 
 
 import { functionList, menuList, rolesList } from './mine.config'
 import { functionList, menuList, rolesList } from './mine.config'
 
 
+const LOGIN_PAGE_URL = '/pages/login/index'
+const CERTIFICATION_SERVICE_URL = '/pages-auth/certification-service/index'
+const SETTLEMENT_CHANNEL_SIGN_URL = '/pages-auth/settlement-channel-sign/index'
+
 const userStore = useUserStore()
 const userStore = useUserStore()
 
 
 const isLoggedIn = computed(() => userStore.isLoggedIn)
 const isLoggedIn = computed(() => userStore.isLoggedIn)
 const currentUserInfo = computed(() => userStore.currentUserInfo)
 const currentUserInfo = computed(() => userStore.currentUserInfo)
-
 const isBlacklisted = computed(() => userStore.isBlacklisted)
 const isBlacklisted = computed(() => userStore.isBlacklisted)
 
 
+const hasUnreadNotification = ref(false)
+const companyList = ref<{ name: string; color: string }[]>([])
+const handleCompanyShow = ref(false)
+
 onLoad(() => {
 onLoad(() => {
   if (!isLoggedIn.value) return
   if (!isLoggedIn.value) return
   getInternalMsgCountUnread()
   getInternalMsgCountUnread()
 })
 })
 
 
-const hasUnreadNotification = ref(false)
 const getInternalMsgCountUnread = async () => {
 const getInternalMsgCountUnread = async () => {
   try {
   try {
     const res = await getInternalMsgCountUnreadApi()
     const res = await getInternalMsgCountUnreadApi()
     if (res.code === 0) {
     if (res.code === 0) {
-      hasUnreadNotification.value = res.data === 0 ? false : true
+      hasUnreadNotification.value = res.data !== 0
     }
     }
   } catch (error) {
   } catch (error) {
     console.error('获取未读消息数量失败:', error)
     console.error('获取未读消息数量失败:', error)
@@ -196,31 +209,73 @@ const getInternalMsgCountUnread = async () => {
 
 
 const navigateToLogin = () => {
 const navigateToLogin = () => {
   uni.navigateTo({
   uni.navigateTo({
-    url: '/pages/login/index',
+    url: LOGIN_PAGE_URL,
+  })
+}
+
+const showBlacklistedModal = () => {
+  uni.showModal({
+    showCancel: false,
+    title: '提示',
+    content: '该账号存在风险,请联系管理员',
+  })
+}
+
+/**
+ * 所有业务页面跳转前置校验:
+ * 1. 未登录:跳登录页
+ * 2. 已登录但黑名单:提示风险,不跳转
+ * 3. 正常用户:允许继续
+ */
+const checkBeforeNavigate = () => {
+  if (!isLoggedIn.value) {
+    navigateToLogin()
+    return false
+  }
+
+  if (isBlacklisted.value) {
+    showBlacklistedModal()
+    return false
+  }
+
+  return true
+}
+
+const navigateTo = (path?: string) => {
+  if (!path) return
+  if (!checkBeforeNavigate()) return
+
+  uni.navigateTo({
+    url: path,
   })
   })
 }
 }
 
 
 const getRolesName = (roles: number[]) => {
 const getRolesName = (roles: number[]) => {
-  const rile = roles?.[0] || 0
-  const roleList = rolesList.find((role) => role.value === rile)
-  return roleList?.name || ''
+  const role = roles?.[0] || 0
+  const roleItem = rolesList.find((item) => item.value === role)
+  return roleItem?.name || ''
 }
 }
+
 // 切换企业
 // 切换企业
-const companyList = ref<{ name: string; color: string }[]>([])
-const handleCompanyShow = ref(false)
 const handleCompanySelect = () => {
 const handleCompanySelect = () => {
-  if (isBlacklisted.value) return
+  if (!checkBeforeNavigate()) return
+
   const userInfoList = userStore.userInfoList
   const userInfoList = userStore.userInfoList
   const currentUserInfoIndex = userStore.currentUserInfoIndex || 0
   const currentUserInfoIndex = userStore.currentUserInfoIndex || 0
+
   const arr = userInfoList.map((info) => ({
   const arr = userInfoList.map((info) => ({
     name: info?.deptName,
     name: info?.deptName,
     color: '#333333',
     color: '#333333',
   }))
   }))
 
 
-  arr[currentUserInfoIndex].color = '#3FA3F1'
+  if (arr[currentUserInfoIndex]) {
+    arr[currentUserInfoIndex].color = '#3FA3F1'
+  }
+
   companyList.value = arr
   companyList.value = arr
   handleCompanyShow.value = true
   handleCompanyShow.value = true
 }
 }
+
 const handleCompanyConfirm = (curr: { item: { name: string; color: string }; index: number }) => {
 const handleCompanyConfirm = (curr: { item: { name: string; color: string }; index: number }) => {
   const index = curr.index
   const index = curr.index
   if (index === userStore.currentUserInfoIndex) return
   if (index === userStore.currentUserInfoIndex) return
@@ -228,24 +283,27 @@ const handleCompanyConfirm = (curr: { item: { name: string; color: string }; ind
 }
 }
 
 
 const navigateToAuth = () => {
 const navigateToAuth = () => {
-  uni.navigateTo({
-    url: '/pages-auth/certification-service/index',
-  })
+  navigateTo(CERTIFICATION_SERVICE_URL)
 }
 }
 
 
-const navigateTo = (path: string) => {
+const navigateToSettlementChannelSign = () => {
+  if (!checkBeforeNavigate()) return
+
+  if (!currentUserInfo.value?.faceAuthStatus || !currentUserInfo.value?.bankCardNumber) {
+    return uni.showModal({
+      title: '提示',
+      content: '请先在认证服务中完成认证',
+      showCancel: false,
+    })
+  }
+
   uni.navigateTo({
   uni.navigateTo({
-    url: path,
+    url: SETTLEMENT_CHANNEL_SIGN_URL,
   })
   })
 }
 }
 
 
 const functionListClick = (item: { key: string; txt: string; icon: string; path?: string }) => {
 const functionListClick = (item: { key: string; txt: string; icon: string; path?: string }) => {
-  if (item.path) {
-    uni.navigateTo({
-      url: item.path,
-    })
-    return
-  }
+  navigateTo(item.path)
 }
 }
 
 
 const handleLogoutClick = () => {
 const handleLogoutClick = () => {
@@ -256,7 +314,7 @@ const handleLogoutClick = () => {
       if (res.confirm) {
       if (res.confirm) {
         userStore.logout()
         userStore.logout()
         uni.reLaunch({
         uni.reLaunch({
-          url: '/pages/login/index',
+          url: LOGIN_PAGE_URL,
         })
         })
       }
       }
     },
     },
@@ -281,6 +339,7 @@ const handleLogoutClick = () => {
     :deep(.navbar) {
     :deep(.navbar) {
       background-color: transparent;
       background-color: transparent;
     }
     }
+
     .navbar-title {
     .navbar-title {
       color: #fff;
       color: #fff;
       font-weight: bold;
       font-weight: bold;
@@ -365,6 +424,7 @@ const handleLogoutClick = () => {
   .mine-content {
   .mine-content {
     position: relative;
     position: relative;
     top: -100rpx;
     top: -100rpx;
+
     .card {
     .card {
       width: 690rpx;
       width: 690rpx;
       margin: 0 30rpx 16rpx;
       margin: 0 30rpx 16rpx;
@@ -431,6 +491,7 @@ const handleLogoutClick = () => {
         font-weight: 600;
         font-weight: 600;
       }
       }
     }
     }
+
     .menu-list {
     .menu-list {
       .menu-item {
       .menu-item {
         display: flex;
         display: flex;
@@ -474,6 +535,7 @@ const handleLogoutClick = () => {
         flex-shrink: 0;
         flex-shrink: 0;
       }
       }
     }
     }
+
     .common-panel {
     .common-panel {
       min-height: 240rpx;
       min-height: 240rpx;