| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <template>
- <view class="earn-page">
- <LoadingSkeleton v-if="loading" :rows="3" />
- <ErrorState v-else-if="error" message="收入记录加载失败" @retry="load" />
- <template v-else>
- <!-- 三大数字 -->
- <view class="sum-card">
- <view class="sum-main">
- <text class="sum-label">累计到手</text>
- <text class="sum-value">¥{{ fenToYuan(totalIncome) }}</text>
- </view>
- <view class="sum-sub-row">
- <view class="sum-sub-col">
- <text class="sum-sub-value">¥{{ fenToYuan(monthIncome) }}</text>
- <text class="sum-sub-label">本月到手</text>
- </view>
- <view class="sum-sub-col">
- <text class="sum-sub-value">¥{{ fenToYuan(pendingIncome) }}</text>
- <text class="sum-sub-label">待确认</text>
- </view>
- <view class="sum-sub-col">
- <text class="sum-sub-value">{{ doneCount }}</text>
- <text class="sum-sub-label">已完成单</text>
- </view>
- </view>
- </view>
- <!-- 最近记录 -->
- <view class="sec-title-row">
- <text class="sec-title">最近收入记录</text>
- </view>
- <view v-if="recent.length === 0" class="empty-box">
- <text class="empty-text">还没有收入记录,完成服务并确认后自动记账</text>
- </view>
- <view v-for="item in recent" :key="item.id" class="earn-item">
- <view class="earn-left">
- <text class="earn-family">{{ item.familyName || '客户家' }}</text>
- <text class="earn-date">{{ item.finishAt || item.orderDate }}</text>
- </view>
- <view class="earn-right">
- <text class="earn-status" :style="{ color: item.status === 'confirmed' ? '#0E8A4F' : '#B9770E' }">
- {{ item.status === 'confirmed' ? '已到账' : '待确认' }}
- </text>
- <text class="earn-income">+¥{{ fenToYuan(item.staffIncome) }}</text>
- </view>
- </view>
- <view class="tip-box">
- <text class="tip-text">收入按服务人员到手金额记账(含平台费扣除后),明细可与机构对账</text>
- </view>
- </template>
- </view>
- </template>
- <script>
- import { getServiceEarnings } from '@/utils/api.js'
- import LoadingSkeleton from '@/components/loading-skeleton.vue'
- import ErrorState from '@/components/error-state.vue'
- export default {
- components: { LoadingSkeleton, ErrorState },
- data() {
- return {
- totalIncome: 0,
- monthIncome: 0,
- pendingIncome: 0,
- doneCount: 0,
- recent: [],
- loading: true,
- error: false
- }
- },
- onShow() {
- this.load()
- },
- methods: {
- load() {
- this.loading = true
- this.error = false
- getServiceEarnings().then(res => {
- if (!res || !res.data) return
- this.totalIncome = res.data.totalIncome || 0
- this.monthIncome = res.data.monthIncome || 0
- this.pendingIncome = res.data.pendingIncome || 0
- this.doneCount = res.data.doneCount || 0
- this.recent = res.data.recent || []
- }).catch(() => {
- this.error = true
- }).finally(() => {
- this.loading = false
- })
- },
- fenToYuan(fen) {
- var n = fen || 0
- return (n / 100).toFixed(2)
- }
- }
- }
- </script>
- <style scoped>
- .earn-page {
- min-height: 100vh;
- background: #F5FAFE;
- padding: 20rpx 24rpx 40rpx;
- }
- .sum-card {
- background: linear-gradient(135deg, #1F4E79, #2E6FA8);
- border-radius: 20rpx;
- padding: 32rpx 28rpx;
- margin-bottom: 26rpx;
- }
- .sum-main { text-align: center; padding: 10rpx 0 24rpx; }
- .sum-label { display: block; font-size: 24rpx; color: rgba(255,255,255,0.8); }
- .sum-value { display: block; font-size: 60rpx; font-weight: 700; color: #fff; line-height: 1.4; }
- .sum-sub-row { display: flex; border-top: 1px solid rgba(255,255,255,0.2); padding-top: 22rpx; }
- .sum-sub-col { flex: 1; text-align: center; display: flex; flex-direction: column; }
- .sum-sub-value { font-size: 32rpx; font-weight: 700; color: #fff; }
- .sum-sub-label { font-size: 22rpx; color: rgba(255,255,255,0.72); margin-top: 4rpx; }
- .sec-title-row { margin: 6rpx 4rpx 14rpx; }
- .sec-title { font-size: 30rpx; font-weight: 700; color: #1F4E79; }
- .empty-box {
- background: #fff;
- border-radius: 16rpx;
- padding: 36rpx 24rpx;
- text-align: center;
- border: 1px solid #E3ECF4;
- }
- .empty-text { font-size: 26rpx; color: #94A3B2; }
- .earn-item {
- background: #fff;
- border-radius: 16rpx;
- padding: 22rpx 24rpx;
- margin-bottom: 14rpx;
- border: 1px solid #E3ECF4;
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .earn-left { display: flex; flex-direction: column; }
- .earn-family { font-size: 30rpx; font-weight: 600; color: #1E3A5F; }
- .earn-date { font-size: 23rpx; color: #94A3B2; margin-top: 4rpx; }
- .earn-right { display: flex; flex-direction: column; align-items: flex-end; }
- .earn-status { font-size: 23rpx; }
- .earn-income { font-size: 34rpx; font-weight: 700; color: #C0392B; margin-top: 4rpx; }
- .tip-box { margin-top: 24rpx; padding: 0 8rpx; }
- .tip-text { font-size: 22rpx; color: #94A3B2; line-height: 1.8; }
- </style>
|