bankCard.vue 2.0 KB
<template>
	<view class="bank_card">
		<view class="head">
			<view class="left">
				<image class="bank_logo" :src="`https://apimg.alipay.com/combo.png?d=cashier&t=${bankCode}`" mode="widthFix"></image>
			</view>
			<view class="right">
				<text class="name">{{ bankInfo.accountBank.split(' ')[0] }}</text>
				<text class="type">{{ bankInfo.accountBank.split(' ')[1] }}</text>
			</view>
		</view>
		<view class="bank_number">
			{{ hideBankCard(bankInfo.account) }}
		</view>
	</view>
</template>

<script>
export default {
	props: {
		bankInfo: {
			type: Object,
			require: true
		},
		bankCode: {
			type: String,
			default: 'ABC'
		}
	},
	computed: {
		// 隐藏银行卡中间号码
		hideBankCard() {
			return (value) => {
				if (value && value.length > 8) {
					return `${value.substring(0, 4)} ${"*".repeat(value.length - 8).replace(/(.{4})/g, `$1 `)}${value.length % 4 ? " " : ""}${value.slice(-4)}`
				}
				return value
			}
		}
	},
}
</script>

<style lang="scss" scoped>
.bank_card{
	padding: 40rpx;
	border-radius: 16rpx;
	box-shadow: rgba(50, 50, 93, 0.25) 0px 50px 100px -20px, rgba(0, 0, 0, 0.3) 0px 30px 60px -30px, rgba(10, 37, 64, 0.35) 0px -2px 6px 0px inset;
	.head{
		display: flex;
		height: 100rpx;
		.left{
			display: flex;
			align-items: center;
			justify-content: center;
			width: 256rpx;
			height: 72rpx;
			border-radius: 50%;
			background-color: #FFD9DB;
			margin-right: 20rpx;
			.bank_logo{
				width: 100%;
				height: 100%;
			}
		}
		.right{
			display: flex;
			flex-direction: column;
			gap: 10rpx;
			flex: 1;
			.name{
				font-size: 32rpx;
				line-height: 42rpx;
				font-weight: 500;
			}
			.type {
				line-height: 38rpx;
				font-size: 28rpx;
			}
		}
	}
	.bank_number{
		margin-top: 20rpx;
		padding: 0 16rpx;
		text-align: right;
		font-size: 40rpx;
		line-height: 64rpx;
		font-weight: 600;
	}
}
.redType{
	background-color: #ca0000;
}
.greenType{
	background-color: #54aa7e;
}
.grayType{
	background-color: #4386c9;
}
.blueType{
	background-color: #009300;
}
</style>