Files
vpUni/.svn/pristine/bd/bd8ae008b1ad962f8ab18fd1d712cec45b30c29a.svn-base
2026-03-09 16:39:03 +08:00

223 lines
4.4 KiB
Plaintext

<template>
<view class="page">
<!-- 时间筛选标签 -->
<view class="time-filter">
<text class="filter-item" @click="currentIndex=0" :class="{active:currentIndex==0}">全部</text>
<text class="filter-item" @click="currentIndex=1" :class="{active:currentIndex==1}">今日</text>
<text class="filter-item" @click="currentIndex=2" :class="{active:currentIndex==2}">本月</text>
<text class="filter-item" @click="show=true" :class="{active:currentIndex==3}">自定义</text>
</view>
<!-- 关键数据卡片 -->
<view class="data-cards">
<view class="data-card">
<text class="data-label">销售额</text>
<text class="data-value">¥12,345</text>
<text class="data-growth">+12.5%</text>
</view>
<view class="data-card">
<text class="data-label">订单数</text>
<text class="data-value">128单</text>
<text class="data-growth">+8.3%</text>
</view>
<view class="data-card">
<text class="data-label">访客数</text>
<text class="data-value">1,024人</text>
<text class="data-growth">+15.2%</text>
</view>
<view class="data-card">
<text class="data-label">人均消费</text>
<text class="data-value">¥96.4</text>
<text class="data-growth">+4.8%</text>
</view>
</view>
<up-calendar :show="show" :mode="mode" monthNum='5' minDate='2025-12-01' maxDate='2999-12-31' @close="show=false" @confirm="confirm"></up-calendar>
</view>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
// 商品销量排行数据类型
interface RankingItem {
name : string;
sales : number;
trend : 'up' | 'down';
}
let currentIndex = ref(0)
// 商品销量排行数据
const salesRanking = ref<RankingItem[]>([
{ name: '招牌牛肉面', sales: 245, trend: 'up' },
{ name: '香菇三明治', sales: 189, trend: 'down' },
{ name: '水果沙拉', sales: 156, trend: 'up' },
{ name: '红烧排骨', sales: 134, trend: 'up' },
{ name: '糖醋里脊', sales: 112, trend: 'down' }
]);
const show = ref(false);
const mode = ref('range');
const confirm = (e) => {
console.log(e);
currentIndex.value=3
};
// 切换时间筛选
const changeTimeFilter = (index : number) => {
// 实际项目中这里应该有切换时间筛选的逻辑
console.log('切换时间筛选', index);
};
</script>
<style scoped lang="scss">
.page {
background-color: #F5F5F5;
min-height: 100vh;
padding-bottom: 40rpx;
}
/* 时间筛选标签 */
.time-filter {
display: flex;
justify-content: space-around;
padding: 30rpx;
background-color: #FFFFFF;
margin-bottom: 30rpx;
}
.filter-item {
font-size: 32rpx;
color: #666666;
padding: 10rpx 40rpx;
border-radius: 30rpx;
}
.filter-item.active {
background-color: #FF6600;
color: #FFFFFF;
}
/* 关键数据卡片 */
.data-cards {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20rpx;
padding: 0 30rpx;
margin-bottom: 30rpx;
}
.data-card {
background-color: #FFFFFF;
padding: 30rpx;
border-radius: 20rpx;
}
.data-label {
font-size: 28rpx;
color: #999999;
display: block;
margin-bottom: 20rpx;
}
.data-value {
font-size: 40rpx;
color: #333333;
font-weight: bold;
display: block;
margin-bottom: 10rpx;
}
.data-growth {
font-size: 28rpx;
color: #4CD964;
}
/* 图表区域 */
.chart-section,
.ranking-section,
.flow-section {
background-color: #FFFFFF;
padding: 30rpx;
border-radius: 20rpx;
margin: 0 30rpx 30rpx;
}
.section-title {
font-size: 36rpx;
color: #333333;
font-weight: bold;
display: block;
margin-bottom: 30rpx;
}
.chart-container {
width: 100%;
height: 320rpx;
}
.sales-trend-chart,
.customer-flow-chart {
width: 100%;
height: 100%;
}
/* 商品销量排行 */
.ranking-list {
gap: 20rpx;
}
.ranking-item {
display: flex;
align-items: center;
padding: 20rpx 0;
border-bottom: 1rpx solid #F0F0F0;
}
.ranking-item:last-child {
border-bottom: none;
}
.ranking-number {
width: 60rpx;
height: 60rpx;
background-color: #FF6600;
color: #FFFFFF;
font-size: 32rpx;
font-weight: bold;
display: flex;
align-items: center;
justify-content: center;
border-radius: 10rpx;
margin-right: 24rpx;
}
.ranking-product {
flex: 1;
font-size: 32rpx;
color: #333333;
}
.ranking-info {
display: flex;
align-items: center;
}
.ranking-sales {
font-size: 32rpx;
color: #333333;
margin-right: 16rpx;
}
.trend-icon {
margin-left: 8rpx;
}
</style>