index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view class="list-page">
  3. <!-- 搜索按钮区域 -->
  4. <view class="search-container">
  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. // 模拟数据
  46. const records = [
  47. {
  48. id: 'XFJ-001-20250612122200001',
  49. type: 'expense', // expense: 支出, income: 收入
  50. amount: -10,
  51. balance: 120,
  52. time: '2025年6月12日 12:22',
  53. location: '第一饭堂001消费机',
  54. orderNo: 'XFJ-001-20250612122200001'
  55. },
  56. {
  57. id: 'XFJ-001-20250612122200002',
  58. type: 'income',
  59. amount: 100,
  60. balance: 120,
  61. time: '2025年6月12日 12:22',
  62. location: '充值',
  63. orderNo: 'XFJ-001-20250612122200001'
  64. },
  65. {
  66. id: 'XFJ-001-20250612122200003',
  67. type: 'expense',
  68. amount: -15,
  69. balance: 20,
  70. time: '2025年6月12日 11:35',
  71. location: '第二饭堂002消费机',
  72. orderNo: 'XFJ-001-20250612113500001'
  73. }
  74. ]
  75. const handleCardClick = (record) => {
  76. console.log('点击了记录:', record)
  77. uni.showToast({
  78. title: `点击了${record.type === 'expense' ? '支出' : '充值'}记录`,
  79. icon: 'none'
  80. })
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .record-list {
  85. margin-top: 40rpx;
  86. .record-item {
  87. .record-header {
  88. display: flex;
  89. align-items: center;
  90. justify-content:flex-start;
  91. gap: 20rpx;
  92. margin-bottom: 20rpx;
  93. .amount {
  94. font-size: 36rpx;
  95. font-weight: bold;
  96. &.expense {
  97. color: #ff4d4f;
  98. }
  99. &.income {
  100. color: #52c41a;
  101. }
  102. }
  103. .balance {
  104. font-size: 24rpx;
  105. color: #999;
  106. }
  107. }
  108. .record-info {
  109. font-size: 24rpx;
  110. color: #666;
  111. .time {
  112. margin-bottom: 8rpx;
  113. }
  114. .location {
  115. margin-bottom: 8rpx;
  116. }
  117. .order-no {
  118. color: #999;
  119. font-size: 22rpx;
  120. }
  121. }
  122. }
  123. }
  124. </style>