feat: 添加路由拦截逻辑 - 用户登录后需完成实名认证才能访问其他页面
This commit is contained in:
parent
3e49edfba4
commit
5b8907cac1
|
|
@ -52,10 +52,7 @@ export interface EditUsernameParams {
|
||||||
|
|
||||||
// 验证码修改密码参数类型
|
// 验证码修改密码参数类型
|
||||||
export interface UpdatePwdByCaptchaParams {
|
export interface UpdatePwdByCaptchaParams {
|
||||||
reg_type: number
|
verify_type: number
|
||||||
email?: string
|
|
||||||
mobile?: string
|
|
||||||
mobile_area?: string
|
|
||||||
code: string
|
code: string
|
||||||
login_password1: string
|
login_password1: string
|
||||||
login_password2: string
|
login_password2: string
|
||||||
|
|
|
||||||
|
|
@ -27,17 +27,14 @@ export interface RegisterParams {
|
||||||
//忘记密码参数类型
|
//忘记密码参数类型
|
||||||
export interface ForgotPasswordParams {
|
export interface ForgotPasswordParams {
|
||||||
mobile?: string // 手机号(可选)
|
mobile?: string // 手机号(可选)
|
||||||
email?: string // 邮箱(可选)
|
email?: string // 邮箱(可选)
|
||||||
reg_type: number // 1-邮箱登录 2-手机登录
|
|
||||||
code: string
|
code: string
|
||||||
login_password1: string
|
login_password1: string
|
||||||
login_password2: string
|
login_password2: string
|
||||||
}
|
}
|
||||||
// 修改密码参数类型
|
// 修改密码参数类型
|
||||||
export interface ChangePasswordParams {
|
export interface ChangePasswordParams {
|
||||||
mobile?: string // 手机号(可选)
|
verify_type: number // 1-邮箱登录 2-手机登录
|
||||||
email?: string // 邮箱(可选)
|
|
||||||
reg_type: number // 1-邮箱登录 2-手机登录
|
|
||||||
code: string
|
code: string
|
||||||
login_password1: string
|
login_password1: string
|
||||||
login_password2: string
|
login_password2: string
|
||||||
|
|
@ -45,7 +42,6 @@ export interface ChangePasswordParams {
|
||||||
// 发送验证码参数类型
|
// 发送验证码参数类型
|
||||||
export interface SendCodeParams {
|
export interface SendCodeParams {
|
||||||
mobile?: string // 手机号(可选)
|
mobile?: string // 手机号(可选)
|
||||||
email?: string // 邮箱(可选)
|
email?: string // 邮箱(可选)
|
||||||
reg_type: number // 1-邮箱登录 2-手机登录
|
|
||||||
type: string // 验证码类型
|
type: string // 验证码类型
|
||||||
}
|
}
|
||||||
|
|
@ -102,9 +102,11 @@ let dynamicRoutesReady = false
|
||||||
router.beforeEach(async (to, _from) => {
|
router.beforeEach(async (to, _from) => {
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const isLoggedIn = !!userStore.token
|
const isLoggedIn = !!userStore.token
|
||||||
|
const isRealNameVerified = userStore.userInfo?.real_check === 3
|
||||||
|
|
||||||
console.log('dynamicRoutesReady', dynamicRoutesReady)
|
console.log('dynamicRoutesReady', userStore.userInfo)
|
||||||
console.log('isLoggedIn', isLoggedIn)
|
console.log('isLoggedIn', isLoggedIn)
|
||||||
|
console.log('isRealNameVerified', isRealNameVerified)
|
||||||
console.log('to.meta.requiresAuth', to.meta.requiresAuth)
|
console.log('to.meta.requiresAuth', to.meta.requiresAuth)
|
||||||
console.log('to.meta.isAuthPage', to.meta.isAuthPage)
|
console.log('to.meta.isAuthPage', to.meta.isAuthPage)
|
||||||
|
|
||||||
|
|
@ -127,12 +129,27 @@ router.beforeEach(async (to, _from) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 已登录访问登录/注册页 → 首页
|
// 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'
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 已登录访问登录/注册页 → 首页(如果已认证)或实名认证页(如果未认证)
|
||||||
if (isLoggedIn && to.meta.isAuthPage) {
|
if (isLoggedIn && to.meta.isAuthPage) {
|
||||||
|
return isRealNameVerified ? '/' : '/realName'
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 已完成认证的用户访问实名认证或活体认证页 → 首页
|
||||||
|
if (isLoggedIn && isRealNameVerified && (to.path === '/realName' || to.path === '/livenessVerification')) {
|
||||||
return '/'
|
return '/'
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 其他情况正常放行
|
// 6. 其他情况正常放行
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,21 +3,37 @@ export const search = [
|
||||||
{ prop: 'accountName', label: '账号名称', type: 'input' as const, placeholder: '请输入账号名称', width: '150px' },
|
{ prop: 'accountName', label: '账号名称', type: 'input' as const, placeholder: '请输入账号名称', width: '150px' },
|
||||||
// 开始时间
|
// 开始时间
|
||||||
{
|
{
|
||||||
prop: "startTime", label: '注册开始时间', type: 'date' as const, dateType: 'date' as const,placeholder: '请选择注册开始时间', width: '270px', // 时间范围选择器
|
prop: "startTime", label: '注册开始时间', type: 'date' as const, dateType: 'date' as const, placeholder: '请选择注册开始时间', width: '270px', // 时间范围选择器
|
||||||
valueFormat: 'YYYY-MM-DD',
|
valueFormat: 'YYYY-MM-DD',
|
||||||
},
|
},
|
||||||
// 结束时间
|
// 结束时间
|
||||||
{
|
{
|
||||||
prop: "endTime", label: '注册结束时间', type: 'date' as const, dateType: 'date' as const,placeholder: '请选择注册结束时间', width: '270px', // 时间范围选择器
|
prop: "endTime", label: '注册结束时间', type: 'date' as const, dateType: 'date' as const, placeholder: '请选择注册结束时间', width: '270px', // 时间范围选择器
|
||||||
valueFormat: 'YYYY-MM-DD',
|
valueFormat: 'YYYY-MM-DD',
|
||||||
},
|
},
|
||||||
// 状态
|
// 状态
|
||||||
{ prop: 'status', label: '状态', type: 'select' as const, placeholder: '请选择状态', width: 100},
|
// {
|
||||||
|
// prop: 'status',
|
||||||
|
// label: '状态',
|
||||||
|
// type: 'select' as const,
|
||||||
|
// options: [
|
||||||
|
// {
|
||||||
|
// label: '正常',
|
||||||
|
// value: '1'
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// label: '封禁',
|
||||||
|
// value: '2'
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// placeholder: '请选择状态',
|
||||||
|
// width: '100px'
|
||||||
|
// },
|
||||||
]
|
]
|
||||||
|
|
||||||
export const tableColumns = [
|
export const tableColumns = [
|
||||||
// 账号名称
|
// 账号名称
|
||||||
{ label: '账号名称', prop: 'accountName', },
|
{ label: '账号名称', prop: 'accountName', },
|
||||||
// 账号id
|
// 账号id
|
||||||
{ prop: 'userId', label: '账号id' },
|
{ prop: 'userId', label: '账号id' },
|
||||||
// 状态
|
// 状态
|
||||||
|
|
@ -27,34 +43,34 @@ export const tableColumns = [
|
||||||
// 账号数量
|
// 账号数量
|
||||||
{ prop: 'accountQty', label: '账号数量', width: 100 },
|
{ prop: 'accountQty', label: '账号数量', width: 100 },
|
||||||
// 点差分配比例
|
// 点差分配比例
|
||||||
{ prop: 'marginRatio', label: '点差分配比例', slotName: 'marginRatio' , width: 140},
|
{ prop: 'marginRatio', label: '点差分配比例', slotName: 'marginRatio', width: 140 },
|
||||||
// 手续费分成比例
|
// 手续费分成比例
|
||||||
{ prop: 'commissionRatio', label: '手续费分成比例', slotName: 'commissionRatio' , width: 140},
|
{ prop: 'commissionRatio', label: '手续费分成比例', slotName: 'commissionRatio', width: 140 },
|
||||||
// 注册时间
|
// 注册时间
|
||||||
{ prop: 'createTime', label: '注册时间', sortable: true , minWidth: 180},
|
{ prop: 'createTime', label: '注册时间', sortable: true, minWidth: 180 },
|
||||||
// 操作
|
// 操作
|
||||||
{ label: '操作', slotName: 'action', width: 200}
|
{ label: '操作', slotName: 'action', width: 200 }
|
||||||
]
|
]
|
||||||
|
|
||||||
// 点差表格配置
|
// 点差表格配置
|
||||||
export const marginRatioTableColumns = [
|
export const marginRatioTableColumns = [
|
||||||
// 品种名称
|
// 品种名称
|
||||||
{ prop: 'varietyName', label: '名称', align: 'center' as const },
|
{ prop: 'varietyName', label: '名称', align: 'center' as const },
|
||||||
// 品种编号
|
// 品种编号
|
||||||
{ prop: 'varietyCode', label: '编号', align: 'center' as const },
|
{ prop: 'varietyCode', label: '编号', align: 'center' as const },
|
||||||
// 可分配点差
|
// 可分配点差
|
||||||
{ prop: 'pointDifference', label: '可分配点差', align: 'center' as const },
|
{ prop: 'pointDifference', label: '可分配点差', align: 'center' as const },
|
||||||
// 已分配点差
|
// 已分配点差
|
||||||
{
|
{
|
||||||
prop: 'assignedPointDifference',
|
prop: 'assignedPointDifference',
|
||||||
label: '已分配点差',
|
label: '已分配点差',
|
||||||
align: 'center' as const,
|
align: 'center' as const,
|
||||||
slotName: 'assignedPointDiff',
|
slotName: 'assignedPointDiff',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
// 手续费分成比例form配置
|
// 手续费分成比例form配置
|
||||||
export const commissionRatioFormItem = [
|
export const commissionRatioFormItem = [
|
||||||
// 手续费分成比例
|
// 手续费分成比例
|
||||||
{ prop: 'commissionRatio', label: '手续费分成比例', type: 'input' as const, placeholder: '请输入手续费分成比例',labelWidth: '140px'},
|
{ prop: 'commissionRatio', label: '手续费分成比例', type: 'input' as const, placeholder: '请输入手续费分成比例', labelWidth: '140px' },
|
||||||
]
|
]
|
||||||
|
|
@ -289,7 +289,6 @@ const sendCodeApi = async (receiver: string) => {
|
||||||
// 发送验证码参数
|
// 发送验证码参数
|
||||||
const type = verifyForm.value.verifyType
|
const type = verifyForm.value.verifyType
|
||||||
const params: any = {
|
const params: any = {
|
||||||
reg_type: userStore.userInfo!.reg_type,
|
|
||||||
type: 'transfer_code',
|
type: 'transfer_code',
|
||||||
}
|
}
|
||||||
if (type === 'email') {
|
if (type === 'email') {
|
||||||
|
|
|
||||||
|
|
@ -524,9 +524,7 @@ const handlePasswordConfirm = async () => {
|
||||||
await passwordFormRef.value.validate();
|
await passwordFormRef.value.validate();
|
||||||
|
|
||||||
const params: UpdatePwdByCaptchaParams = {
|
const params: UpdatePwdByCaptchaParams = {
|
||||||
reg_type: userStore.userInfo!.reg_type,
|
verify_type: passwordForm.verifyType === 'email'?1:2,
|
||||||
email: passwordForm.verifyType === 'email' ? userInfo.email : undefined,
|
|
||||||
mobile: passwordForm.verifyType === 'mobile' ? userInfo.mobile : undefined,
|
|
||||||
code: passwordForm.code,
|
code: passwordForm.code,
|
||||||
login_password1: passwordForm.login_password1,
|
login_password1: passwordForm.login_password1,
|
||||||
login_password2: passwordForm.login_password2
|
login_password2: passwordForm.login_password2
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ export const clientSearch = [
|
||||||
dateType: 'date' as const, // 时间范围选择器
|
dateType: 'date' as const, // 时间范围选择器
|
||||||
valueFormat: 'YYYY-MM-DD',
|
valueFormat: 'YYYY-MM-DD',
|
||||||
// minWidth: '200px'
|
// minWidth: '200px'
|
||||||
width: '180px',
|
width: '180',
|
||||||
disabledDate
|
disabledDate
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -32,7 +32,7 @@ export const clientSearch = [
|
||||||
dateType: 'date' as const, // 时间范围选择器
|
dateType: 'date' as const, // 时间范围选择器
|
||||||
valueFormat: 'YYYY-MM-DD',
|
valueFormat: 'YYYY-MM-DD',
|
||||||
// minWidth: '200px'
|
// minWidth: '200px'
|
||||||
width: '180px',
|
width: '180',
|
||||||
disabledDate
|
disabledDate
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,6 @@ const sendCodeApi = async () => {
|
||||||
const sendParams = {
|
const sendParams = {
|
||||||
email: changePasswordForm.value.email,
|
email: changePasswordForm.value.email,
|
||||||
mobile: changePasswordForm.value.phone,
|
mobile: changePasswordForm.value.phone,
|
||||||
reg_type: activeTab.value === 'email' ? 1 : 2,
|
|
||||||
type:'resetPass_code'
|
type:'resetPass_code'
|
||||||
}
|
}
|
||||||
return userStore.sendCode(sendParams)
|
return userStore.sendCode(sendParams)
|
||||||
|
|
@ -180,10 +179,8 @@ const handleChangePassword = async () => {
|
||||||
await changePasswordFormRef.value.validate();
|
await changePasswordFormRef.value.validate();
|
||||||
|
|
||||||
// 重置密码参数
|
// 重置密码参数
|
||||||
const changePasswordParams = {
|
const changePasswordParams = {
|
||||||
mobile: changePasswordForm.value.phone,
|
verify_type: activeTab.value === 'email' ? 1 : 2,
|
||||||
email: changePasswordForm.value.email,
|
|
||||||
reg_type: activeTab.value === 'email' ? 1 : 2,
|
|
||||||
code: changePasswordForm.value.code,
|
code: changePasswordForm.value.code,
|
||||||
login_password1: md5Encrypt(changePasswordForm.value.password),
|
login_password1: md5Encrypt(changePasswordForm.value.password),
|
||||||
login_password2: md5Encrypt(changePasswordForm.value.confirmPassword),
|
login_password2: md5Encrypt(changePasswordForm.value.confirmPassword),
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,6 @@ const sendCodeApi = async () => {
|
||||||
const sendParams = {
|
const sendParams = {
|
||||||
email: forgotPasswordForm.value.email,
|
email: forgotPasswordForm.value.email,
|
||||||
mobile: forgotPasswordForm.value.phone,
|
mobile: forgotPasswordForm.value.phone,
|
||||||
reg_type: getStorage('forgotType', 'session') === 'email' ? 1 : 2,
|
|
||||||
type:'transfer_code'
|
type:'transfer_code'
|
||||||
}
|
}
|
||||||
return userStore.sendCode(sendParams)
|
return userStore.sendCode(sendParams)
|
||||||
|
|
@ -273,12 +272,10 @@ const handleForgotPassword = async () => {
|
||||||
// 校验密码+确认密码
|
// 校验密码+确认密码
|
||||||
await forgotPasswordFormRef.value.validateField(['password', 'confirmPassword'])
|
await forgotPasswordFormRef.value.validateField(['password', 'confirmPassword'])
|
||||||
|
|
||||||
// 重置密码参数
|
// 重置密码参数
|
||||||
const getForgotType = getStorage('forgotType', 'session') || 'email'
|
|
||||||
const forgotParams = {
|
const forgotParams = {
|
||||||
mobile: forgotPasswordForm.value.phone,
|
mobile: forgotPasswordForm.value.phone,
|
||||||
email: forgotPasswordForm.value.email,
|
email: forgotPasswordForm.value.email,
|
||||||
reg_type: getForgotType === 'email' ? 1 : 2,
|
|
||||||
code: forgotPasswordForm.value.code,
|
code: forgotPasswordForm.value.code,
|
||||||
// login_password1: md5Encrypt(forgotPasswordForm.value.password),
|
// login_password1: md5Encrypt(forgotPasswordForm.value.password),
|
||||||
// login_password2: md5Encrypt(forgotPasswordForm.value.confirmPassword),
|
// login_password2: md5Encrypt(forgotPasswordForm.value.confirmPassword),
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,6 @@ const sendCodeApi = async () => {
|
||||||
email: registerForm.value.email,
|
email: registerForm.value.email,
|
||||||
mobile: registerForm.value.countryCode + registerForm.value.phone,
|
mobile: registerForm.value.countryCode + registerForm.value.phone,
|
||||||
mobile_area: registerForm.value.countryCode,
|
mobile_area: registerForm.value.countryCode,
|
||||||
reg_type: activeTab.value === 'email' ? 1 : 2,
|
|
||||||
type: 'reg_code',
|
type: 'reg_code',
|
||||||
}
|
}
|
||||||
return userStore.sendCode(sendParams)
|
return userStore.sendCode(sendParams)
|
||||||
|
|
@ -225,6 +224,7 @@ const handleRegister = async () => {
|
||||||
// 注册参数
|
// 注册参数
|
||||||
const registerParams = {
|
const registerParams = {
|
||||||
email: registerForm.value.email,
|
email: registerForm.value.email,
|
||||||
|
mobile_area: registerForm.value.countryCode,
|
||||||
mobile: registerForm.value.countryCode + registerForm.value.phone,
|
mobile: registerForm.value.countryCode + registerForm.value.phone,
|
||||||
reg_type: activeTab.value === 'email' ? 1 : 2,
|
reg_type: activeTab.value === 'email' ? 1 : 2,
|
||||||
invite_code: registerForm.value.inviteCode,
|
invite_code: registerForm.value.inviteCode,
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,6 @@ const sendCodeApi = async () => {
|
||||||
// 发送验证码参数
|
// 发送验证码参数
|
||||||
const sendParams = {
|
const sendParams = {
|
||||||
email: bindEmailForm.value.email,
|
email: bindEmailForm.value.email,
|
||||||
reg_type: 1,
|
|
||||||
type:'resetPass_code'
|
type:'resetPass_code'
|
||||||
}
|
}
|
||||||
return userStore.sendCode(sendParams)
|
return userStore.sendCode(sendParams)
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,6 @@ const sendCodeApi = async () => {
|
||||||
// 发送验证码参数
|
// 发送验证码参数
|
||||||
const sendParams = {
|
const sendParams = {
|
||||||
mobile: bindPhoneForm.value.phone,
|
mobile: bindPhoneForm.value.phone,
|
||||||
reg_type: 2,
|
|
||||||
type: 'resetPass_code'
|
type: 'resetPass_code'
|
||||||
}
|
}
|
||||||
return userStore.sendCode(sendParams)
|
return userStore.sendCode(sendParams)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue