| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <template>
- <view class="page">
- <NavBar title="门店销售" :showBack="true" />
- <scroll-view class="list-scroll" scroll-y @scrolltolower="loadMore">
- <view class="card-set">
- <view class="card" v-for="(item, idx) in list" :key="item.shopId">
- <view class="card-head">
- <view class="rank-badge" :class="'top' + Math.min(idx + 1, 3)"><text>{{ idx + 1 }}</text></view>
- <view class="card-center">
- <text class="card-name">{{ item.shopName }}</text>
- <text class="card-city" v-if="item.city">{{ item.city }}</text>
- </view>
- <text class="card-amount">{{ formatMoney(item.totalAmount || 0) }}</text>
- </view>
- <view class="card-foot">
- <text class="foot-stat">订单 {{ item.orderCount || 0 }}</text>
- <text class="foot-stat">利润 {{ formatMoney(item.profit || 0) }}</text>
- </view>
- </view>
- </view>
- <view class="load-tip" v-if="loading"><view class="dot-row"><view class="pulse-dot"></view><view class="pulse-dot"></view><view class="pulse-dot"></view></view></view>
- <view class="end-tip" v-if="!hasMore && list.length > 0"><text>没有更多了</text></view>
- </scroll-view>
- </view>
- </template>
- <script setup lang="ts">
- import { ref, onMounted } from 'vue';
- import NavBar from '@/components/NavBar.vue';
- import { get } from '@/utils/request';
- import { formatMoney, formatDate } from '@/utils/common';
- const list = ref<any[]>([]); const loading = ref(false); const hasMore = ref(true); const page = ref(1);
- const loadData = async () => {
- loading.value = true;
- try {
- const end = formatDate(new Date()); const start = formatDate(new Date(Date.now()-30*86400000));
- const res = await get('/statistics/shop/list', { page: page.value, pageSize: 20, startDate: start, endDate: end, sortBy: 'totalAmount', sortOrder: 'desc' });
- if (page.value === 1) list.value = res.list || []; else list.value = [...list.value, ...(res.list || [])];
- hasMore.value = list.value.length < (res.total || 0);
- } catch { }
- loading.value = false;
- };
- const loadMore = () => { if (loading.value || !hasMore.value) return; page.value++; loadData(); };
- onMounted(() => loadData());
- </script>
- <style lang="scss" scoped>
- .page { height: 100vh; background: $bg-color-page; display: flex; flex-direction: column; }
- .list-scroll { flex: 1; height: 0; }
- .card-set { padding: 20rpx 24rpx; display: flex; flex-direction: column; gap: 16rpx; }
- .card { background: $bg-color-card; border-radius: $radius-md; padding: 20rpx 24rpx; box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.05); }
- .card-head { display: flex; align-items: center; margin-bottom: 12rpx; }
- .rank-badge { width: 44rpx; height: 44rpx; border-radius: 10rpx; display: flex; align-items: center; justify-content: center; margin-right: 16rpx; flex-shrink: 0; }
- .rank-badge text { font-size: 24rpx; font-weight: 700; color: #fff; }
- .rank-badge.top1 { background: #f59e0b; } .rank-badge.top2 { background: #94a3b8; } .rank-badge.top3 { background: #cd853f; }
- .card-center { flex: 1; }
- .card-name { font-size: 28rpx; font-weight: 500; color: $text-color-primary; display: block; }
- .card-city { font-size: 22rpx; color: $text-color-muted; }
- .card-amount { font-size: 28rpx; font-weight: 700; color: $primary-color-dark; white-space: nowrap; }
- .card-foot { display: flex; gap: 24rpx; }
- .foot-stat { font-size: 22rpx; color: $text-color-muted; }
- .load-tip { display: flex; justify-content: center; padding: 36rpx 0; }
- .dot-row { display: flex; gap: 8rpx; }
- .pulse-dot { width: 9rpx; height: 9rpx; background: $text-color-placeholder; border-radius: 50%; animation: pulse 1.2s ease-in-out infinite; }
- .pulse-dot:nth-child(2) { animation-delay: 0.2s; } .pulse-dot:nth-child(3) { animation-delay: 0.4s; }
- @keyframes pulse { 0%,80%,100% { transform: scale(0.5); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }
- .end-tip { text-align: center; padding: 36rpx; font-size: 24rpx; color: $text-color-muted; }
- </style>
|