Merge branch 'yueyixin'
This commit is contained in:
commit
f7e4e408b0
|
|
@ -11,4 +11,4 @@ VITE_REQUEST_TIMEOUT = 10000
|
|||
VITE_DEBUG = true
|
||||
|
||||
# 交易mqtt
|
||||
VITE_MQTT_TRANSACTION_HOST=ws://43.198.76.61:8083/mqtt
|
||||
VITE_MQTT_TRANSACTION_HOST=wss://43.198.76.61:8084/mqtt
|
||||
|
|
@ -11,4 +11,4 @@ VITE_REQUEST_TIMEOUT = 10000
|
|||
VITE_DEBUG = false
|
||||
|
||||
# 交易mqtt
|
||||
VITE_MQTT_TRANSACTION_HOST=ws://43.198.76.61:8083/mqtt
|
||||
VITE_MQTT_TRANSACTION_HOST=wss://43.198.76.61:8084/mqtt
|
||||
|
|
@ -102,7 +102,7 @@ let dynamicRoutesReady = false
|
|||
router.beforeEach(async (to, _from) => {
|
||||
const userStore = useUserStore()
|
||||
const isLoggedIn = !!userStore.token
|
||||
const isRealNameVerified = userStore.userInfo?.real_check === 3
|
||||
const isRealNameVerified = userStore.userInfo?.real_check !== 1
|
||||
|
||||
console.log('dynamicRoutesReady', userStore.userInfo)
|
||||
console.log('isLoggedIn', isLoggedIn)
|
||||
|
|
@ -129,27 +129,40 @@ router.beforeEach(async (to, _from) => {
|
|||
}
|
||||
}
|
||||
|
||||
// 3. 已登录但未完成实名认证 → 跳转到实名认证页面
|
||||
// 白名单:实名认证页面、活体认证页面、登录/注册页
|
||||
const authPages = ['/realName', '/livenessVerification', '/user/login', '/user/register', '/user/forgot-password']
|
||||
const isAuthPage = authPages.some(path => to.path.startsWith(path))
|
||||
|
||||
if (isLoggedIn && !isRealNameVerified && !isAuthPage) {
|
||||
// 已登录但未认证,访问非认证页面时重定向到实名认证
|
||||
return '/realName'
|
||||
// 3. 白名单页面(实名认证、活体认证、登录/注册相关页面)
|
||||
// 这些页面即使未实名认证也可以访问
|
||||
const whiteList = [
|
||||
'/realName',
|
||||
'/livenessVerification',
|
||||
'/user/login',
|
||||
'/user/register',
|
||||
'/user/forgot-password',
|
||||
]
|
||||
const isWhiteListPage = whiteList.some((path) => to.path === path)
|
||||
|
||||
// 4. 已登录但未完成实名认证 → 只能访问白名单页面
|
||||
if (isLoggedIn && !isRealNameVerified && !isWhiteListPage) {
|
||||
// 未实名认证访问非白名单页面 → 跳转到登录页
|
||||
return '/user/login'
|
||||
}
|
||||
|
||||
// 4. 已登录访问登录/注册页 → 首页(如果已认证)或实名认证页(如果未认证)
|
||||
// 5. 已登录访问登录页(从认证页面退出)→ 允许
|
||||
if (isLoggedIn && !isRealNameVerified && to.path === '/user/login') {
|
||||
// 未认证用户主动跳转到登录页(用于退出登录),允许放行
|
||||
return true
|
||||
}
|
||||
|
||||
// 6. 已登录访问登录/注册页 → 首页(如果已认证)或实名认证页(如果未认证)
|
||||
if (isLoggedIn && to.meta.isAuthPage) {
|
||||
return isRealNameVerified ? '/' : '/realName'
|
||||
}
|
||||
|
||||
// 5. 已完成认证的用户访问实名认证或活体认证页 → 首页
|
||||
if (isLoggedIn && isRealNameVerified && (to.path === '/realName' || to.path === '/livenessVerification')) {
|
||||
// 7. 已完成认证的用户访问实名认证或活体认证页 → 首页
|
||||
if (isLoggedIn && isRealNameVerified && isWhiteListPage && (to.path === '/realName' || to.path === '/livenessVerification')) {
|
||||
return '/'
|
||||
}
|
||||
|
||||
// 6. 其他情况正常放行
|
||||
// 8. 其他情况正常放行
|
||||
return true
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -214,5 +214,6 @@ export const useUserStore = defineStore('user', () => {
|
|||
sendCode,
|
||||
switchAccount,
|
||||
updateUserInfo,
|
||||
clearUserInfo,
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -218,6 +218,7 @@ import {
|
|||
Close,
|
||||
} from '@element-plus/icons-vue'
|
||||
import { uploadCard } from '@/api/modules/livenessVerification'
|
||||
import { useUserStore } from '@/stores/modules/user'
|
||||
|
||||
/* ==================== 类型定义 ==================== */
|
||||
|
||||
|
|
@ -529,6 +530,11 @@ const handleSubmit = async (): Promise<void> => {
|
|||
|
||||
/** 返回上一页 */
|
||||
const goBack = (): void => {
|
||||
const userStore = useUserStore()
|
||||
// real_check === 1 表示未认证状态,real_check !== 1 表示已认证
|
||||
const isRealNameVerified = userStore.userInfo?.real_check !== 1
|
||||
console.log('real_check value:', userStore.userInfo?.real_check, 'isRealNameVerified:', isRealNameVerified)
|
||||
|
||||
if (form.frontImage || form.backImage) {
|
||||
ElMessageBox.confirm('退出将丢失已上传的照片,是否继续?', '提示', {
|
||||
confirmButtonText: '退出',
|
||||
|
|
@ -539,11 +545,28 @@ const goBack = (): void => {
|
|||
// 清理预览 URL
|
||||
if (form.frontPreview) URL.revokeObjectURL(form.frontPreview)
|
||||
if (form.backPreview) URL.revokeObjectURL(form.backPreview)
|
||||
router.back()
|
||||
|
||||
if (isRealNameVerified) {
|
||||
console.log('已认证用户可以返回上一页')
|
||||
// 已认证用户可以返回上一页
|
||||
router.back()
|
||||
} else {
|
||||
// 未认证用户跳转到登录页
|
||||
console.log('未实名验证只能去登录页')
|
||||
router.push('/user/login')
|
||||
}
|
||||
})
|
||||
.catch(() => {})
|
||||
.catch(() => { })
|
||||
} else {
|
||||
router.back()
|
||||
if (isRealNameVerified) {
|
||||
console.log('已认证用户可以返回上一页')
|
||||
// 已认证用户可以返回上一页
|
||||
router.back()
|
||||
} else {
|
||||
// 未认证用户跳转到登录页
|
||||
console.log('未实名验证只能去登录页')
|
||||
router.push('/user/login')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
@ -646,6 +669,7 @@ const goBack = (): void => {
|
|||
background: var(--el-color-primary);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
span {
|
||||
color: var(--el-color-primary);
|
||||
font-weight: 500;
|
||||
|
|
@ -823,11 +847,13 @@ const goBack = (): void => {
|
|||
}
|
||||
|
||||
@keyframes pulse {
|
||||
|
||||
0%,
|
||||
100% {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: scale(1.1);
|
||||
opacity: 0.6;
|
||||
|
|
@ -997,6 +1023,7 @@ const goBack = (): void => {
|
|||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue