bankCard-select.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <u-popup mode="bottom" :border-radius="20"
  3. :safe-area-inset-bottom="true"
  4. v-model="show" @close="close"
  5. >
  6. <view class="popup-container">
  7. <view class="popup-header">
  8. <view class="title">选择提现银行卡</view>
  9. <view class="subtitle">请留意各银行到账时间</view>
  10. </view>
  11. <scroll-view scroll-y class="card-list-scroll">
  12. <!-- 银行卡列表 -->
  13. <view
  14. class="card-item"
  15. v-for="card in dataList"
  16. :key="card.id"
  17. @click="selectCard(card)"
  18. >
  19. <image class="bank-icon" :src="card.icon" mode="aspectFit"></image>
  20. <text class="card-name">{{ card.name }} ({{ card.last4 }})</text>
  21. <u-icon v-if="selectedCardId === card.id" name="checkbox-mark" color="#2979ff" size="40"></u-icon>
  22. </view>
  23. <!-- 添加银行卡 -->
  24. <view class="card-item add-card" @click="addCard">
  25. <image class="bank-icon" src="/static/groupMeal/icon_bankadd.png" mode="aspectFit"></image>
  26. <text class="card-name">添加银行卡</text>
  27. <u-icon name="arrow-right" color="#C7C6CA" size="32"></u-icon>
  28. </view>
  29. </scroll-view>
  30. </view>
  31. </u-popup>
  32. </template>
  33. <script>
  34. export default {
  35. name: 'BankCardSelector',
  36. props: {
  37. // 银行卡列表
  38. dataList: {
  39. type: Array,
  40. default: () => []
  41. },
  42. // 当前选中的银行卡ID (v-model)
  43. value: {
  44. type: [String, Number],
  45. default: ''
  46. }
  47. },
  48. data() {
  49. return {
  50. show: false,
  51. selectedCardId: this.value
  52. };
  53. },
  54. watch: {
  55. // 监听v-model的变化,同步内部状态
  56. value(newVal) {
  57. this.selectedCardId = newVal;
  58. }
  59. },
  60. methods: {
  61. open() {
  62. this.show = true;
  63. },
  64. close() {
  65. this.show = false;
  66. },
  67. selectCard(card) {
  68. this.selectedCardId = card.id;
  69. // 通过v-model更新父组件的值
  70. this.$emit('input', card.id);
  71. this.$emit('select', card);
  72. this.close();
  73. },
  74. addCard() {
  75. console.log('跳转到添加银行卡页面');
  76. uni.navigateTo({
  77. url: '/pages/wallet/AddBankCard' // 假设这是添加银行卡的页面路径
  78. });
  79. this.close();
  80. }
  81. }
  82. };
  83. </script>
  84. <style lang="scss" scoped>
  85. ::v-deep .u-drawer-bottom {
  86. background: #F7F8FC;
  87. }
  88. .popup-container {
  89. .popup-header {
  90. padding: 20rpx 30rpx;
  91. text-align: center;
  92. border-bottom: 1rpx solid #f0f0f0;
  93. .title {
  94. font-size: 30rpx;
  95. font-weight: 500;
  96. color: #232832;
  97. }
  98. .subtitle {
  99. font-weight: 400;
  100. font-size: 24rpx;
  101. color: rgba(51,51,51,0.8);
  102. }
  103. }
  104. .card-list-scroll {
  105. max-height: 60vh; // 限制最大高度,超出则滚动
  106. background: #fff;
  107. }
  108. .card-item {
  109. display: flex;
  110. align-items: center;
  111. padding: 30rpx;
  112. border-bottom: 1rpx solid #f0f0f0;
  113. .bank-icon {
  114. width: 40rpx;
  115. height: 40rpx;
  116. margin-right: 20rpx;
  117. }
  118. .card-name {
  119. flex: 1;
  120. font-size: 30rpx;
  121. color: #303133;
  122. }
  123. }
  124. }
  125. </style>