cards.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <div>
  3. <div class="add-apply" @click="addApply" v-if="kycList.length > 0 && cardList.length > 0 ">{{ t('cards.p10') }}</div>
  4. <FirstApply v-if="cardList.length == 0" />
  5. <VirtualCard v-else />
  6. </div>
  7. </template>
  8. <script setup lang="ts">
  9. import VirtualCard from '@/components/VirtualCard.vue'
  10. import FirstApply from '@/components/FirstApply.vue'
  11. import { ucardApi } from '@/api/ucard'
  12. import type { CardInfo } from '@/api/ucard'
  13. import { useI18n } from 'vue-i18n'
  14. import { useRouter } from 'vue-router'
  15. import useUserStore from '@/stores/use-user-store'
  16. const userStore = useUserStore()
  17. const router = useRouter()
  18. const { t } = useI18n()
  19. const globalStore = useGlobalStore()
  20. const cardList = ref<CardInfo[]>([])
  21. const kycList = ref<CardInfo[]>([])
  22. const getCardList = async () => {
  23. globalStore.setFullScreenLoading(true)
  24. try {
  25. const [response1, response2] = await Promise.all([
  26. ucardApi.cardList({ page: { current: 1, row: 10 } }),
  27. ucardApi.cardKycTypesList({ page: { current: 1, row: 10 } }),
  28. ])
  29. const mergedMap = new Map()
  30. let [data1, data2] = await Promise.all([response1.data, response2.data])
  31. // data2 = data2.map((i) => {
  32. // return { ...i, kycStatus: 1,applyStatus :null }
  33. // })
  34. if (data1.length > 0) {
  35. data1.forEach((item: any) => {
  36. mergedMap.set(item.cardTypeId, { ...item })
  37. })
  38. }
  39. if (data2.length > 0) {
  40. data2.forEach((item: any) => {
  41. const existing = mergedMap.get(item.cardTypeId) || {}
  42. const { id, ...rest } = existing
  43. mergedMap.set(item.cardTypeId, { ...rest, ...item, id })
  44. })
  45. }
  46. const mergedArray = Array.from(mergedMap.values())
  47. let a = mergedArray.map((i) => {
  48. if (i.cardNo) {
  49. i.isOk = true
  50. } else {
  51. i.isOk = false
  52. i.cardNo = '**** **** **** ****'
  53. }
  54. return i
  55. })
  56. // 待申请
  57. let b = mergedArray.filter((i) => {
  58. return i.kycStatus == null
  59. })
  60. // 已申请-银行卡
  61. let c = a.filter((i) => {
  62. return i.kycStatus != null
  63. })
  64. cardList.value = c
  65. kycList.value = b
  66. console.log(c,'cardList');
  67. console.log(b,'kycList');
  68. userStore.saveUserCard(cardList.value)
  69. } catch (error) {
  70. } finally {
  71. globalStore.setFullScreenLoading(false)
  72. }
  73. }
  74. const addApply = () => {
  75. router.push('/select/card')
  76. }
  77. onMounted(async () => {
  78. getCardList()
  79. })
  80. </script>
  81. <style scoped lang="scss">
  82. .add-apply {
  83. position: fixed;
  84. top: 14px;
  85. right: 10px;
  86. cursor: pointer;
  87. z-index: 100;
  88. display: flex;
  89. flex-direction: row;
  90. justify-content: center;
  91. align-items: center;
  92. gap: 4px;
  93. min-width: 100px;
  94. padding: 0 10px;
  95. height: 30px;
  96. background: #ea002a;
  97. border-radius: 100px;
  98. font-size: 14px;
  99. color: #ffffff;
  100. }
  101. </style>