diff --git a/src/api/platformData.js b/src/api/platformData.js
index 7721f2f..8bcd80f 100644
--- a/src/api/platformData.js
+++ b/src/api/platformData.js
@@ -86,6 +86,29 @@ export function getUserLoginList(params) {
})
}
+// 获取今日登录数据(渠道分布)
+export function getUserLoginChannel(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/channel',
+ method: 'post',
+ headers: {
+ 'token': localStorage.getItem('token'),
+ 'client': 'ios',
+ 'version': '1',
+ 'Content-Type': 'multipart/form-data'
+ },
+ data: formData
+ })
+}
+
// 获取用户登录趋势数据
export function getUserLoginTrend(params) {
const formData = new FormData();
diff --git a/src/views/PlatformData/UserLoginStats.vue b/src/views/PlatformData/UserLoginStats.vue
index 5504e3e..f813e6f 100644
--- a/src/views/PlatformData/UserLoginStats.vue
+++ b/src/views/PlatformData/UserLoginStats.vue
@@ -98,10 +98,10 @@
-
今日登录数据
+
{{ statsTitle }}登录数据
-
+
@@ -223,7 +223,7 @@
import { ref, onMounted, nextTick, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import * as echarts from 'echarts';
-import { getUserLoginList, getUserLoginTrend, getRegionActiveData, getRegionActiveDataHistogram } from '../../api/platformData';
+import { getUserLoginList, getUserLoginTrend, getRegionActiveData, getRegionActiveDataHistogram, getUserLoginChannel } from '../../api/platformData';
const route = useRoute();
const router = useRouter();
@@ -405,6 +405,37 @@ const updateTrendChart = (list) => {
chartTrendInstance.setOption(option);
};
+const fetchLoginChannelData = async () => {
+ let params = {};
+ if (dateRange.value && dateRange.value.length === 2) {
+ params.start_time = formatDate(dateRange.value[0]);
+ params.end_time = formatDate(dateRange.value[1]);
+ }
+
+ if (selectedRegion.value && selectedRegion.value !== 'all') {
+ params.region = selectedRegion.value;
+ }
+
+ try {
+ const res = await getUserLoginChannel(params);
+ console.log("获取今日登录渠道数据响应:", res);
+
+ // 兼容处理拦截器
+ const data = res.list ? res : (res.data && res.data.list ? res.data : null);
+
+ if (data && data.list) {
+ loginTableData1.value = data.list.map(item => ({
+ channel: item.source,
+ total: item.today_count,
+ dailyNew: item.growth_value,
+ percent: item.ratio + '%'
+ }));
+ }
+ } catch (e) {
+ console.error('获取今日登录渠道数据失败:', e);
+ }
+};
+
const handleSearch = () => {
// 更新 URL 参数
const query = { ...route.query };
@@ -442,6 +473,7 @@ const handleReset = () => {
fetchTrendData();
fetchLoginData();
+ fetchLoginChannelData();
};
const fetchRegionActiveData = async () => {
@@ -649,13 +681,7 @@ const handleResetRegion = () => {
};
// Tab 1 数据
-const loginTableData1 = [
- { channel: 'App Store', total: '154,832', dailyNew: '', percent: '38%' },
- { channel: 'Play Store', total: '42,567', dailyNew: '', percent: '30%' },
- { channel: 'H5', total: '112,265', dailyNew: '', percent: '17%' },
- { channel: 'APK', total: '68,420', dailyNew: '', percent: '10%' },
- { channel: '总计', total: '68,420', dailyNew: '', percent: '100%' },
-];
+const loginTableData1 = ref([]);
const loginTableData2 = [
{ channel: 'App Store', total: '1,245', dailyNew: '', rate: '38%' },
@@ -805,6 +831,7 @@ watch(activeTab, (newVal) => {
onMounted(() => {
if (activeTab.value === 'loginData') {
fetchLoginData();
+ fetchLoginChannelData();
}
initCharts();
});