<template>
	<view class="content">
		<view class="box vflex acenter jcenter" v-if="pageList.length == 0">
			<view class="tips_img">
				<image src="/static/images/mine/tips_yellow.png" class="img"></image>
			</view>
			<view class="text_style1">您还未绑定银行卡</view>
		</view>
		<view class="vflex" v-else>
			<block v-for="(item,index) in pageList" :key="index">
				<view class="box1" @click="open(item.id)">
					<view class="hflex">
						<!-- <image :src="item.icon" class="bank_info"></image> -->
						<view class="name">{{item.bank}}</view>
					</view>
					<view class="card">{{item.number}}</view>
				</view>
			</block>
		</view>
		<view class="add hflex acenter jcenter" @click="add">
			<u-icon name="plus-circle" color="#506DFF" size="19"></u-icon>
			<view class="add_text">去添加</view>
		</view>
		<u-popup :show="show" round="10" mode="bottom" @close="close" :safeAreaInsetBottom="false">
			<view class="popu">
				<view class="popu_text hflex acenter jcenter" @click="delbank">解除绑定</view>
				<view class="popu_btn hflex acenter jcenter" @click="close">取消</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import $api from '@/static/js/api.js'
	var that = ''
	export default {
		data() {
			return {
				pageList: [
					
				],
				show: false,
				id: ''
			}
		},
		onLoad() {
			that = this
		},
		onShow() {
			that.getBank()
		},
		methods: {
			getBank() {
				$api.req({
					url: '/data/api.business.User/user_bank',
					// method: 'POST'
				}, function(res) {
					if(res.code == 1) {
						that.pageList = res.data.list
						for(var i=0;i<res.data.list.length;i++) {
							that.pageList[i].number = res.data.list[i].number.substr(-4)
							that.pageList[i].number = "**** **** **** " + that.pageList[i].number
						}
						// console.log(that.pageList);
					}
				})
			},
			add() {
				$api.jump('/pages/mine/wallet/add')
			},
			open(id) {
				that.id = id
				that.show = true
			},
			close() {
				that.show = false
			},
			delbank() {
				$api.req({
					url: '/data/api.business.User/bank_del',
					method: 'POST',
					data: {
						bank_id: that.id
					}
				}, function(res) {
					if(res.code == 1) {
						that.close()
						$api.info(res.info)
						that.getBank()
					}
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	.content {
		background: #F5F5F5;
		padding: 0 30rpx;
		.box {
			
			.tips_img {
				margin: 68rpx auto 28rpx;
				.img {
					width: 64rpx;
					height: 64rpx;
				}
			}
			.text_style1 {
				font-size: 32rpx;
				font-weight: 400;
				color: #222222;
				line-height: 44rpx;
				padding-bottom: 56rpx;
			}
		}
		.box1 {
			width: 100%;
			height: 200rpx;
			background: #506DFF;
			border-radius: 12rpx;
			margin-top: 20rpx;
			box-sizing: border-box;
			padding: 36rpx 40rpx 0;
			.bank_info {
				width: 52rpx;
				height: 52rpx;
			}
			.name {
				font-size: 28rpx;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 40rpx;
				padding-left: 20rpx;
			}
			.card {
				// vertical-align:middle;
				padding-top: 34rpx;
				font-size: 48rpx;
				font-weight: 400;
				color: #FFFFFF;
				padding-left: 32rpx;
			}
		}
		.add {
			margin-top: 20rpx;
			width: 100%;
			height: 136rpx;
			background: #FFFFFF;
			border-radius: 12rpx;
			.add_text {
				font-size: 36rpx;
				font-weight: 400;
				color: #506DFF;
				line-height: 50rpx;
				padding-left: 6rpx;
			}
		}
		.popu {
			width: 100%;
			height: 316rpx;
			background: #FFFFFF;
			border-radius: 40rpx 40rpx 0px 0px;
			.popu_text {
				font-size: 32rpx;
				font-weight: 400;
				color: #000000;
				line-height: 44rpx;
				padding: 52rpx 0 60rpx;
			}
			.popu_btn {
				margin: 0 auto;
				width: 650rpx;
				height: 80rpx;
				background: #F4F4F4;
				border-radius: 52rpx;
				font-size: 28rpx;
				font-weight: 400;
				color: #222222;
			}
		}
	}
</style>