diff --git a/.env.development b/.env.development index 74b4618..8686c0c 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,3 @@ # 开发环境配置 VITE_API_BASE_URL=/api -VITE_UPLOAD_BASE_URL=http://localhost:3001/api/upload \ No newline at end of file +VITE_UPLOAD_BASE_URL=http://localhost:3000/api/upload \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 2224fbb..78ad576 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,12 +10,14 @@ "dependencies": { "@element-plus/icons-vue": "^2.3.1", "axios": "^1.6.2", + "echarts": "^5.6.0", "element-plus": "^2.4.4", "nprogress": "^0.2.0", "pinia": "^2.1.7", "swiper": "^8.4.7", "vue": "^3.3.11", "vue-awesome-swiper": "^5.0.1", + "vue-echarts": "^7.0.3", "vue-router": "^4.2.5" }, "devDependencies": { @@ -1453,6 +1455,22 @@ "node": ">= 0.4" } }, + "node_modules/echarts": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/echarts/-/echarts-5.6.0.tgz", + "integrity": "sha512-oTbVTsXfKuEhxftHqL5xprgLoc0k7uScAwtryCgWF6hPYFLRwOUHiFmHGCBKP5NPFNkDVopOieyUqYGH8Fa3kA==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "2.3.0", + "zrender": "5.6.1" + } + }, + "node_modules/echarts/node_modules/tslib": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", + "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==", + "license": "0BSD" + }, "node_modules/element-plus": { "version": "2.10.3", "resolved": "https://registry.npmjs.org/element-plus/-/element-plus-2.10.3.tgz", @@ -2620,6 +2638,51 @@ } } }, + "node_modules/vue-echarts": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/vue-echarts/-/vue-echarts-7.0.3.tgz", + "integrity": "sha512-/jSxNwOsw5+dYAUcwSfkLwKPuzTQ0Cepz1LxCOpj2QcHrrmUa/Ql0eQqMmc1rTPQVrh2JQ29n2dhq75ZcHvRDw==", + "license": "MIT", + "dependencies": { + "vue-demi": "^0.13.11" + }, + "peerDependencies": { + "@vue/runtime-core": "^3.0.0", + "echarts": "^5.5.1", + "vue": "^2.7.0 || ^3.1.1" + }, + "peerDependenciesMeta": { + "@vue/runtime-core": { + "optional": true + } + } + }, + "node_modules/vue-echarts/node_modules/vue-demi": { + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.13.11.tgz", + "integrity": "sha512-IR8HoEEGM65YY3ZJYAjMlKygDQn25D5ajNFNoKh9RSDMQtlzCxtfQjdQgv9jjK+m3377SsJXY8ysq8kLCZL25A==", + "hasInstallScript": true, + "license": "MIT", + "bin": { + "vue-demi-fix": "bin/vue-demi-fix.js", + "vue-demi-switch": "bin/vue-demi-switch.js" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@vue/composition-api": "^1.0.0-rc.1", + "vue": "^3.0.0-0 || ^2.6.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + } + }, "node_modules/vue-router": { "version": "4.5.1", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.5.1.tgz", @@ -2634,6 +2697,21 @@ "peerDependencies": { "vue": "^3.2.0" } + }, + "node_modules/zrender": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/zrender/-/zrender-5.6.1.tgz", + "integrity": "sha512-OFXkDJKcrlx5su2XbzJvj/34Q3m6PvyCZkVPHGYpcCJ52ek4U/ymZyfuV1nKE23AyBJ51E/6Yr0mhZ7xGTO4ag==", + "license": "BSD-3-Clause", + "dependencies": { + "tslib": "2.3.0" + } + }, + "node_modules/zrender/node_modules/tslib": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", + "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==", + "license": "0BSD" } } } diff --git a/package.json b/package.json index fe6363e..4e773bf 100644 --- a/package.json +++ b/package.json @@ -11,12 +11,14 @@ "dependencies": { "@element-plus/icons-vue": "^2.3.1", "axios": "^1.6.2", + "echarts": "^5.6.0", "element-plus": "^2.4.4", "nprogress": "^0.2.0", "pinia": "^2.1.7", "swiper": "^8.4.7", "vue": "^3.3.11", "vue-awesome-swiper": "^5.0.1", + "vue-echarts": "^7.0.3", "vue-router": "^4.2.5" }, "devDependencies": { diff --git a/src/router/index.js b/src/router/index.js index b8d9eff..69975ee 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -198,7 +198,19 @@ const routes = [ name: 'AgentDashboard', component: () => import('@/views/AgentDashboard.vue'), meta: { - title: '代理后台' + title: '代理后台', + requiresAuth: true, + isAgent: true + } + }, + { + path: '/agent/withdrawals', + name: 'AgentWithdrawals', + component: () => import('@/views/AgentWithdrawals.vue'), + meta: { + title: '佣金提现', + requiresAuth: true, + isAgent: true } }, { @@ -252,17 +264,33 @@ router.beforeEach(async (to, from, next) => { // 检查是否需要认证 if (to.meta.requiresAuth) { - if (!userStore.isAuthenticated) { - // 尝试从本地存储恢复登录状态 - await userStore.checkAuth() + // 检查是否是代理页面 + if (to.meta.isAgent) { + // 代理页面认证逻辑 + const agentInfo = localStorage.getItem('agentInfo') + const agentToken = localStorage.getItem('token') - if (!userStore.isAuthenticated) { + if (!agentInfo || !agentToken) { next({ - name: 'MyLogin', + path: '/agent/login', query: { redirect: to.fullPath } }) return } + } else { + // 普通用户页面认证逻辑 + if (!userStore.isAuthenticated) { + // 尝试从本地存储恢复登录状态 + await userStore.checkAuth() + + if (!userStore.isAuthenticated) { + next({ + name: 'MyLogin', + query: { redirect: to.fullPath } + }) + return + } + } } } diff --git a/src/utils/api.js b/src/utils/api.js index 45851b9..cc933d5 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -64,11 +64,20 @@ api.interceptors.response.use( switch (status) { case 401: - // 未授权,清除token并跳转到登录页 + // 未授权,清除token并根据当前路由跳转到相应的登录页 localStorage.removeItem('token') + localStorage.removeItem('agentInfo') // 清除代理信息 delete api.defaults.headers.common['Authorization'] - router.push({ name: 'Login' }) - ElMessage.error('登录已过期,请重新登录') + + // 判断当前是否在代理相关页面 + const currentPath = router.currentRoute.value.path + if (currentPath.startsWith('/agent')) { + router.push('/agent/login') + ElMessage.error('代理登录已过期,请重新登录') + } else { + router.push({ name: 'Login' }) + ElMessage.error('登录已过期,请重新登录') + } break case 403: diff --git a/src/views/AgentDashboard.vue b/src/views/AgentDashboard.vue index 87c9d75..5a23330 100644 --- a/src/views/AgentDashboard.vue +++ b/src/views/AgentDashboard.vue @@ -4,46 +4,132 @@
-

