PaymentMethodsList.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view class="payment-list">
  3. <view v-for="item in list" :key="item.id" class="payment-card" :class="{ disabled: item.disabled }"
  4. @click="handleClick(item)">
  5. <view class="icon-wrapper">
  6. <image class="icon" :src="imgUrl + item.icon" mode="widthFix" />
  7. </view>
  8. <view class="content">
  9. <view class="header">
  10. <text class="title">{{ item.name }}</text>
  11. <view v-if="item.payTypeTags && item.payTypeTags.length > 0" class="pay-box">
  12. <view class="carousel-box">
  13. <!-- 超过3个:轮播 -->
  14. <view v-if="item.payTypeTags.length > 3" class="carousel-track carousel-animate">
  15. <view v-for="(icon, index) in item.payTypeTags" :key="index" class="pay-icon-container">
  16. <image class="pay-icon" :src="imgUrl + icon" mode="widthFix" />
  17. </view>
  18. <view v-for="(icon, index) in item.payTypeTags" :key="`copy-${index}`" class="pay-icon-container">
  19. <image class="pay-icon" :src="imgUrl + icon" mode="widthFix" />
  20. </view>
  21. </view>
  22. <!-- 小于等于3个:不轮播 -->
  23. <view v-else class="carousel-track">
  24. <view v-for="(icon, index) in item.payTypeTags" :key="index" class="pay-icon-container">
  25. <image class="pay-icon" :src="imgUrl + icon" mode="widthFix" />
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="info-list">
  32. <view class="info-item">
  33. <text class="info-label" v-t="'Label.ProcessingTime'" />
  34. <text class="info-value">{{ item.fundingTime || '--' }}</text>
  35. </view>
  36. <view class="info-item">
  37. <text class="info-label" v-t="'Label.Fee'" />
  38. <text class="info-value" v-if="item.feeType == 1">{{ item.free != null ? item.free + '%' : '-' }}</text>
  39. <text class="info-value" v-else-if="item.feeType == 2">${{ item.feeAmount != null ? item.feeAmount : '0'
  40. }}</text>
  41. <text class="info-value" v-else>{{ item.free != null ? item.free + '%' : '-' }}</text>
  42. </view>
  43. <view class="info-item">
  44. <text class="info-label">限制</text>
  45. <text class="info-value">{{ item.minAmount }}-{{ item.maxAmount }} {{ item.currency }}</text>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script setup>
  53. import { defineProps, defineEmits } from 'vue'
  54. import Config from '@/config/index'
  55. const { Code, Host05, Host80 } = Config
  56. const imgUrl = Host05
  57. // 定义 props,接收支付方式列表
  58. const props = defineProps({
  59. list: {
  60. type: Array,
  61. default: () => []
  62. }
  63. })
  64. // 定义事件,点击卡片时触发
  65. const emit = defineEmits(['select'])
  66. const handleClick = (item) => {
  67. if (!item.disabled) {
  68. emit('select', item)
  69. }
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. @import "@/uni.scss";
  74. .payment-list {
  75. display: grid;
  76. grid-row-gap: px2rpx(16);
  77. grid-column-gap: px2rpx(24);
  78. grid-template-columns: repeat(auto-fill, minmax(px2rpx(480), 1fr));
  79. }
  80. .payment-card {
  81. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  82. border-radius: px2rpx(12);
  83. padding: px2rpx(16);
  84. display: flex;
  85. align-items: flex-start;
  86. border: 1px solid rgba(14, 15, 12, 0.08);
  87. transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  88. cursor: pointer;
  89. box-sizing: border-box;
  90. gap: px2rpx(16);
  91. &:hover {
  92. transform: translateY(px2rpx(-2));
  93. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  94. box-shadow: 0 px2rpx(8) px2rpx(20) rgba(0, 0, 0, 0.06);
  95. border-color: var(--color-primary, #007aff);
  96. }
  97. &.disabled {
  98. opacity: 0.5;
  99. cursor: not-allowed;
  100. filter: grayscale(100%);
  101. }
  102. .icon-wrapper {
  103. width: px2rpx(120);
  104. height: px2rpx(120);
  105. flex-shrink: 0;
  106. border-radius: px2rpx(8);
  107. background-color: var(--color-zinc-50, #f9f9f9);
  108. display: flex;
  109. align-items: center;
  110. justify-content: center;
  111. overflow: hidden;
  112. .icon {
  113. width: 80%;
  114. }
  115. }
  116. .content {
  117. flex: 1;
  118. min-width: 0; // 防止文本溢出
  119. .header {
  120. margin-bottom: px2rpx(12);
  121. display: flex;
  122. align-items: center;
  123. justify-content: space-between;
  124. .title {
  125. font-size: px2rpx(16);
  126. font-weight: 700;
  127. color: var(--color-navy-900, #1e2a3a);
  128. word-break: break-all;
  129. flex: 1;
  130. margin-right: px2rpx(12);
  131. }
  132. .pay-box {
  133. width: px2rpx(32 * 3 + 8 * 2);
  134. flex-shrink: 0;
  135. overflow: hidden;
  136. }
  137. .carousel-box {
  138. width: 100%;
  139. overflow: hidden;
  140. }
  141. .carousel-track {
  142. display: flex;
  143. gap: px2rpx(8);
  144. width: max-content;
  145. }
  146. // 只有超过3个才加动画
  147. .carousel-animate {
  148. animation: carousel 8s linear infinite;
  149. }
  150. @keyframes carousel {
  151. 0% {
  152. transform: translateX(0);
  153. }
  154. 100% {
  155. transform: translateX(-50%);
  156. }
  157. }
  158. .pay-icon-container {
  159. width: px2rpx(32);
  160. height: px2rpx(32);
  161. display: flex;
  162. align-items: center;
  163. justify-content: center;
  164. background-color: var(--color-zinc-50, #f9f9f9);
  165. border-radius: px2rpx(6);
  166. border: 1px solid var(--color-zinc-100, #f3f4f6);
  167. flex-shrink: 0;
  168. }
  169. .pay-icon {
  170. width: px2rpx(20);
  171. height: px2rpx(20);
  172. object-fit: contain;
  173. }
  174. }
  175. .info-list {
  176. .info-item {
  177. display: flex;
  178. justify-content: space-between;
  179. align-items: center;
  180. margin-bottom: px2rpx(8);
  181. font-size: px2rpx(13);
  182. line-height: 1.4;
  183. .info-label {
  184. color: var(--color-zinc-500, #7f8c8d);
  185. margin-right: px2rpx(8);
  186. white-space: nowrap;
  187. }
  188. .info-value {
  189. color: var(--color-navy-900, #1e2a3a);
  190. font-weight: 600;
  191. text-align: right;
  192. word-break: break-all;
  193. }
  194. &:last-child {
  195. margin-bottom: 0;
  196. }
  197. }
  198. }
  199. }
  200. }
  201. /* 移动端适配 */
  202. @media screen and (max-width: 768px) {
  203. .payment-list {
  204. grid-template-columns: 1fr;
  205. grid-row-gap: px2rpx(12);
  206. }
  207. .payment-card {
  208. padding: px2rpx(12);
  209. gap: px2rpx(12);
  210. .icon-wrapper {
  211. width: px2rpx(90);
  212. height: px2rpx(90);
  213. }
  214. .content {
  215. .header {
  216. margin-bottom: px2rpx(8);
  217. .title {
  218. font-size: px2rpx(15);
  219. }
  220. }
  221. .info-list {
  222. .info-item {
  223. margin-bottom: px2rpx(4);
  224. font-size: px2rpx(12);
  225. }
  226. }
  227. }
  228. }
  229. }
  230. </style>