rewards-all.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <view class="container">
  3. <!-- 类型标签 -->
  4. <view class="tab-bar">
  5. <view
  6. class="tab-item"
  7. v-for="(tab, idx) in tabs"
  8. :key="idx"
  9. :class="{ active: activeTab === idx }"
  10. @click="switchTab(idx)"
  11. >
  12. <text>{{ tab }}</text>
  13. <view class="tab-line" v-if="activeTab === idx"></view>
  14. </view>
  15. </view>
  16. <!-- 按月分组列表 -->
  17. <scroll-view scroll-y class="main-scroll">
  18. <view v-for="(group, gIdx) in filteredGroups" :key="gIdx" class="month-group">
  19. <!-- 月份标题 -->
  20. <view class="month-header">
  21. <text class="month-title">{{ group.month }}月</text>
  22. <view class="month-summary">
  23. <text class="month-sum-text">已入账¥{{ group.credited.toFixed(2) }}</text>
  24. <text class="month-sum-text"> 待入账¥{{ group.pending.toFixed(2) }}</text>
  25. </view>
  26. </view>
  27. <!-- 记录列 -->
  28. <view class="record-item" v-for="(item, rIdx) in group.items" :key="rIdx">
  29. <view class="ri-icon" :class="item.amount > 0 ? 'ri-reward' : 'ri-penalty'">
  30. <text class="ri-icon-text">¥</text>
  31. </view>
  32. <view class="ri-content">
  33. <view class="ri-title-row">
  34. <text class="ri-date">{{ item.date }}</text>
  35. <text class="ri-title">{{ item.title }}</text>
  36. </view>
  37. <text class="ri-desc">{{ item.desc }}</text>
  38. </view>
  39. <view class="ri-right">
  40. <text class="ri-amount" :class="item.amount > 0 ? 'positive' : 'negative'">
  41. {{ item.amount > 0 ? '+' : '' }}{{ item.amount.toFixed(2) }}
  42. </text>
  43. <text class="ri-status" :class="item.statusClass">{{ item.status }}</text>
  44. </view>
  45. </view>
  46. </view>
  47. <view style="height: 40rpx;"></view>
  48. </scroll-view>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. data() {
  54. return {
  55. tabs: ['全部', '奖励', '惩罚'],
  56. activeTab: 0,
  57. // 所有完整记录(按月分组)
  58. allGroups: [
  59. {
  60. month: 9,
  61. credited: 30, pending: 0,
  62. items: [
  63. { date: '09-24', title: '高温补贴', desc: '9月份高温天气补贴', amount: 30, status: '已入账', statusClass: 'credited', type: 'reward' }
  64. ]
  65. },
  66. {
  67. month: 8,
  68. credited: 2610, pending: 0,
  69. items: [
  70. { date: '08-01', title: '单量奖励', desc: '超140单', amount: 560, status: '已入账', statusClass: 'credited', type: 'reward' },
  71. { date: '07-01', title: '单量奖励', desc: '超470单', amount: 2050, status: '已入账', statusClass: 'credited', type: 'reward' }
  72. ]
  73. },
  74. {
  75. month: 7,
  76. credited: 0, pending: 0,
  77. items: [
  78. { date: '07-15', title: '超时扣款', desc: '订单#T98211 超时30分钟', amount: -15, status: '已扣款', statusClass: 'deducted', type: 'penalty' },
  79. { date: '07-20', title: '客诉扣款', desc: '订单#T98222 餐品遗漏', amount: -50, status: '已扣款', statusClass: 'deducted', type: 'penalty' }
  80. ]
  81. }
  82. ]
  83. };
  84. },
  85. computed: {
  86. filteredGroups() {
  87. if (this.activeTab === 0) return this.allGroups;
  88. const typeKey = this.activeTab === 1 ? 'reward' : 'penalty';
  89. return this.allGroups.map(g => ({
  90. ...g,
  91. items: g.items.filter(i => i.type === typeKey)
  92. })).filter(g => g.items.length > 0);
  93. }
  94. },
  95. methods: {
  96. switchTab(idx) { this.activeTab = idx; }
  97. }
  98. };
  99. </script>
  100. <style>
  101. page { background-color: #F7F8FA; }
  102. .container { min-height: 100vh; background-color: #F7F8FA; }
  103. .tab-bar {
  104. display: flex;
  105. background-color: #fff;
  106. padding: 0 30rpx;
  107. }
  108. .tab-item {
  109. padding: 18rpx 16rpx 0;
  110. font-size: 28rpx;
  111. color: #999;
  112. display: flex;
  113. flex-direction: column;
  114. align-items: center;
  115. }
  116. .tab-item:first-child { padding-left: 0; }
  117. .tab-item.active { color: #FF9800; font-weight: bold; }
  118. /* 下划线正常流,自然居中 */
  119. .tab-line {
  120. width: 32rpx;
  121. height: 3rpx;
  122. background-color: #FF9800;
  123. border-radius: 2rpx;
  124. margin-top: 8rpx;
  125. align-self: center;
  126. }
  127. .main-scroll { flex: 1; padding: 16rpx 0; }
  128. .month-group {
  129. background-color: #fff;
  130. border-radius: 16rpx;
  131. padding: 0 24rpx;
  132. margin: 0 30rpx 16rpx;
  133. overflow: hidden;
  134. }
  135. .month-header {
  136. display: flex;
  137. align-items: center;
  138. padding: 20rpx 0;
  139. border-bottom: 1rpx solid #f5f5f5;
  140. }
  141. .month-title {
  142. font-size: 30rpx;
  143. font-weight: bold;
  144. color: #333;
  145. margin-right: 12rpx;
  146. }
  147. .month-summary { display: flex; }
  148. .month-sum-text { font-size: 22rpx; color: #999; margin-right: 10rpx; }
  149. .record-item {
  150. display: flex;
  151. align-items: center;
  152. padding: 24rpx 0;
  153. border-bottom: 1rpx solid #f9f9f9;
  154. }
  155. .ri-icon {
  156. width: 72rpx;
  157. height: 72rpx;
  158. border-radius: 50%;
  159. background-color: #FFF3E0;
  160. display: flex;
  161. align-items: center;
  162. justify-content: center;
  163. margin-right: 20rpx;
  164. flex-shrink: 0;
  165. }
  166. .ri-icon.ri-penalty { background-color: #FAFAFA; }
  167. .ri-icon-text {
  168. font-size: 30rpx;
  169. color: #FF9800;
  170. font-weight: bold;
  171. }
  172. .ri-icon.ri-penalty .ri-icon-text { color: #ccc; }
  173. .ri-content { flex: 1; }
  174. .ri-title-row { display: flex; align-items: center; margin-bottom: 6rpx; }
  175. .ri-date { font-size: 26rpx; color: #333; font-weight: bold; margin-right: 10rpx; }
  176. .ri-title { font-size: 26rpx; color: #333; }
  177. .ri-desc { font-size: 24rpx; color: #999; }
  178. .ri-right {
  179. display: flex;
  180. flex-direction: column;
  181. align-items: flex-end;
  182. margin-left: 16rpx;
  183. }
  184. .ri-amount { font-size: 30rpx; font-weight: bold; margin-bottom: 4rpx; }
  185. .ri-amount.positive { color: #FF5722; }
  186. .ri-amount.negative { color: #333; }
  187. .ri-status { font-size: 22rpx; }
  188. .ri-status.pending { color: #FF9800; }
  189. .ri-status.credited { color: #999; }
  190. .ri-status.deducted { color: #999; }
  191. </style>