This commit is contained in:
aaron 2025-03-09 09:37:16 +08:00
parent b07dc4a79d
commit a28ae6063f
2 changed files with 299 additions and 112 deletions

View File

@ -9,14 +9,14 @@ import config from '../utils/config';
* @param {string} data.role - 角色默认为 partner * @param {string} data.role - 角色默认为 partner
* @returns {Promise} - 返回登录结果 * @returns {Promise} - 返回登录结果
*/ */
export function login(data) { export function login(postData) {
return request({ return request({
url: config.API.LOGIN, url: config.API.LOGIN,
method: 'post', method: 'post',
data: { data: {
phone: data.phone, phone: postData.phone,
password: data.password, password: postData.password,
role: data.role || 'partner' role: 'partner'
} }
}); });
} }

View File

@ -1,75 +1,138 @@
<template> <template>
<div class="dashboard"> <div class="dashboard">
<!-- 汇总卡片 -->
<a-row :gutter="16"> <a-row :gutter="16">
<a-col :span="6"> <a-col :span="8" :xs="24" :sm="12" :md="8" :lg="8" :xl="8">
<a-card> <a-card class="card-community">
<template #title> <template #title>
<span><user-outlined /> 用户总</span> <span><home-outlined /> 运营小区</span>
</template> </template>
<div class="card-content"> <div class="card-content">
<h2>1,286</h2> <h2>{{ dashboardData.communityCount }}</h2>
<p>较上周 <a-tag color="green">+12%</a-tag></p> <p>本月新增 <a-tag color="success">+{{ dashboardData.newCommunityCount }}</a-tag></p>
</div> </div>
</a-card> </a-card>
</a-col> </a-col>
<a-col :span="6"> <a-col :span="8" :xs="24" :sm="12" :md="8" :lg="8" :xl="8">
<a-card> <a-card class="card-orders">
<template #title> <template #title>
<span><shopping-outlined /> 订单</span> <span><shopping-outlined /> 总配送订单数</span>
</template> </template>
<div class="card-content"> <div class="card-content">
<h2>4,389</h2> <h2>{{ dashboardData.totalOrders.toLocaleString() }}</h2>
<p>较上周 <a-tag color="green">+8%</a-tag></p> <div class="comparison-data">
<div>
<span>今日</span>
<span class="highlight">{{ dashboardData.todayOrders }}</span>
</div>
<div>
<span>昨日</span>
<span>{{ dashboardData.yesterdayOrders }}</span>
</div>
</div>
</div> </div>
</a-card> </a-card>
</a-col> </a-col>
<a-col :span="6"> <a-col :span="8" :xs="24" :sm="12" :md="8" :lg="8" :xl="8">
<a-card> <a-card class="card-users">
<template #title> <template #title>
<span><dollar-outlined /> 销售额</span> <span><user-outlined /> 总用户数</span>
</template> </template>
<div class="card-content"> <div class="card-content">
<h2>¥ 126,560</h2> <h2>{{ dashboardData.totalUsers.toLocaleString() }}</h2>
<p>较上周 <a-tag color="green">+23%</a-tag></p> <div class="comparison-data">
</div> <div>
</a-card> <span>今日新增</span>
</a-col> <span class="highlight">{{ dashboardData.todayNewUsers }}</span>
<a-col :span="6"> </div>
<a-card> <div>
<template #title> <span>昨日新增</span>
<span><team-outlined /> 新增会员</span> <span>{{ dashboardData.yesterdayNewUsers }}</span>
</template> </div>
<div class="card-content"> </div>
<h2>128</h2>
<p>较上周 <a-tag color="red">-5%</a-tag></p>
</div> </div>
</a-card> </a-card>
</a-col> </a-col>
</a-row> </a-row>
<a-row :gutter="16" style="margin-top: 16px"> <a-row :gutter="16" style="margin-top: 16px">
<a-col :span="16"> <a-col :span="8" :xs="24" :sm="12" :md="8" :lg="8" :xl="8">
<a-card title="销售趋势"> <a-card class="card-sales">
<div style="height: 300px; display: flex; justify-content: center; align-items: center;"> <template #title>
<p>这里将显示销售趋势图表</p> <span><dollar-outlined /> 累计销售金额</span>
</template>
<div class="card-content">
<h2>¥ {{ dashboardData.totalSales.toLocaleString() }}</h2>
<div class="comparison-data">
<div>
<span>今日</span>
<span class="highlight">¥ {{ dashboardData.todaySales.toLocaleString() }}</span>
</div>
<div>
<span>昨日</span>
<span>¥ {{ dashboardData.yesterdaySales.toLocaleString() }}</span>
</div>
</div>
</div> </div>
</a-card> </a-card>
</a-col> </a-col>
<a-col :span="8"> <a-col :span="8" :xs="24" :sm="12" :md="8" :lg="8" :xl="8">
<a-card title="最近活动"> <a-card class="card-profit">
<a-list item-layout="horizontal" :data-source="activities"> <template #title>
<template #renderItem="{ item }"> <span><wallet-outlined /> 累计分润金额</span>
<a-list-item> </template>
<a-list-item-meta> <div class="card-content">
<template #avatar> <h2>¥ {{ dashboardData.totalProfit.toLocaleString() }}</h2>
<a-avatar :src="item.avatar" /> <div class="comparison-data">
</template> <div>
<template #title>{{ item.title }}</template> <span>今日</span>
<template #description>{{ item.description }}</template> <span class="highlight">¥ {{ dashboardData.todayProfit.toLocaleString() }}</span>
</a-list-item-meta> </div>
</a-list-item> <div>
</template> <span>昨日</span>
</a-list> <span>¥ {{ dashboardData.yesterdayProfit.toLocaleString() }}</span>
</div>
</div>
</div>
</a-card>
</a-col>
<a-col :span="8" :xs="24" :sm="12" :md="8" :lg="8" :xl="8">
<a-card class="card-conversion">
<template #title>
<span><rise-outlined /> 订单转化率</span>
</template>
<div class="card-content">
<h2>{{ dashboardData.conversionRate }}%</h2>
<p>较上周 <a-tag :color="dashboardData.conversionRateChange > 0 ? 'success' : 'error'">{{ dashboardData.conversionRateChange > 0 ? '+' : '' }}{{ dashboardData.conversionRateChange }}%</a-tag></p>
</div>
</a-card>
</a-col>
</a-row>
<a-row :gutter="16" style="margin-top: 16px">
<a-col :span="24">
<a-card title="每日分润趋势" class="card-chart">
<div style="height: 350px; padding: 0 20px;">
<a-row style="margin-bottom: 20px;">
<a-col :span="24">
<div class="chart-legend">
<div class="chart-legend-item">
<div class="chart-legend-color" style="background-color: #1890ff;"></div>
<span>分润金额</span>
</div>
</div>
</a-col>
</a-row>
<div class="chart-container">
<div v-for="(item, index) in dashboardData.dailyProfitData" :key="index" class="chart-bar-item">
<div class="chart-bar-value">¥{{ item.value }}</div>
<div class="chart-bar">
<div class="chart-bar-inner" :style="{ height: (item.value / maxProfitValue * 100) + '%' }"></div>
</div>
<div class="chart-bar-label">{{ item.date }}</div>
</div>
</div>
</div>
</a-card> </a-card>
</a-col> </a-col>
</a-row> </a-row>
@ -77,12 +140,14 @@
</template> </template>
<script> <script>
import { ref } from 'vue'; import { ref, reactive, onMounted, computed } from 'vue';
import { import {
UserOutlined, UserOutlined,
ShoppingOutlined, ShoppingOutlined,
DollarOutlined, DollarOutlined,
TeamOutlined HomeOutlined,
WalletOutlined,
RiseOutlined
} from '@ant-design/icons-vue'; } from '@ant-design/icons-vue';
export default { export default {
@ -91,34 +156,68 @@ export default {
UserOutlined, UserOutlined,
ShoppingOutlined, ShoppingOutlined,
DollarOutlined, DollarOutlined,
TeamOutlined HomeOutlined,
WalletOutlined,
RiseOutlined
}, },
setup() { setup() {
const activities = ref([ //
{ const dashboardData = reactive({
title: '张三', //
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png', communityCount: 68,
description: '刚刚完成了一笔订单' newCommunityCount: 5,
},
{ //
title: '李四', totalOrders: 24689,
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png', todayOrders: 386,
description: '刚刚注册成为新用户' yesterdayOrders: 412,
},
{ //
title: '王五', totalUsers: 8756,
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png', todayNewUsers: 42,
description: '提交了一个工单' yesterdayNewUsers: 38,
},
{ //
title: '系统通知', totalSales: 1268950,
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png', todaySales: 28650,
description: '服务器将于今晚23:00进行维护' yesterdaySales: 31280,
}
]); //
totalProfit: 253790,
todayProfit: 5730,
yesterdayProfit: 6256,
//
conversionRate: 32.6,
conversionRateChange: 2.8,
//
dailyProfitData: [
{ date: '6/1', value: 4280 },
{ date: '6/2', value: 5120 },
{ date: '6/3', value: 4830 },
{ date: '6/4', value: 5680 },
{ date: '6/5', value: 6120 },
{ date: '6/6', value: 5890 },
{ date: '6/7', value: 4950 },
{ date: '6/8', value: 5230 },
{ date: '6/9', value: 5780 },
{ date: '6/10', value: 6050 },
{ date: '6/11', value: 5840 },
{ date: '6/12', value: 5320 },
{ date: '6/13', value: 6256 },
{ date: '6/14', value: 5730 }
]
});
//
const maxProfitValue = computed(() => {
return Math.max(...dashboardData.dailyProfitData.map(item => item.value)) * 1.1;
});
return { return {
activities dashboardData,
maxProfitValue
}; };
} }
}; };
@ -136,18 +235,30 @@ export default {
.card-content h2 { .card-content h2 {
font-size: 24px; font-size: 24px;
margin-bottom: 8px; margin-bottom: 8px;
color: #1a1a1a; font-weight: 600;
} }
.card-content p { .card-content p {
margin: 0; margin: 0;
color: rgba(0, 0, 0, 0.45); color: rgba(0, 0, 0, 0.65);
}
.comparison-data {
display: flex;
justify-content: space-around;
color: rgba(0, 0, 0, 0.65);
font-size: 14px;
}
.comparison-data .highlight {
font-weight: 500;
} }
:deep(.ant-card) { :deep(.ant-card) {
border-radius: 8px; border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
transition: all 0.3s; transition: all 0.3s;
margin-bottom: 16px;
} }
:deep(.ant-card:hover) { :deep(.ant-card:hover) {
@ -161,64 +272,140 @@ export default {
:deep(.ant-card-head-title) { :deep(.ant-card-head-title) {
font-weight: 600; font-weight: 600;
color: #1a1a1a;
} }
:deep(.ant-tag.ant-tag-green) { /* 卡片颜色主题 */
color: #1a1a1a; .card-community {
background: rgba(26, 26, 26, 0.1); border-top: 3px solid #722ed1;
border-color: #1a1a1a; }
.card-community h2, .card-community :deep(.anticon) {
color: #722ed1;
} }
:deep(.ant-tag.ant-tag-red) { .card-orders {
color: #ff4d4f; border-top: 3px solid #1890ff;
background: rgba(255, 77, 79, 0.1); }
border-color: #ff4d4f; .card-orders h2, .card-orders :deep(.anticon) {
color: #1890ff;
} }
:deep(.ant-list-item) { .card-users {
padding: 12px 0; border-top: 3px solid #52c41a;
border-bottom: 1px solid #f0f0f0; }
.card-users h2, .card-users :deep(.anticon) {
color: #52c41a;
} }
:deep(.ant-list-item:last-child) { .card-sales {
border-bottom: none; border-top: 3px solid #fa8c16;
}
.card-sales h2, .card-sales :deep(.anticon) {
color: #fa8c16;
} }
:deep(.ant-list-item-meta-title) { .card-profit {
color: #1a1a1a; border-top: 3px solid #eb2f96;
font-weight: 500; }
.card-profit h2, .card-profit :deep(.anticon) {
color: #eb2f96;
} }
:deep(.ant-list-item-meta-description) { .card-conversion {
color: rgba(0, 0, 0, 0.45); border-top: 3px solid #13c2c2;
}
.card-conversion h2, .card-conversion :deep(.anticon) {
color: #13c2c2;
} }
:deep(.ant-avatar) { .card-chart {
background-color: #1a1a1a; border-top: 3px solid #1890ff;
}
.card-chart :deep(.ant-card-head-title) {
color: #1890ff;
} }
/* 链接样式 */ /* 图表样式 */
:deep(a) { .chart-container {
color: #1a1a1a; display: flex;
transition: all 0.3s; justify-content: space-between;
align-items: flex-end;
height: 250px;
} }
:deep(a:hover) { .chart-bar-item {
color: #333333; display: flex;
flex-direction: column;
align-items: center;
width: 100%;
} }
/* 列表项中的链接样式 */ .chart-bar-value {
:deep(.ant-list-item-meta-title a) { font-size: 12px;
color: #1a1a1a; color: #666;
margin-bottom: 4px;
height: 20px;
} }
:deep(.ant-list-item-meta-title a:hover) { .chart-bar {
color: #333333; width: 24px;
height: 200px;
background-color: #f5f5f5;
border-radius: 4px;
position: relative;
overflow: hidden;
} }
/* 图标颜色 */ .chart-bar-inner {
:deep(.anticon) { position: absolute;
color: #1a1a1a; bottom: 0;
left: 0;
width: 100%;
background-color: #1890ff;
border-radius: 4px;
transition: height 0.3s ease;
}
.chart-bar-label {
margin-top: 8px;
font-size: 12px;
color: #666;
}
.chart-legend {
display: flex;
justify-content: flex-end;
}
.chart-legend-item {
display: flex;
align-items: center;
margin-left: 16px;
}
.chart-legend-color {
width: 12px;
height: 12px;
margin-right: 8px;
border-radius: 2px;
}
@media (max-width: 768px) {
.comparison-data {
flex-direction: column;
align-items: center;
}
.comparison-data div {
margin-bottom: 4px;
}
.chart-container {
overflow-x: auto;
padding-bottom: 10px;
}
.chart-bar-item {
min-width: 40px;
}
} }
</style> </style>