balance.vue 7.1 KB

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