9.16/1
This commit is contained in:
@@ -12,22 +12,26 @@
|
||||
<view class="kpi">
|
||||
<view class="kpi-item">
|
||||
<text class="kpi-label">今日销售额</text>
|
||||
<text class="kpi-value">{{ todayAmount }}</text>
|
||||
<text class="kpi-value">{{ kpi.todaySales }}</text>
|
||||
</view>
|
||||
<view class="kpi-item">
|
||||
<text class="kpi-label">本月销售额</text>
|
||||
<text class="kpi-value">{{ kpi.monthSales }}</text>
|
||||
</view>
|
||||
<view class="kpi-item">
|
||||
<text class="kpi-label">本月利润</text>
|
||||
<text class="kpi-value">{{ monthProfit }}</text>
|
||||
<text class="kpi-value">{{ kpi.monthProfit }}</text>
|
||||
</view>
|
||||
<view class="kpi-item">
|
||||
<text class="kpi-label">库存数量</text>
|
||||
<text class="kpi-value">{{ stockQty }}</text>
|
||||
<text class="kpi-label">库存商品数量</text>
|
||||
<text class="kpi-value">{{ kpi.stockCount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 公告栏:自动轮播,可点击查看详情 -->
|
||||
<!-- 广告栏:自动轮播,可点击查看详情 -->
|
||||
<view class="notice">
|
||||
<view class="notice-left">公告</view>
|
||||
<view class="notice-left">广告</view>
|
||||
<view v-if="loadingNotices" class="notice-swiper" style="display:flex;align-items:center;color:#6b5a2a;">加载中...</view>
|
||||
<view v-else-if="noticeError" class="notice-swiper" style="display:flex;align-items:center;color:#dd524d;">{{ noticeError }}</view>
|
||||
<view v-else-if="!notices.length" class="notice-swiper" style="display:flex;align-items:center;color:#6b5a2a;">暂无公告</view>
|
||||
@@ -39,7 +43,6 @@
|
||||
</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<view class="notice-right" @click="onNoticeList">更多</view>
|
||||
</view>
|
||||
|
||||
<!-- 分割标题:产品与功能 -->
|
||||
@@ -66,12 +69,18 @@
|
||||
<view class="tab" :class="{ active: activeTab==='home' }" @click="activeTab='home'">
|
||||
<text>首页</text>
|
||||
</view>
|
||||
<view class="tab" :class="{ active: activeTab==='product' }" @click="activeTab='product'">
|
||||
<text>货品</text>
|
||||
</view>
|
||||
<view class="tab primary" @click="onCreateOrder">
|
||||
<text>开单</text>
|
||||
</view>
|
||||
<view class="tab" :class="{ active: activeTab==='detail' }" @click="activeTab='detail'">
|
||||
<text>明细</text>
|
||||
</view>
|
||||
<view class="tab" :class="{ active: activeTab==='report' }" @click="activeTab='report'">
|
||||
<text>报表</text>
|
||||
</view>
|
||||
<view class="tab" :class="{ active: activeTab==='me' }" @click="activeTab='me'">
|
||||
<text>我的</text>
|
||||
</view>
|
||||
@@ -84,9 +93,7 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
todayAmount: '0.00',
|
||||
monthProfit: '0.00',
|
||||
stockQty: '0.00',
|
||||
kpi: { todaySales: '0.00', monthSales: '0.00', monthProfit: '0.00', stockCount: '0' },
|
||||
activeTab: 'home',
|
||||
notices: [],
|
||||
loadingNotices: false,
|
||||
@@ -105,9 +112,23 @@
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.fetchMetrics()
|
||||
this.fetchNotices()
|
||||
},
|
||||
methods: {
|
||||
async fetchMetrics() {
|
||||
try {
|
||||
const d = await get('/api/metrics/overview')
|
||||
this.kpi = {
|
||||
todaySales: (d && d.todaySales) || '0.00',
|
||||
monthSales: (d && d.monthSales) || '0.00',
|
||||
monthProfit: (d && d.monthProfit) || '0.00',
|
||||
stockCount: (d && d.stockCount) || '0'
|
||||
}
|
||||
} catch (e) {
|
||||
// 忽略错误,保留默认值
|
||||
}
|
||||
},
|
||||
async fetchNotices() {
|
||||
this.loadingNotices = true
|
||||
this.noticeError = ''
|
||||
@@ -127,18 +148,16 @@
|
||||
uni.showToast({ title: item.title + '(开发中)', icon: 'none' })
|
||||
},
|
||||
onCreateOrder() {
|
||||
uni.showToast({ title: '开单(开发中)', icon: 'none' })
|
||||
uni.navigateTo({ url: '/pages/order/create' })
|
||||
},
|
||||
onNoticeTap(n) {
|
||||
uni.showModal({
|
||||
title: '公告',
|
||||
title: '广告',
|
||||
content: n && (n.text || n.title || n.content) || '',
|
||||
showCancel: false
|
||||
})
|
||||
},
|
||||
onNoticeList() {
|
||||
uni.showToast({ title: '公告列表(开发中)', icon: 'none' })
|
||||
},
|
||||
|
||||
onIconError(item) {
|
||||
item.img = ''
|
||||
}
|
||||
@@ -192,7 +211,7 @@
|
||||
.notice-item { display: flex; align-items: center; gap: 12rpx; min-height: 72rpx; }
|
||||
.notice-text { color: #4b3e19; font-size: 28rpx; line-height: 36rpx; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
||||
.notice-tag { color: #B4880F; font-size: 22rpx; padding: 4rpx 10rpx; border-radius: 999rpx; background: rgba(215,167,46,0.18); }
|
||||
.notice-right { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; min-width: 72rpx; height: 44rpx; color: #B4880F; font-size: 26rpx; padding-left: 8rpx; }
|
||||
|
||||
|
||||
/* 分割标题 */
|
||||
.section-title { display: flex; align-items: center; gap: 16rpx; padding: 10rpx 28rpx 0; }
|
||||
|
||||
Reference in New Issue
Block a user