earnings.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view class="earn-page">
  3. <LoadingSkeleton v-if="loading" :rows="3" />
  4. <ErrorState v-else-if="error" message="收入记录加载失败" @retry="load" />
  5. <template v-else>
  6. <!-- 三大数字 -->
  7. <view class="sum-card">
  8. <view class="sum-main">
  9. <text class="sum-label">累计到手</text>
  10. <text class="sum-value">¥{{ fenToYuan(totalIncome) }}</text>
  11. </view>
  12. <view class="sum-sub-row">
  13. <view class="sum-sub-col">
  14. <text class="sum-sub-value">¥{{ fenToYuan(monthIncome) }}</text>
  15. <text class="sum-sub-label">本月到手</text>
  16. </view>
  17. <view class="sum-sub-col">
  18. <text class="sum-sub-value">¥{{ fenToYuan(pendingIncome) }}</text>
  19. <text class="sum-sub-label">待确认</text>
  20. </view>
  21. <view class="sum-sub-col">
  22. <text class="sum-sub-value">{{ doneCount }}</text>
  23. <text class="sum-sub-label">已完成单</text>
  24. </view>
  25. </view>
  26. </view>
  27. <!-- 最近记录 -->
  28. <view class="sec-title-row">
  29. <text class="sec-title">最近收入记录</text>
  30. </view>
  31. <view v-if="recent.length === 0" class="empty-box">
  32. <text class="empty-text">还没有收入记录,完成服务并确认后自动记账</text>
  33. </view>
  34. <view v-for="item in recent" :key="item.id" class="earn-item">
  35. <view class="earn-left">
  36. <text class="earn-family">{{ item.familyName || '客户家' }}</text>
  37. <text class="earn-date">{{ item.finishAt || item.orderDate }}</text>
  38. </view>
  39. <view class="earn-right">
  40. <text class="earn-status" :style="{ color: item.status === 'confirmed' ? '#0E8A4F' : '#B9770E' }">
  41. {{ item.status === 'confirmed' ? '已到账' : '待确认' }}
  42. </text>
  43. <text class="earn-income">+¥{{ fenToYuan(item.staffIncome) }}</text>
  44. </view>
  45. </view>
  46. <view class="tip-box">
  47. <text class="tip-text">收入按服务人员到手金额记账(含平台费扣除后),明细可与机构对账</text>
  48. </view>
  49. </template>
  50. </view>
  51. </template>
  52. <script>
  53. import { getServiceEarnings } from '@/utils/api.js'
  54. import LoadingSkeleton from '@/components/loading-skeleton.vue'
  55. import ErrorState from '@/components/error-state.vue'
  56. export default {
  57. components: { LoadingSkeleton, ErrorState },
  58. data() {
  59. return {
  60. totalIncome: 0,
  61. monthIncome: 0,
  62. pendingIncome: 0,
  63. doneCount: 0,
  64. recent: [],
  65. loading: true,
  66. error: false
  67. }
  68. },
  69. onShow() {
  70. this.load()
  71. },
  72. methods: {
  73. load() {
  74. this.loading = true
  75. this.error = false
  76. getServiceEarnings().then(res => {
  77. if (!res || !res.data) return
  78. this.totalIncome = res.data.totalIncome || 0
  79. this.monthIncome = res.data.monthIncome || 0
  80. this.pendingIncome = res.data.pendingIncome || 0
  81. this.doneCount = res.data.doneCount || 0
  82. this.recent = res.data.recent || []
  83. }).catch(() => {
  84. this.error = true
  85. }).finally(() => {
  86. this.loading = false
  87. })
  88. },
  89. fenToYuan(fen) {
  90. var n = fen || 0
  91. return (n / 100).toFixed(2)
  92. }
  93. }
  94. }
  95. </script>
  96. <style scoped>
  97. .earn-page {
  98. min-height: 100vh;
  99. background: #F5FAFE;
  100. padding: 20rpx 24rpx 40rpx;
  101. }
  102. .sum-card {
  103. background: linear-gradient(135deg, #1F4E79, #2E6FA8);
  104. border-radius: 20rpx;
  105. padding: 32rpx 28rpx;
  106. margin-bottom: 26rpx;
  107. }
  108. .sum-main { text-align: center; padding: 10rpx 0 24rpx; }
  109. .sum-label { display: block; font-size: 24rpx; color: rgba(255,255,255,0.8); }
  110. .sum-value { display: block; font-size: 60rpx; font-weight: 700; color: #fff; line-height: 1.4; }
  111. .sum-sub-row { display: flex; border-top: 1px solid rgba(255,255,255,0.2); padding-top: 22rpx; }
  112. .sum-sub-col { flex: 1; text-align: center; display: flex; flex-direction: column; }
  113. .sum-sub-value { font-size: 32rpx; font-weight: 700; color: #fff; }
  114. .sum-sub-label { font-size: 22rpx; color: rgba(255,255,255,0.72); margin-top: 4rpx; }
  115. .sec-title-row { margin: 6rpx 4rpx 14rpx; }
  116. .sec-title { font-size: 30rpx; font-weight: 700; color: #1F4E79; }
  117. .empty-box {
  118. background: #fff;
  119. border-radius: 16rpx;
  120. padding: 36rpx 24rpx;
  121. text-align: center;
  122. border: 1px solid #E3ECF4;
  123. }
  124. .empty-text { font-size: 26rpx; color: #94A3B2; }
  125. .earn-item {
  126. background: #fff;
  127. border-radius: 16rpx;
  128. padding: 22rpx 24rpx;
  129. margin-bottom: 14rpx;
  130. border: 1px solid #E3ECF4;
  131. display: flex;
  132. justify-content: space-between;
  133. align-items: center;
  134. }
  135. .earn-left { display: flex; flex-direction: column; }
  136. .earn-family { font-size: 30rpx; font-weight: 600; color: #1E3A5F; }
  137. .earn-date { font-size: 23rpx; color: #94A3B2; margin-top: 4rpx; }
  138. .earn-right { display: flex; flex-direction: column; align-items: flex-end; }
  139. .earn-status { font-size: 23rpx; }
  140. .earn-income { font-size: 34rpx; font-weight: 700; color: #C0392B; margin-top: 4rpx; }
  141. .tip-box { margin-top: 24rpx; padding: 0 8rpx; }
  142. .tip-text { font-size: 22rpx; color: #94A3B2; line-height: 1.8; }
  143. </style>