From b0859cac8ae8ebc03d8461e7b3da5e3f0346a6b2 Mon Sep 17 00:00:00 2001 From: songjie Date: Sat, 24 Jan 2026 10:50:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=B1=BB=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E7=9A=84=E7=99=BB=E5=BD=95=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=AF=B9=E6=8E=A5=E5=AE=8C=E6=88=90=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/platformData.js | 23 +++++++++++ src/views/PlatformData/UserLoginStats.vue | 64 +++++++++++++++++++++++++++---- 2 files changed, 80 insertions(+), 7 deletions(-) diff --git a/src/api/platformData.js b/src/api/platformData.js index a07c4ce..55e5e96 100644 --- a/src/api/platformData.js +++ b/src/api/platformData.js @@ -62,3 +62,26 @@ export function exportUserFullReport(params) { responseType: 'blob' // Important for file download }) } + +// 获取用户登录数据列表 +export function getUserLoginList(params) { + const formData = new FormData(); + formData.append('token', localStorage.getItem('token')); + if (params) { + if (params.region) formData.append('region', params.region); + if (params.start_time) formData.append('start_time', params.start_time); + if (params.end_time) formData.append('end_time', params.end_time); + } + + return request({ + url: 'http://7a1b8c9e.r40.cpolar.top/admin/user/login/list', + method: 'post', + headers: { + 'token': localStorage.getItem('token'), + 'client': 'ios', + 'version': '1', + 'Content-Type': 'multipart/form-data' + }, + data: formData + }) +} diff --git a/src/views/PlatformData/UserLoginStats.vue b/src/views/PlatformData/UserLoginStats.vue index 4df03c6..e68f239 100644 --- a/src/views/PlatformData/UserLoginStats.vue +++ b/src/views/PlatformData/UserLoginStats.vue @@ -50,9 +50,9 @@ 今日登录用户数
-
154,838
-
- 较昨日增加↑ 5.22% +
{{ loginStats.total }}
+
+ {{ getGrowthText(loginStats.total_growth) }}
@@ -64,10 +64,12 @@
今日登录会员用户数
-
112,265
+
{{ loginStats.member }}
-
较昨日增加↑ 15.22%
+
+ {{ getGrowthText(loginStats.member_growth) }} +
@@ -77,10 +79,12 @@
今日登录非网用户数
-
42,567
+
{{ loginStats.normal }}
-
较昨日减少↓ 1.22%
+
+ {{ getGrowthText(loginStats.normal_growth) }} +
@@ -219,6 +223,7 @@ import { ref, onMounted, nextTick, watch } from 'vue'; import { useRoute, useRouter } from 'vue-router'; import * as echarts from 'echarts'; +import { getUserLoginList } from '../../api/platformData'; const route = useRoute(); const router = useRouter(); @@ -235,6 +240,48 @@ const chartRegionPieRef = ref(null); const chartRegionMemberPieRef = ref(null); const chartRegionNonMemberPieRef = ref(null); +// 响应式数据:登录数据统计 +const loginStats = ref({ + total: 0, + total_growth: '0%', + member: 0, + member_growth: '0%', + normal: 0, + normal_growth: '0%' +}); + +// 获取增长率的样式类 +const getGrowthClass = (growthStr) => { + if (!growthStr) return ''; + return growthStr.startsWith('-') ? 'down' : 'up'; +}; + +// 获取增长率的显示文本(添加箭头) +const getGrowthText = (growthStr) => { + if (!growthStr) return ''; + const isDown = growthStr.startsWith('-'); + const arrow = isDown ? '↓' : '↑'; + const prefix = isDown ? '较昨日减少' : '较昨日增加'; + const value = growthStr.replace('-', ''); + return `${prefix}${arrow} ${value}`; +}; + +const fetchLoginData = async () => { + try { + const res = await getUserLoginList(); + console.log("获取用户登录数据响应:", res); + + // 兼容处理拦截器 + const data = res.list ? res : (res.data && res.data.list ? res.data : null); + + if (data && data.list) { + loginStats.value = data.list; + } + } catch (e) { + console.error('获取用户登录数据失败:', e); + } +}; + // Tab 1 数据 const loginTableData1 = [ { channel: 'App Store', total: '154,832', dailyNew: '', percent: '38%' }, @@ -428,6 +475,9 @@ watch(activeTab, (newVal) => { }); onMounted(() => { + if (activeTab.value === 'loginData') { + fetchLoginData(); + } initCharts(); });