From 2c319bae8f9652fffafd29a572a66ca261497b35 Mon Sep 17 00:00:00 2001 From: dzq Date: Tue, 20 May 2025 11:00:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=AC=A2=E8=BF=8E=E9=A1=B5):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=BB=9F=E8=AE=A1=E6=95=B0=E6=8D=AE=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在欢迎页中新增了统计数据的显示功能,包括商店、商品、订单、柜子、格口等数据的动态展示,并引入了热门商品和今日最新订单的展示模块。通过调用 `getStats` API 获取数据,并在页面加载时进行渲染,提升了页面的信息丰富度和用户体验。 --- src/api/shop/stats.ts | 73 +++++++++++++ src/views/welcome/index.vue | 203 +++++++++++++++++++++++++++++++++--- 2 files changed, 263 insertions(+), 13 deletions(-) create mode 100644 src/api/shop/stats.ts diff --git a/src/api/shop/stats.ts b/src/api/shop/stats.ts new file mode 100644 index 0000000..a583dc9 --- /dev/null +++ b/src/api/shop/stats.ts @@ -0,0 +1,73 @@ +import { http } from '@/utils/http'; + +/** 热门商品DTO */ +export interface TopGoodsDTO { + /** 商品ID */ + goodsId: number; + /** 商品名称 */ + goodsName: string; + /** 封面图片 */ + coverImg: string; + /** 出现次数 */ + occurrenceCount: number; +} + +/** 今日最新订单商品DTO */ +export interface TodayLatestOrderGoodsDTO { + /** 订单商品唯一ID */ + orderGoodsId: number; + /** 关联订单ID */ + orderId: number; + /** 关联商品ID */ + goodsId: number; + /** 关联格口ID */ + cellId: number; + /** 购买数量 */ + quantity: number; + /** 购买时单价 */ + price: number; + /** 商品总金额 */ + totalAmount: number; + /** 商品名称 */ + goodsName: string; + /** 封面图URL */ + coverImg: string; + /** 商品状态(1正常 2已退货 3已换货 4已完成 5审核中 6退货未通过) */ + status: number; + /** 买家姓名 */ + buyerName: string; + createTime: string; + createTimeStr: string; +} + +/** 统计数据DTO */ +export interface StatsDTO { + /** 商店数量 */ + shopCount: number; + /** 商品数量 */ + goodsCount: number; + /** 订单数量 */ + orderCount: number; + /** 总柜子数量 */ + cabinetCount: number; + /** 总格口数量 */ + cellCount: number; + /** 已关联格口数量 */ + linkedCellCount: number; + /** 未管理格口数量 */ + unmanagedCellCount: number; + /** 网关数量 */ + gatewayCount: number; + /** 热门商品列表 */ + topGoods: TopGoodsDTO[]; + /** 今日最新订单商品列表 */ + todayLatestOrderGoods: TodayLatestOrderGoodsDTO[]; +} + +/** + * 获取统计数据 + * @returns 包含统计数据的响应 + */ +export const getStats = () => { + return http.request>('get', '/shop/shops/Stats'); +}; \ No newline at end of file diff --git a/src/views/welcome/index.vue b/src/views/welcome/index.vue index 148bb29..ac6ae49 100644 --- a/src/views/welcome/index.vue +++ b/src/views/welcome/index.vue @@ -1,5 +1,7 @@ @@ -106,7 +191,7 @@ const deviceData = [ .section-title { display: flex; align-items: center; - margin-bottom: 15px; + margin-bottom: 5px; .title-bar { width: 3px; @@ -152,6 +237,7 @@ const deviceData = [ } } } + .todo-count { font-size: 24px; font-weight: bold; @@ -164,8 +250,99 @@ const deviceData = [ color: var(--el-text-color-secondary); text-align: center; } + .data-section { margin-bottom: 0; } + + .goods-card, + .order-card { + height: 100%; + border: none; + + .goods-image, + .order-image { + width: 100%; + height: 140px; + border-radius: 4px 4px 0 0; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); + } + + .goods-content, + .order-content { + padding: 10px; + + .goods-name, + .order-name { + font-size: 14px; + font-weight: bold; + margin-bottom: 5px; + text-align: center; + } + + .goods-count, + .order-info { + font-size: 12px; + color: var(--el-text-color-secondary); + text-align: center; + } + } + } + + .goods-list { + .goods-item { + border: none; + + .goods-item-content { + display: flex; + align-items: center; + justify-content: space-between; + padding: 3px; + + .goods-left { + display: flex; + align-items: center; + flex: 1; + + .goods-image { + width: 100px; + height: 80px; + border-radius: 4px; + margin-right: 12px; + /* box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1); */ + } + + .goods-name { + font-size: 14px; + font-weight: bold; + } + } + + .goods-right { + display: flex; + align-items: center; + width: 450px; + + .goods-progress { + flex: 1; + margin-right: 12px; + } + + .goods-count { + width: 60px; + text-align: right; + font-size: 14px; + color: var(--el-text-color-primary); + } + + .buyer-name { + padding-left: 10px; + flex-grow: 1; + text-align: left; + } + } + } + } + } } \ No newline at end of file