index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view class="xfjl-page">
  3. <!-- 搜索按钮区域 -->
  4. <view class="search-container right">
  5. <ss-search-button
  6. text="充值"
  7. pre-icon="icon-jiahao"
  8. @click="handleAddRecord"
  9. />
  10. </view>
  11. <!-- 消费记录列表区域 -->
  12. <view class="record-list">
  13. <!-- 使用卡片组件展示消费记录 -->
  14. <ss-card
  15. v-for="record in records"
  16. :key="record.id"
  17. @click="handleCardClick(record)"
  18. >
  19. <view class="record-item">
  20. <view class="record-header">
  21. <text class="amount" :class="record.type">{{ record.amount > 0 ? '+' : '' }}¥ {{ record.amount }}</text>
  22. <text class="balance">【余额: {{ record.balance }}】</text>
  23. </view>
  24. <view class="record-info">
  25. <view class="time">{{ record.time }}</view>
  26. <view class="location">{{ record.location }}</view>
  27. <view class="order-no">{{ record.orderNo }}</view>
  28. </view>
  29. </view>
  30. </ss-card>
  31. </view>
  32. </view>
  33. </template>
  34. <script setup>
  35. import SsSearchButton from '@/components/SsSearchButton/index.vue'
  36. import Icon from '@/components/icon/index.vue'
  37. import SsCard from '@/components/SsCard/index.vue'
  38. const handleAddRecord = () => {
  39. console.log('点击了新增消费记录')
  40. uni.showToast({
  41. title: '新增消费记录',
  42. icon: 'none'
  43. })
  44. }
  45. const handleExport = () => {
  46. console.log('点击了导出记录')
  47. uni.showToast({
  48. title: '导出记录功能',
  49. icon: 'none'
  50. })
  51. }
  52. // 模拟数据
  53. const records = [
  54. {
  55. id: 'XFJ-001-20250612122200001',
  56. type: 'expense', // expense: 支出, income: 收入
  57. amount: -10,
  58. balance: 120,
  59. time: '2025年6月12日 12:22',
  60. location: '第一饭堂001消费机',
  61. orderNo: 'XFJ-001-20250612122200001'
  62. },
  63. {
  64. id: 'XFJ-001-20250612122200002',
  65. type: 'income',
  66. amount: 100,
  67. balance: 120,
  68. time: '2025年6月12日 12:22',
  69. location: '充值',
  70. orderNo: 'XFJ-001-20250612122200001'
  71. },
  72. {
  73. id: 'XFJ-001-20250612122200003',
  74. type: 'expense',
  75. amount: -15,
  76. balance: 20,
  77. time: '2025年6月12日 11:35',
  78. location: '第二饭堂002消费机',
  79. orderNo: 'XFJ-001-20250612113500001'
  80. }
  81. ]
  82. const handleCardClick = (record) => {
  83. console.log('点击了记录:', record)
  84. uni.showToast({
  85. title: `点击了${record.type === 'expense' ? '支出' : '充值'}记录`,
  86. icon: 'none'
  87. })
  88. }
  89. </script>
  90. <style lang="scss" scoped>
  91. .xfjl-page {
  92. padding: 20rpx;
  93. background-color: #f5f5f5;
  94. min-height: 100vh;
  95. }
  96. .page-header {
  97. text-align: center;
  98. margin-bottom: 40rpx;
  99. }
  100. .page-title {
  101. font-size: 36rpx;
  102. font-weight: bold;
  103. color: #333;
  104. }
  105. .search-container {
  106. display: flex;
  107. margin: 1rem 0;
  108. gap: 0.5rem;
  109. &.right {
  110. justify-content: flex-end;
  111. }
  112. }
  113. .record-list {
  114. margin-top: 40rpx;
  115. .record-item {
  116. .record-header {
  117. display: flex;
  118. align-items: center;
  119. justify-content:flex-start;
  120. gap: 20rpx;
  121. margin-bottom: 20rpx;
  122. .amount {
  123. font-size: 36rpx;
  124. font-weight: bold;
  125. &.expense {
  126. color: #ff4d4f;
  127. }
  128. &.income {
  129. color: #52c41a;
  130. }
  131. }
  132. .balance {
  133. font-size: 24rpx;
  134. color: #999;
  135. }
  136. }
  137. .record-info {
  138. font-size: 24rpx;
  139. color: #666;
  140. .time {
  141. margin-bottom: 8rpx;
  142. }
  143. .location {
  144. margin-bottom: 8rpx;
  145. }
  146. .order-no {
  147. color: #999;
  148. font-size: 22rpx;
  149. }
  150. }
  151. }
  152. }
  153. </style>