balance.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <cwg-page-wrapper>
  3. <view class="page">
  4. <view class="apply-card-footer">
  5. <cwg-load-more-wrapper :loading="loading" :finished="finished" @reach-bottom="loadMore">
  6. <view v-if="cardList.length > 0">
  7. <view class="kyc-list">
  8. <view v-for="item in cardList" :key="item.id" class="kyc-item">
  9. <view class="g">
  10. <view class="g-l">
  11. <view class="g-item">
  12. <view class="label a1 ellipsis">
  13. <text> {{ t(walletBalanceTypeMap[item.type]) }}</text>
  14. </view>
  15. <view class="status" :class="statusClass1(item.status)">
  16. <text v-if="item.status == '2'" v-t="'card.Status.t1'"></text>
  17. <text v-else-if="item.status == '3'" v-t="'card.Status.t2'"></text>
  18. <text v-else v-t="'card.Status.t3'"></text>
  19. </view>
  20. </view>
  21. <view class="g-item g-item1">
  22. <view v-t="'card.Form.f55'" class="label1 a2"></view>
  23. <view class="label a1">{{ item.amount }} USD</view>
  24. </view>
  25. <view class="g-item g-item1">
  26. <view v-t="'card.Form.f30'" class="label1 a2"></view>
  27. <view class="label a1">{{ item.fee }} USD</view>
  28. </view>
  29. <view class="g-item">
  30. <view class="label a3"></view>
  31. <view class="label a3">{{ item.addTime }}</view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <cwg-empty-state v-if="cardList.length == 0" :title="t('empty-state.t1')"
  39. :text="t('empty-state.c1')" />
  40. </cwg-load-more-wrapper>
  41. </view>
  42. </view>
  43. </cwg-page-wrapper>
  44. </template>
  45. <script setup lang="ts">
  46. import { ref, onMounted, watch, computed } from "vue";
  47. import { showToast } from "@/utils/toast";
  48. import { onLoad } from '@dcloudio/uni-app'
  49. import useRouter from "@/hooks/useRouter";
  50. import { useI18n } from "vue-i18n";
  51. import { ucardApi } from "@/api/ucard";
  52. import { walletBalanceTypeMap } from '@/utils/dataMap';
  53. const { t } = useI18n();
  54. const router = useRouter();
  55. onLoad((options) => {
  56. // id.value = options.id
  57. // type.value = options.type
  58. })
  59. const status: Record<string, string> = {
  60. success: t('card.Status.t6'),
  61. fail: t('card.Status.t7'),
  62. processing: t('card.Status.t3'),
  63. wait_process: t('card.Status.t3'),
  64. cancel: t('card.New2.p3'),
  65. }
  66. function statusClass1(status: string) {
  67. switch (status) {
  68. case 2:
  69. return 'status-default status-success'
  70. case 3:
  71. return 'status-default status-error'
  72. default:
  73. return 'status-default'
  74. }
  75. }
  76. // 分页字段
  77. const page = ref(1)
  78. const pageSize = 10
  79. // 状态
  80. const loading = ref(false)
  81. const finished = ref(false)
  82. const loadingInit = ref(true) // 控制首次加载避免闪 empty
  83. const cardList = ref<CardInfo[]>([])
  84. const search = ref({})
  85. // 加载列表
  86. async function getCardList(isLoadMore = false) {
  87. if (loading.value || finished.value) return
  88. loading.value = true
  89. try {
  90. const res = await ucardApi.getRecordPage({
  91. page: { current: page.value, row: pageSize }
  92. })
  93. const data = res.code === 200 ? res.data || [] : []
  94. if (isLoadMore) {
  95. cardList.value.push(...data)
  96. } else {
  97. cardList.value = data
  98. }
  99. // 判断是否还有更多
  100. if (data.length < pageSize) {
  101. finished.value = true
  102. }
  103. } catch (e) {
  104. console.error(e)
  105. } finally {
  106. loading.value = false
  107. loadingInit.value = false
  108. }
  109. }
  110. // 父组件触底触发
  111. function loadMore() {
  112. console.log(234234);
  113. if (finished.value || loading.value) return
  114. page.value++
  115. getCardList(true)
  116. }
  117. onMounted(async () => {
  118. getCardList()
  119. })
  120. </script>
  121. <style scoped lang="scss">
  122. @import "@/uni.scss";
  123. .apply-card-footer {
  124. width: 100%;
  125. }
  126. .kyc-item {
  127. display: flex;
  128. align-items: center;
  129. flex-direction: column;
  130. padding: px2rpx(12);
  131. border-bottom: 1px solid var(--border, #333);
  132. font-size: px2rpx(16);
  133. background: var(--action-bg);
  134. border-radius: px2rpx(16);
  135. margin-bottom: px2rpx(16);
  136. border: 1px solid rgba(214, 255, 0, 0.2);
  137. box-shadow: 0 px2rpx(2) px2rpx(8) rgba(0, 0, 0, 0.08);
  138. gap: px2rpx(16);
  139. }
  140. .kyc-item:last-child {
  141. border-bottom: none;
  142. }
  143. .g {
  144. width: 100%;
  145. img {
  146. width: px2rpx(56);
  147. height: px2rpx(35);
  148. }
  149. .g-l {
  150. width: 100%;
  151. margin: 0;
  152. .g-item {
  153. margin-bottom: 0;
  154. }
  155. .g-item1 {
  156. justify-content: start;
  157. align-items: center;
  158. }
  159. .label {
  160. font-family: 'Roboto';
  161. font-style: normal;
  162. font-weight: 600;
  163. font-size: px2rpx(14);
  164. line-height: px2rpx(20);
  165. text-align: left;
  166. color: #1a1a1a;
  167. width: px2rpx(180);
  168. }
  169. .label1 {
  170. font-family: 'Roboto';
  171. font-style: normal;
  172. font-weight: 600;
  173. font-size: px2rpx(14);
  174. line-height: px2rpx(20);
  175. text-align: left;
  176. color: #1a1a1a;
  177. max-width: px2rpx(180);
  178. padding-right: px2rpx(10);
  179. }
  180. .a2 {
  181. color: #6b7280;
  182. font-size: px2rpx(12);
  183. line-height: px2rpx(16);
  184. }
  185. .a3 {
  186. color: #8e8a8a;
  187. font-family: Roboto;
  188. font-size: px2rpx(14);
  189. font-style: normal;
  190. font-weight: 400;
  191. line-height: px2rpx(36);
  192. letter-spacing: px2rpx(0.07);
  193. text-align: end;
  194. }
  195. }
  196. /* .g-l1 {
  197. margin-left: 0;
  198. } */
  199. }
  200. </style>