<template>
	<view>
		<navigator style="position: relative;" hover-class="none" :url="'./add?id='+item.id"  v-for="(item,index) in bankList" :key="index" class="card card_bg">
			<view @click.stop="del(item.id)" style="position: absolute;right: 10rpx;top: 10rpx;">
				<u-icon name="close-circle" color="#fff" size="40"></u-icon>
			</view>
			
			<view class="top center" style="justify-content: flex-start;">
				<view class="center margin-top-10">
					<image :src="'/pagesB/static/bank/'+item.bankType+'.png'"></image>
				</view>
				<view class="">
					<text class="bankType">{{item.bankTypeLabel}}</text>
					<text class="bankAccountType">{{item.bankAccountTypeLabel}}</text>
				</view>
			</view>
			<view class="number">
				<text>{{item.cardNo}}</text>
			</view>
		</navigator>
		<navigator url="./add" class="card_add" hover-class="none">
			<view class="margin-bottom-10">
				<u-icon name="plus-circle-fill" color="#F5A85B" size="80"></u-icon>
			</view>
			<view  class="" style="color: #666666;">
				添加新的银行卡
			</view>
		</navigator>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bankList:[]
			}
		},
		onShow() {
			this.fetchCardList()
		},
		methods: {
			fetchCardList(){
				let params={
					userId:this.vuex_userId,
					size:10
				}
				this.$api.userBank.appList(params).then(res=>{
					this.bankList=res.data.records
				})
			},
			del(id){
				this.$dialog.showModal('确定要解绑？').then(()=>{
					this.$api.userBank.remove(id).then(res=>{
						if (res.success) {
							this.$u.toast('解绑成功!')
							this.fetchCardList()
						}
					})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.card_add{
		margin: 30rpx;
		border-radius:20rpx;
		padding: 40rpx 30rpx;
		background-color: #FFFFFF;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
	}
	
	.card {
		margin: 30rpx;
		border-radius:20rpx;
		padding: 40rpx 30rpx;
		background-image: linear-gradient(#F5A85B, #EF9944);
		display: flex;
		flex-direction: column;
		.top {
			display: flex;
			margin-bottom: 20rpx;

			image {
				border-radius: 50%;
				background-color: #FFFFFF;
				width: 70rpx;
				height: 70rpx;
			}
			
			.bankType{
				font-size: 36rpx;
				color: #FFFFFF;
				font-weight: 800;
				margin-left: 30rpx;
			}
			.bankAccountType{
				color: #F8E0C6;
				font-size: 26rpx;
				margin-left: 20rpx;
			}
		}

		.number {
			margin-left: 110rpx;
			color: #FFFFFF;
			font-weight: 800;
			font-size: 34rpx;
		}
	}
</style>
