微信支付
This commit is contained in:
@@ -137,7 +137,7 @@ const routes = [
|
||||
component: () => import('@/views/Payment.vue'),
|
||||
meta: {
|
||||
title: '支付激活',
|
||||
requiresAuth: true
|
||||
requiresAuth: true
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -248,37 +248,37 @@ const routes = [
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/buydetail',
|
||||
name: 'BuyDetail',
|
||||
component: () => import('../views/BuyDetails.vue'),
|
||||
meta: { title: '确认订单' }
|
||||
},
|
||||
{
|
||||
path: '/pay/:orderId',
|
||||
name: 'Pay',
|
||||
component: () => import('@/views/Pay.vue'),
|
||||
meta: { title: '确认支付' },
|
||||
props: route => ({ orderId: route.query.orderId })
|
||||
},
|
||||
{
|
||||
path: '/cart',
|
||||
name: 'Cart',
|
||||
component: () => import('@/views/Cart.vue'),
|
||||
meta: { title: '购物车' }
|
||||
},
|
||||
{
|
||||
path: '/address',
|
||||
name: 'Address',
|
||||
component: () => import('@/views/Address.vue'),
|
||||
meta: { title: '地址管理', requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/payloading',
|
||||
name: 'PayLoading',
|
||||
component: () => import('@/views/PayLoading.vue'),
|
||||
meta: { title: '支付确认' },
|
||||
props: route => ({ orderId: route.query.orderId })
|
||||
},
|
||||
path: '/buydetail',
|
||||
name: 'BuyDetail',
|
||||
component: () => import('../views/BuyDetails.vue'),
|
||||
meta: { title: '确认订单' }
|
||||
},
|
||||
{
|
||||
path: '/pay/:orderId',
|
||||
name: 'Pay',
|
||||
component: () => import('@/views/Pay.vue'),
|
||||
meta: { title: '确认支付' },
|
||||
props: route => ({ orderId: route.query.orderId })
|
||||
},
|
||||
{
|
||||
path: '/cart',
|
||||
name: 'Cart',
|
||||
component: () => import('@/views/Cart.vue'),
|
||||
meta: { title: '购物车' }
|
||||
},
|
||||
{
|
||||
path: '/address',
|
||||
name: 'Address',
|
||||
component: () => import('@/views/Address.vue'),
|
||||
meta: { title: '地址管理', requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/payloading',
|
||||
name: 'PayLoading',
|
||||
component: () => import('@/views/PayLoading.vue'),
|
||||
meta: { title: '支付确认' },
|
||||
props: route => ({ orderId: route.query.orderId })
|
||||
},
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
name: 'NotFound',
|
||||
@@ -304,19 +304,19 @@ const router = createRouter({
|
||||
// 路由守卫
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
NProgress.start()
|
||||
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
|
||||
// 设置页面标题
|
||||
if (to.meta.title) {
|
||||
document.title = `${to.meta.title} - 炬融圈`
|
||||
}
|
||||
|
||||
|
||||
// 检查维护模式
|
||||
try {
|
||||
const {data} = await api.get('/system/maintenance-status', { showLoading: false })
|
||||
console.log(data,'data');
|
||||
|
||||
const { data } = await api.get('/system/maintenance-status', { showLoading: false })
|
||||
console.log(data, 'data');
|
||||
|
||||
if (data.success) {
|
||||
if (data.data.maintenance_mode) {
|
||||
// 维护模式开启,且不在维护页面,跳转到维护页面
|
||||
@@ -336,7 +336,7 @@ router.beforeEach(async (to, from, next) => {
|
||||
// 如果检查维护状态失败,继续正常流程
|
||||
console.warn('检查维护状态失败:', error)
|
||||
}
|
||||
|
||||
|
||||
// 检查是否需要认证
|
||||
if (to.meta.requiresAuth) {
|
||||
// 检查是否是代理页面
|
||||
@@ -344,10 +344,10 @@ router.beforeEach(async (to, from, next) => {
|
||||
// 代理页面认证逻辑
|
||||
const agentInfo = localStorage.getItem('agentInfo')
|
||||
const agentToken = localStorage.getItem('token')
|
||||
|
||||
|
||||
if (!agentInfo || !agentToken) {
|
||||
next({
|
||||
path: '/agent/login',
|
||||
path: '/mylogin',
|
||||
query: { redirect: to.fullPath }
|
||||
})
|
||||
return
|
||||
@@ -357,7 +357,7 @@ router.beforeEach(async (to, from, next) => {
|
||||
if (!userStore.isAuthenticated) {
|
||||
// 尝试从本地存储恢复登录状态
|
||||
await userStore.checkAuth()
|
||||
|
||||
|
||||
if (!userStore.isAuthenticated) {
|
||||
next({
|
||||
name: 'MyLogin',
|
||||
@@ -366,9 +366,13 @@ router.beforeEach(async (to, from, next) => {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 检查支付状态(管理员除外)
|
||||
console.log(userStore.user);
|
||||
|
||||
if (userStore.user && userStore.user.role !== 'admin' && userStore.user.payment_status === 'unpaid') {
|
||||
console.log('进来了');
|
||||
|
||||
// 如果当前不在支付页面,静默重定向到支付页面(不显示额外通知)
|
||||
if (to.name !== 'Payment') {
|
||||
next({
|
||||
@@ -376,17 +380,19 @@ router.beforeEach(async (to, from, next) => {
|
||||
query: { redirect: to.fullPath }
|
||||
})
|
||||
return
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 如果已登录用户访问登录/注册页面,重定向到转账管理(改成了主页)
|
||||
if (to.meta.hideForAuth && userStore.isAuthenticated) {
|
||||
next({ name: 'MainPage' })
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
next()
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user