<template>
	<view class="aircondition-box">
		<view class="aircondition-control">
			<view class="aircondition-toogle">
				<view class="toogle-icon-text">
					<view class="toogle-icon">
						<uni-icons type="icon-fentikongtiaokongtiaojieneng" custom-prefix="iconfont" color="#fff"
							size="26">
						</uni-icons>
					</view>
					<text class="text">{{title}}</text>
				</view>
				<uni-icons type="icon-caozuo-kaiguan" custom-prefix="iconfont" size="40"
					:color="!isOpen?'#c3c3c3':'#08979c'" @click="isOpen = !isOpen">
				</uni-icons>
			</view>
			<view class="aircondition-show">
				<view class="aircondition-reduce aircondition-icon">
					<uni-icons type="icon-jian" custom-prefix="iconfont" color="#8c8c8c"></uni-icons>
				</view>
				<view class="aircondition-label">
					<view class="value">{{temp}}</view>
					<view class="unit">°C</view>
				</view>
				<view class="aircondition-add aircondition-icon">
					<uni-icons type="plusempty" color="#8c8c8c"></uni-icons>
				</view>
			</view>
			<l-slider v-model="temp" :min="16" :max="30" :step="0.5"></l-slider>
		</view>
		<view class="aircondition-model">
			<view class="box" @click="openPopup('model')">
				<view class="content">
					<view class="title">模式</view>
					<view class="sub-title">制热</view>
				</view>
				<uni-icons type="icon-zhongtumoshi" custom-prefix="iconfont" color="#bcbcbc" size="26">
				</uni-icons>
			</view>
			<view class="bg"></view>
			<view class="box" @click="openPopup('windSpeed')">
				<view class="content">
					<view class="title">风速</view>
					<view class="sub-title">自动</view>
				</view>
				<uni-icons type="icon-fengsu" custom-prefix="iconfont" color="#bcbcbc" size="26">
				</uni-icons>
			</view>
		</view>
		<uni-popup ref="popup">
			<view class="popup-content">
				<view class="popup-operation">
					<view class="model-popup" v-if="type == 'model'">
						<view class="model-popup-item active">
							<uni-icons type="icon-zidong" custom-prefix="iconfont" color="#08979c" size="26">
							</uni-icons>
							<view class="model-popup-label">自动</view>
						</view>
						<view class="model-popup-item">
							<uni-icons type="icon-zhileng" custom-prefix="iconfont" color="#8c8c8c" size="26">
							</uni-icons>
							<view class="model-popup-label">制冷</view>
						</view>
						<view class="model-popup-item">
							<uni-icons type="icon-zhire" custom-prefix="iconfont" color="#8c8c8c" size="26">
							</uni-icons>
							<view class="model-popup-label">制热</view>
						</view>
						<view class="model-popup-item">
							<uni-icons type="icon-chushi" custom-prefix="iconfont" color="#8c8c8c" size="26">
							</uni-icons>
							<view class="model-popup-label">抽湿</view>
						</view>
						<view class="model-popup-item">
							<uni-icons type="icon-songfeng" custom-prefix="iconfont" color="#8c8c8c" size="26">
							</uni-icons>
							<view class="model-popup-label">送风</view>
						</view>
					</view>
					<view class="wind-popup" v-if="type == 'windSpeed'">
						<view class="wind-title">
							<view class="big-title">风速</view>
							<view class="line"></view>
							<view class="label">
								<text v-if="autoWind">自动风</text>
								<text v-else>{{windSpeed}}%</text>
							</view>
						</view>
						<view class="wind-auto">
							<uni-icons type="icon-zidong" custom-prefix="iconfont" color="#1f1f1f" size="26">
							</uni-icons>
							<view class="big-title">自动风</view>
							<uv-switch v-model="autoWind" size="40rpx"></uv-switch>
						</view>
						<view class="wind-hand">
							<l-slider v-model="windSpeed" :min="1" :max="100" :step="1"></l-slider>
						</view>
						<view class="hand-text">
							<text class="number1">1%</text>
							<text class="number20">20%</text>
							<text class="number40">40%</text>
							<text class="number60">60%</text>
							<text class="number80">80%</text>
							<text class="number100">100%</text>
						</view>
					</view>
				</view>
				<view class="popup-close" @click="closePopup">关闭</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		props: ['title'],
		data() {
			return {
				isOpen: true,
				temp: 26,
				type: '',
				autoWind: true,
				windSpeed: 20
			}
		},
		mounted() {},
		methods: {
			openPopup(type) {
				this.type = type;
				this.$refs.popup.open('bottom');
			},
			closePopup() {
				this.$refs.popup.close();
			}
		}
	}
