<template>
	<!-- 充值免单 -->
	<view class="rechargeFree">
		<view class="rechargeFree_bg" @click="changeFree">
			<view class="left">
				<view class="icon">优惠</view>
				<view class="text">充值消费{{freeDingConfig.rechargeTimes}}倍（订单满￥{{freeDingConfig.rechargeThreshold}}元可用），本单立享免单！</view>
			</view>
			<u-checkbox-group iconPlacement="right" >
			    <u-checkbox :disabled="freeDisabled" v-model="rechargeFreeChecked" :checked="rechargeFreeChecked" @change="changeFree" activeColor="#E8AD7B" shape="circle" icon-size="36" size="36">
				</u-checkbox>
			</u-checkbox-group>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				freeDisabled: false,
			}
		},
		props:{
			shopUserInfo:{
				type: Object
			},
			freeDingConfig:{
				type: Object
			},
			payAmount: {
				type: Number
			},
			rechargeFreeChecked: {
				type: Boolean
			},
			
		},
		watch: {
			payAmount (newVal) {
				if ( this.payAmount < this.freeDingConfig.rechargeThreshold ) {
					this.freeDisabled = true
				} else {
					this.freeDisabled = false
				}
			}
		},
		mounted() {
			
		},
		methods: {
			
			/**
			 * 监听是否免单
			 */
			changeFree ( e ) {
				if ( this.freeDisabled ) {
					return;
				}
				this.$emit("changeFree",this.rechargeFreeChecked)
			}
		}
	}
</script>

<style lang="scss">
	// 充值免单
	.rechargeFree{
		// padding: 0 20rpx;
		margin-top: 32rpx;
		.rechargeFree_bg{
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 32rpx 24rpx;
			border-radius: 24rpx;
			background-color: #fff;
			.left{
				display: flex;
				align-items: center;
				.icon{
					width: 68rpx;
					height: 36rpx;
					text-align: center;
					line-height: 36rpx;
					background: linear-gradient( 180deg, #FEDE81 0%, #FEB263 100%);
					border-radius: 12rpx 0rpx 12rpx 0rpx;
					font-weight: 500;
					font-size: 20rpx;
					color: #FFFFFF;
					margin-right: 12rpx;
				}
				.text{
					width: 90%;
					font-weight: 500;
					font-size: 28rpx;
					color: #333333;
				}
			}
		}
	}
	
</style>