{{ agentInfo?.real_name }} - {{ agentInfo?.city_name }}{{ agentInfo?.district_name }}代理

-

手机号:{{ agentInfo?.phone }}

+
+ +
+
+

{{ agentInfo?.real_name }}

+

{{ agentInfo?.city_name }}{{ agentInfo?.district_name }}代理

+ {{ agentInfo?.phone }} +
- 退出登录 +
- -
- -
-
-
- -
-
-
{{ stats.total_merchants || 0 }}
-
招募商户
-
已审核:{{ stats.approved_merchants || 0 }}
-
+ +
+
+
+

今日概览

+
- -
-
- +
+
+
+ +
+
+
{{ stats.total_merchants || 0 }}
+
总商户
+
+{{ stats.weekly_new_merchants || 0 }} 本周新增
+
-
-
¥{{ (Number(stats.total_commission) || 0).toFixed(2) }}
-
总佣金
-
已到账:¥{{ (Number(stats.paid_commission) || 0).toFixed(2) }}
+ +
+
+ +
+
+
¥{{ (Number(stats.total_commission) || 0).toFixed(2) }}
+
总佣金
+
¥{{ (Number(stats.monthly_commission) || 0).toFixed(2) }} 本月
+
+
+ +
+
+ +
+
+
¥{{ (Number(stats.daily_commission) || 0).toFixed(2) }}
+
今日佣金
+
{{ stats.daily_commission_records || 0 }} 笔记录
+
+
+ +
+
+