wallet-detail.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view class="tabs flex-align-center">
  3. <view
  4. v-for="(item, index) in types"
  5. :key="index"
  6. class="fs-30 mr-60"
  7. :style="{
  8. color:
  9. type === item.value ? 'rgba(0, 0, 0, 1);' : 'rgba(0, 0, 0, 0.6);',
  10. }"
  11. @click="changeType(index)"
  12. >{{ item.label
  13. }}<view
  14. :style="{ opacity: type === item.value ? '1' : '0' }"
  15. class="active"
  16. ></view
  17. ></view>
  18. </view>
  19. <view
  20. class="pl-30 pr-30"
  21. v-if="infiniteScroller.list && infiniteScroller.list.length"
  22. >
  23. <view
  24. class="item flex-align-center"
  25. v-for="(item, index) in infiniteScroller.list"
  26. :key="index"
  27. @click="detail(index)"
  28. >
  29. <view>
  30. <view class="fs-30 fw-500" key="title" duration="300">{{
  31. typesMap[item.type - 1]
  32. }}</view>
  33. <view class="fs-24" style="color: rgba(0, 0, 0, 0.4)">余额</view>
  34. </view>
  35. <view class="ml-auto" style="text-align: right">
  36. <view class="fs-30 fw-500">
  37. <text>{{ item.type > 1 ? "- " : "" }}{{ item.amount }}</text>
  38. <text class="fs-24 ml-6">元</text>
  39. </view>
  40. <view class="fs-24" style="color: rgba(0, 0, 0, 0.4)">{{
  41. item.transaction_time
  42. }}</view>
  43. </view>
  44. <view class="ml-32" v-if="item.type === 3">
  45. <uni-icons type="right" size="12" color="rgba(0,0,0,0.4)"></uni-icons>
  46. </view>
  47. </view>
  48. </view>
  49. <view
  50. class="pt-40 flex-center fs-30"
  51. style="color: rgba(0, 0, 0, 0.6)"
  52. v-if="infiniteScroller.list && infiniteScroller.list.length <= 0"
  53. >暂无数据</view
  54. >
  55. </template>
  56. <script setup lang="ts">
  57. import { useInfiniteScroll } from "../../utils/infinite-scroll";
  58. import { onLoad, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
  59. import { ref } from "vue";
  60. import { fetchWallet } from "../../api/user";
  61. const type = ref(0);
  62. const types = ref([
  63. {
  64. label: "全部",
  65. value: 0,
  66. },
  67. {
  68. label: "充值",
  69. value: 1,
  70. },
  71. {
  72. label: "消费",
  73. value: 3,
  74. },
  75. ]);
  76. const typesMap = ref(["充值", "提现", "消费"]);
  77. const infiniteScroller = useInfiniteScroll(10, (page) => {
  78. return fetchWallet(type.value, page, 10).then((res: any) => {
  79. if (res && res.length) {
  80. res.forEach((item: any) => {
  81. item.amount = (Number(item.amount) / 100).toFixed(2);
  82. });
  83. }
  84. return res;
  85. });
  86. });
  87. const changeType = (index: number) => {
  88. type.value = types.value[index].value;
  89. infiniteScroller.refresh();
  90. };
  91. const detail = (index: number) => {
  92. if (!infiniteScroller.list) {
  93. return;
  94. }
  95. if (infiniteScroller.list[index].type === 3) {
  96. uni.navigateTo({
  97. url: `/pages-charge/order/order?id=${infiniteScroller.list[index].transaction_id}`,
  98. });
  99. }
  100. };
  101. onLoad(() => {
  102. infiniteScroller.refresh();
  103. });
  104. onReachBottom(() => {
  105. infiniteScroller.next();
  106. });
  107. onPullDownRefresh(() => {
  108. infiniteScroller.refresh();
  109. });
  110. </script>
  111. <style lang="scss">
  112. .tabs {
  113. height: 92rpx;
  114. padding: 0 40rpx;
  115. & > view {
  116. position: relative;
  117. height: 62rpx;
  118. .active {
  119. position: absolute;
  120. left: 50%;
  121. bottom: 0px;
  122. transform: translateX(-50%);
  123. width: 40rpx;
  124. height: 4rpx;
  125. border-radius: 4rpx;
  126. background-color: var(--color-primary);
  127. }
  128. }
  129. }
  130. .item {
  131. height: 170rpx;
  132. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  133. &:last-child {
  134. border-bottom: none;
  135. }
  136. }
  137. </style>