Browse Source

对接用户类登录统计-登录数据-今日登录数据接口完成;

zhaowenkang/feature-20260206140254-后台AI复盘二期
songjie 1 month ago
parent
commit
3bbcea42fb
  1. 23
      src/api/platformData.js
  2. 47
      src/views/PlatformData/UserLoginStats.vue

23
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();

47
src/views/PlatformData/UserLoginStats.vue

@ -98,10 +98,10 @@
<!-- 表格1: 今日登录数据 -->
<div class="detail-section">
<div class="section-title"><el-icon><DataLine /></el-icon> </div>
<div class="section-title"><el-icon><DataLine /></el-icon> {{ statsTitle }}</div>
<el-table :data="loginTableData1" style="width: 100%" :header-cell-style="headerCellStyle">
<el-table-column prop="channel" label="来源渠道" />
<el-table-column prop="total" label="今日登录总数" />
<el-table-column prop="total" :label="statsTitle + '登录总数'" />
<el-table-column prop="dailyNew" label="较昨日新增" />
<el-table-column prop="percent" label="占比" />
</el-table>
@ -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();
});

Loading…
Cancel
Save