<template>
	<u-popup mode="bottom" border-radius="20" :popup="false" v-model="show" :maskCloseAble="true" length="auto"
	 :safeAreaInsetBottom="true" @close="popupClose" :z-index="9999" close-icon="cross" :closeable="true">
		<view class="coupon">
		 <scroll-view :scroll-y="true" style="max-height: 70vh;"> 
			<view class="title">储蓄卡</view>
			<view class="chosentips">请选择要使用的储蓄卡</view>
			<view class="details">
				<view class="item" v-for="(x, i) in ts" :key="i" :style="{'margin-bottom':ts.length==i+1?'50px':'10px'}">
					<view class="item-left">
						<view style="font-weight: bold;width: 100%;overflow: hidden;display: inline-block;white-space: nowrap; text-overflow:ellipsis;">
							{{x.Name}}
						</view>
						<view style="font-size: 11px;color: #818181;margin-top: 9px;">
							有效期{{x.EndTime}}
						</view>
					</view>
					<view style="width: 1px;flex: 1;display: flex;align-items: flex-end;color: #FF4544;font-size: 12px;justify-content: flex-end;">
						余额￥ <text style="font-size: 20px;">{{x.SurplusPrice}}</text>
					</view>
					<view class="chosen">
						<u-radio-group v-model="currentChosen">
							<u-radio shape="circle" :name="x.Id" :icon-size="36" :active-color="mc"></u-radio>
						</u-radio-group>
					</view>
					<view class="positop">
						储蓄卡
					</view>
					
				</view>
			</view>
			</scroll-view>
			<view class="btton-box">
				<u-button size="80" :ripple="true" shape="circle" :custom-style="{
            backgroundColor: mc,
            height: '80rpx',
            color: '#FFF',
            fontSize: '14px',
            margin: '0 3vw',
            width: '90vw',
          }"
				 @click="popupClose">确定</u-button>
			</view>
		</view>
	</u-popup>
</template>

<script>
	export default {
		props: ["list", "current"],
		data() {
			return {
				mc: "",
				show: true,
				currentChosen: "",
				ts: []
			};
		},
		mounted() {
			this.mc = this.$uiConfig.mainColor;
			this.currentChosen = this.current;
			this.ts = this.list
			this.ts.forEach(x => {
				x.EndTime = x.EndTime.split(' ')[0].replace(/-/g, '.')
			})
		},
		methods: {
			popupClose() {
				if (this.currentChosen != this.current) {
					this.$emit('close', this.currentChosen)
				} else {
					this.$emit('close', -1)
				}
			}
		},
	};
</script>

<style>
	.coupon {
		max-height: 70vh;
		background: #f5f5f5;
		/* padding-bottom: 50px; */
		text-align: left !important;
		border-top-left-radius: 20rpx;
		border-top-right-radius: 20rpx;
		/* overflow: scroll; */
		overflow: hidden;
	}

	.coupon .title {
		font-size: 22px;
		color: #000;
		padding: 20px;
		background: #fff;
	}

	.coupon .chosentips {
		padding: 12px 20px;
		border-bottom: 1px solid #f5f5f5;
		border-top: 1px solid #f5f5f5;
		color: #777;
		background: #fff;
		font-size: 12px;
	}

	.coupon .details {
		padding: 10px;
		display: flex;
		flex-direction: column;
	}

	.coupon .details .item {
		display: flex;
		margin-bottom: 10px;
		padding: 35px 15px 15px;
		background: #fff;
		position: relative;
		align-items: center;
		border-radius: 5px;
	}
	
	.coupon .details .item .item-left{
		width: calc(100vw - 260rpx - 55px);
		font-size: 14px;
		color: #000000;
		
	}
	.coupon .details .item  .chosen {
		width: 20px;
		position: absolute;
		right: 10px;
		top: 10px;
	}
	.coupon .positop{
		position: absolute;
		left: 0;
		top: 0;
		width: 55px;
		height: 21px;
		background: linear-gradient(90deg, #FF9966, #E95252);
		font-size: 12px;
		color: #FFFFFF;
		line-height: 21px;
		text-align: center;
		border-top-left-radius:5px ;
		border-bottom-right-radius: 5px;
	}
	
	
	

	.pesongBox .btton-box {
		height: 50px;
		display: flex;
		padding: 5px 10px;
		border-top: 1px solid #f5f5f5;
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		align-items: center;
		background: #fff;
	}
</style>
