<template>
	<view class="coupon-list">
		<view class="coupon-box" v-for="item in list" :key="item.id" @click="checked(item)">
			<view class="coupon-head">
				<view class="coupon-sel coupon-checked" v-if="item.checked"></view>
				<view class="coupon-sel" v-else></view>
				<view class="coupon-title">
					<view class="coupon-title-1">{{item.couponTitle}}</view>
				</view>
				<view class="coupon-price">
					￥<text>{{item.couponAmount}}</text>
				</view>
			</view>
			<view class="coupon-desc">
				<view><u-icon class="icon" size="30" name="clock"></u-icon>{{item.validEndTimeStr}}</view>
				<view>
					<u-icon class="icon" size="30" name="info-circle"></u-icon>
					<text class="couponRuleDesc">{{item.couponRuleDesc}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		name: 'couponTpl',
		props: {
			showCheck: {
				type: Boolean,
				default: false
			},
			list:{
				type: Array,
				default: function(){
					return []
				}
			}
		},
		methods: {
			// 选中优惠卷
			checked(item) {
				if(this.showCheck){
					this.$emit('checkOk',item)
				}
			},
		},
	}
</script>

<style lang="scss">
	.coupon-list{
		padding: 25rpx;
	}
	.coupon-box.diabled{
		background: #999;
	}
	.coupon-box{
		margin-bottom: 30rpx;
		border-radius: 15rpx;
		box-shadow: 2rpx 2rpx 10rpx #ddd;
		background: #ff0000;
		color: #FFFFFF;
		.coupon-head{
			display: flex;
			align-items: center;
			padding: 20rpx 30rpx;
			position: relative;
			border-bottom: 15rpx dotted #FFFFFF;
			margin-bottom: -8rpx;
			.coupon-sel{
				position: absolute;
				width: 56rpx;
				height: 46rpx;
				right: 0;
				top: 0;
			}
			.coupon-checked{
				background: url(/static/img/select.png) no-repeat center;
				background-size: 100% 100%;
			}
			.coupon-title{
				flex-grow: 1;
				font-size: 32rpx;
			}
			.coupon-price{
				padding: 0 15rpx;
				color: #FFFFFF;
				text{
					font-size: 60rpx;
				}
			}
		}
		.coupon-desc{
			padding: 10rpx 30rpx;
			color: #666;
			background: #FFFFFF;
			border-bottom-left-radius:10rpx;
			border-bottom-right-radius: 10rpx;
			>view{
				padding: 5rpx 0;
				display: flex;
				align-items: flex-start;
			}
			.couponRuleDesc{
				width: 100%;
				word-wrap: break-word;
			}
			.icon{
				margin-right: 10rpx;
			}
		}
	}
</style>
