index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view class="balance">
  3. <!-- <view class="date_picker">
  4. <picker mode="date" :value="selectedDate" fields="month" @change="_bindDateChange">
  5. <view>{{ formattedDate }}</view>
  6. </picker>
  7. </view> -->
  8. <view class="balance_list">
  9. <!-- <view class="balance_date">2025年1月</view> -->
  10. <view class="balance_item" @click="_goDetail(item.id)" v-for="(item, index) in balanceList" :key="item.id">
  11. <view class="balance_item_fix">
  12. <view class="balance_item_left">
  13. <view style="margin-bottom: 10rpx">{{ item.type_state }}
  14. <text v-if="item.state" style="font-size: 20rpx">
  15. ({{ item.state }})
  16. </text>
  17. </view>
  18. <view>{{ item.insert_time }}</view>
  19. </view>
  20. <view class="balance_item_right">
  21. <view class="price">{{ item.prefix == 1 ? "+" : "-" }}{{ item.amount }}</view>
  22. <view>余额:{{ item.balance }}</view>
  23. </view>
  24. </view>
  25. <view class="alter_info"v-if="item.buy_type == 2 && item.status == 1" >若提现不成功,将在24小时内返回您的余额,可重新提现</view>
  26. </view>
  27. </view>
  28. <Empty v-if="balanceList.length == 0 && !isReqing" text="----- 还没有记录啦 -----" />
  29. <view class="to_bottom" v-if="isLast && balanceList.length"> -----到底啦-----</view>
  30. </view>
  31. </template>
  32. <script setup>
  33. import {
  34. ref,
  35. computed,
  36. onMounted
  37. } from "vue";
  38. import {
  39. onReachBottom,
  40. onPullDownRefresh
  41. } from "@dcloudio/uni-app";
  42. import Empty from "@/components/Empty/Empty.vue";
  43. import http from "@/utils/request";
  44. const selectedDate = ref("请选择日期");
  45. const balanceList = ref([]);
  46. const page = ref(1);
  47. const pageSize = ref(15);
  48. const isLast = ref(false);
  49. const isReqing = ref(false);
  50. const _bindDateChange = (e) => {
  51. selectedDate.value = e.detail.value;
  52. };
  53. onMounted(() => {
  54. _getBalacnelist();
  55. });
  56. const _goDetail = (record_id) => {
  57. uni.navigateTo({
  58. url: `/pages/balance/detail?record_id=${record_id}`,
  59. });
  60. };
  61. const _getBalacnelist = async () => {
  62. if (isReqing.value) return;
  63. isReqing.value = true;
  64. try {
  65. const callback = await http.request("api/custom_amount/get_record_list", {
  66. page: page.value,
  67. limit: pageSize.value
  68. });
  69. if (callback.code == "success") {
  70. if (callback.data.last_page <= page.value) isLast.value = true;
  71. const balanceListData = callback.data.data || [];
  72. balanceList.value = [...balanceList.value, ...balanceListData];
  73. }
  74. } finally {
  75. isReqing.value = false;
  76. }
  77. };
  78. onReachBottom(async () => {
  79. console.log("上拉加载");
  80. if (isLast.value || isReqing.value) return;
  81. page.value += 1;
  82. await _getBalacnelist();
  83. });
  84. onPullDownRefresh(async () => {
  85. page.value = 1;
  86. balanceList.value = [];
  87. isLast.value = false;
  88. await _getBalacnelist();
  89. uni.stopPullDownRefresh();
  90. });
  91. const formattedDate = computed(() => {
  92. if (selectedDate.value === "请选择日期") {
  93. return selectedDate.value;
  94. }
  95. const [year, month] = selectedDate.value.split("-");
  96. return `${year}年${parseInt(month)}月`;
  97. });
  98. </script>
  99. <style scoped lang="less">
  100. .balance {
  101. padding: 36rpx;
  102. box-sizing: border-box;
  103. width: 100vw;
  104. .date_picker {
  105. padding: 0 16rpx;
  106. border: 1px solid #e5e5e5;
  107. width: 250rpx;
  108. height: 60rpx;
  109. line-height: 60rpx;
  110. margin-bottom: 40rpx;
  111. }
  112. .balance_list {
  113. .balance_date {
  114. font-weight: bold;
  115. padding-bottom: 20rpx;
  116. border-bottom: 2rpx solid #ddd;
  117. }
  118. .balance_item {
  119. border-bottom: 1px solid #ddd;
  120. padding-bottom: 20rpx;
  121. .balance_item_fix {
  122. display: flex;
  123. justify-content: space-between;
  124. align-items: center;
  125. .balance_item_left,
  126. .balance_item_right {
  127. display: flex;
  128. flex-direction: column;
  129. font-size: 26rpx;
  130. padding-top: 20rpx;
  131. }
  132. .balance_item_right {
  133. align-items: flex-end;
  134. >.price {
  135. font-weight: bold;
  136. margin-bottom: 10rpx;
  137. &.red {
  138. color: #ff0000;
  139. }
  140. &.green {
  141. color: #00ff00;
  142. }
  143. }
  144. }
  145. }
  146. }
  147. .alter_info {
  148. display: block;
  149. color: #e03519;
  150. font-size: 20rpx;
  151. overflow: hidden;
  152. margin: 0rpx auto;
  153. line-height: 40rpx;
  154. padding: 5rpx 0rpx;
  155. }
  156. }
  157. }
  158. </style>