accountTransferHistory.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <!-- 月份选择器 -->
  3. <view class="date-picker">
  4. <view class="date-picker-item arrow left-arrow">
  5. <uni-icons type="left" size="30" @click="plusMonth(-1)"></uni-icons>
  6. </view>
  7. <view class="date-picker-item">
  8. <picker mode="date" fields="month" :value="currentMonth" @change="monthChange">
  9. <view class="picker-view">{{ currentMonth }}</view>
  10. </picker>
  11. </view>
  12. <view class="date-picker-item arrow right-arrow">
  13. <uni-icons type="right" size="30" @click="plusMonth(1)"></uni-icons>
  14. </view>
  15. </view>
  16. <!-- 数据列表 -->
  17. <uni-list :border="true">
  18. <uni-list-item v-for="item in listData" :key="item.id">
  19. <template v-slot:body>
  20. <view class="item-box">
  21. <span class="item-label">转账类型</span>
  22. <span class="item-label">{{ item.transferCategory == 'TRANSFER' ? '转账' : '结算' }}</span>
  23. </view>
  24. <view class="item-box" v-if="item.transferCategory == 'TRANSFER'">
  25. <span class="item-label">转出账户</span>
  26. <span class="item-label">{{ item.senderAccountName }}</span>
  27. </view>
  28. <view class="item-box" v-if="item.transferCategory == 'TRANSFER'">
  29. <span class="item-label">转出账户转入前积分</span>
  30. <span class="item-label">{{ item.saPointsBeforeTransfer }}</span>
  31. </view>
  32. <view class="item-box" v-if="item.transferCategory == 'TRANSFER'">
  33. <span class="item-label">转出账户转入后积分</span>
  34. <span class="item-label">{{ item.saPointsAfterTransfer }}</span>
  35. </view>
  36. <view class="item-box">
  37. <span class="item-label">转出账户</span>
  38. <span class="item-label">{{ item.recipientAccountName }}</span>
  39. </view>
  40. <view class="item-box">
  41. <span class="item-label">转入账户转入前积分</span>
  42. <span class="item-label">{{ item.raPointsBeforeTransfer }}</span>
  43. </view>
  44. <view class="item-box">
  45. <span class="item-label">转入账户转入后积分</span>
  46. <span class="item-label">{{ item.raPointsAfterTransfer }}</span>
  47. </view>
  48. <view class="item-box">
  49. <span class="item-label">转账积分</span>
  50. <span class="item-label">{{ item.transferPoints }}</span>
  51. </view>
  52. <view class="item-box">
  53. <span class="item-label">转账时间</span>
  54. <span class="item-value">{{ item.transferTime }}</span>
  55. </view>
  56. </template>
  57. </uni-list-item>
  58. </uni-list>
  59. <uni-load-more status="no-more" v-if="!listData || listData.length == 0" />
  60. </template>
  61. <script setup>
  62. import { ref } from 'vue';
  63. import { accountApi } from '@/apis/apis';
  64. import { onLoad, onShow, onPullDownRefresh } from '@dcloudio/uni-app';
  65. // 属性
  66. /**
  67. * 当前选中的月
  68. */
  69. const currentMonth = ref('2025-04');
  70. /**
  71. * 数据
  72. */
  73. const listData = ref([]);
  74. // 方法
  75. /**
  76. * 月份选择器
  77. */
  78. const monthChange = (e) => {
  79. currentMonth.value = e.detail.value
  80. }
  81. /**
  82. * 月份加减
  83. */
  84. const plusMonth = (num) => {
  85. // 转换成date对象
  86. let tempDate = new Date(currentMonth.value);
  87. // 月份加减
  88. tempDate.setMonth(tempDate.getMonth() + num);
  89. // daet对象转换成字符串
  90. let tempYear = tempDate.getFullYear();
  91. let tempMonth = (tempDate.getMonth() + 1).toString().padStart(2, "0"); // 月份从0开始,+1后格式化为两位数
  92. currentMonth.value = `${tempYear}-${tempMonth}`;
  93. loadData();
  94. }
  95. /**
  96. * 获取转账数据
  97. */
  98. const loadData = async () => {
  99. let res = await accountApi.queryTransferHistory({ 'transferMonth': currentMonth.value });
  100. listData.value = res ? res : [];
  101. }
  102. // 生命周期
  103. onLoad(() => {
  104. // daet对象转换成字符串
  105. let tempDate = new Date();
  106. let tempYear = tempDate.getFullYear();
  107. let tempMonth = (tempDate.getMonth() + 1).toString().padStart(2, "0"); // 月份从0开始,+1后格式化为两位数
  108. currentMonth.value = `${tempYear}-${tempMonth}`;
  109. });
  110. onShow(() => {
  111. loadData();
  112. })
  113. onPullDownRefresh(() => {
  114. loadData();
  115. });
  116. </script>
  117. <style lang="scss" scoped>
  118. .date-picker {
  119. display: flex;
  120. .date-picker-item {
  121. flex: 1;
  122. picker {
  123. width: 100%;
  124. height: 100%;
  125. display: flex;
  126. display: flex;
  127. /* 水平居中 */
  128. justify-content: center;
  129. /* 垂直居中 */
  130. align-items: center;
  131. }
  132. }
  133. .arrow {
  134. /* 启用 Flexbox 布局 */
  135. display: flex;
  136. /* 垂直居中 */
  137. align-items: center;
  138. }
  139. .left-arrow {
  140. /* 将子元素对齐到右侧 */
  141. justify-content: flex-end;
  142. }
  143. .right-arrow {
  144. /* 将子元素对齐到右侧 */
  145. justify-content: flex-start;
  146. }
  147. }
  148. ::v-deep .uni-list-item__container .uni-list-item__header {
  149. width: 0%;
  150. }
  151. ::v-deep .uni-list-item__container>view {
  152. width: 100%;
  153. }
  154. .item-box {
  155. display: flex;
  156. justify-content: space-between;
  157. align-items: center;
  158. width: 100%;
  159. }
  160. </style>