</script>

<style lang="scss">
	.aircondition-box {
		padding: 30rpx;

		.popup-content {
			border-radius: 16rpx 16rpx 0 0;
			background: #fff;

			.popup-operation {
				padding: 30rpx 0;
			}

			.model-popup {
				display: flex;

				.model-popup-item {
					flex: 1;
					text-align: center;

					&.active {
						color: $uni-primary;
					}
				}

				.model-popup-label {
					font-size: 24rpx;
					margin-top: 10rpx;
					font-weight: 300;
				}
			}

			.wind-popup {
				padding: 0 30rpx;
				box-sizing: border-box;

				.wind-title {
					display: flex;
					align-items: center;
				}

				.big-title {
					font-size: 32rpx
				}

				.line {
					width: 2rpx;
					height: 26rpx;
					background: $uni-background-color;
					margin: 0 16rpx;
				}

				.wind-auto {
					padding: 20rpx 30rpx;
					border-radius: 26rpx;
					box-shadow: 0px 1px 12px rgba(3, 3, 3, 0.08);
					display: flex;
					align-items: center;
					margin: 30rpx 0;

					.big-title {
						flex: 1;
						margin-left: 20rpx;
					}
				}

				.wind-hand {
					padding-top: 20rpx;
				}

				.hand-text {
					position: relative;
					color: $uni-secondary-color;
					font-size: 24rpx;
					height: 34rpx;
					margin-top: 20rpx;

					.number20 {
						position: absolute;
						left: 20%;
						margin-left: -26rpx;
					}

					.number40 {
						position: absolute;
						left: 40%;
						margin-left: -26rpx;
					}

					.number60 {
						position: absolute;
						left: 60%;
						margin-left: -26rpx;
					}

					.number80 {
						position: absolute;
						left: 80%;
						margin-left: -26rpx;
					}

					.number100 {
						position: absolute;
						left: 100%;
						margin-left: -52rpx;
					}
				}
			}

			.popup-close {
				border-top: 20rpx solid $uni-background-color;
				padding: 24rpx 0;
				text-align: center;
				color: $uni-secondary-color;
			}
		}

		.aircondition-control {
			padding: 30rpx;
			background: #fff;
			border-radius: 16rpx;
			box-shadow: 0px 1px 12px rgba(3, 3, 3, 0.08);
		}

		.aircondition-toogle {
			display: flex;
			justify-content: space-between;
			margin-bottom: 40rpx;
		}

		.toogle-icon-text {
			display: flex;
			align-items: center;

			.text {
				font-size: 36rpx;
				margin-left: 20rpx;
			}
		}

		.toogle-icon {
			width: 80rpx;
			height: 80rpx;
			background: $uni-primary;
			text-align: center;
			line-height: 80rpx;
			border-radius: 8px;
		}

		.aircondition-show {
			display: flex;
			align-items: center;
			justify-content: center;
			padding: 0 40rpx 30rpx 40rpx;
		}

		.aircondition-icon {
			width: 60rpx;
			height: 60rpx;
			background-color: $uni-background-color;
			text-align: center;
			line-height: 60rpx;
			border-radius: 50%;
		}

		.aircondition-label {
			flex: 1;
			width: 0;
			display: flex;
			align-items: flex-end;
			justify-content: center;
			color: $uni-base-color;

			.value {
				font-size: 80rpx;
				height: 100rpx;
			}

			.unit {
				font-size: 40rpx;
			}
		}

		.aircondition-model {
			display: flex;
			margin-top: 30rpx;

			.box {
				flex: 1;
				background: #fff;
				border-radius: 16rpx;
				box-shadow: 0px 1px 12px rgba(3, 3, 3, 0.08);
				height: 160rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 0 60rpx 0 30rpx;
				box-sizing: border-box;

				.content {
					.title {
						font-size: 32rpx;
						font-weight: 300;
					}

					.sub-title {
						font-size: 24rpx;
						color: $uni-secondary-color;
						font-weight: 200;
						margin-top: 10rpx;
					}
				}
			}

			.bg {
				width: 30rpx;
			}
		}

	}
</style>