<template>
	<view class="device-detail">
		<view class="bj">

		</view>
		<!-- 自定义导航栏 -->
		<view class="tabback" style="background-color: #fff;">
			<view class="rtjt" @click="btnback">←</view>
			<view class="name">{{ $i18n.t('manualAddTitle') }}</view>
			<view style="width: 36rpx;"></view>
		</view>

		<view class="content-container" style="background-color: #F3F5F6;">
			<!-- 顶部说明区域 -->
			<view class="instruction-section">
				<text class="instruction-text">{{ $i18n.t('manualAddInstruction') }}</text>
			</view>

			<!-- 中间输入区域 -->
			<view class="input-section">
				<view class="input-group">
					<text class="input-label">{{ $i18n.t('deviceIdLabel') }}</text>
					<input class="device-input" type="text" :placeholder="$i18n.t('deviceIdPlaceholder')"
						v-model="deviceId" maxlength="20" />
				</view>
			</view>

			<!-- 底部继续按钮 -->
			<view class="button-section">
				<button class="continue-btn" :class="{ 'active': deviceId.length >= 1 }"
					@click="handleContinue">{{ $i18n.t('continueText') }}</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				deviceId: '' // 设备ID输入值
			}
		},
		methods: {
			// 返回上一页
			btnback() {
				uni.navigateBack({
					delta: 1
				});
			},

			// 处理继续按钮点击
			handleContinue() {
				if (!this.deviceId.trim()) {
					uni.showToast({
						title: this.$i18n.t('pleaseEnterDeviceId'),
						icon: 'none',
						duration:3000
					})
					return
				}
				if (this.deviceId.length < 1) {
					uni.showToast({
						title: this.$i18n.t('deviceIdMinLength'),
						icon: 'none',
						duration:3000
					})
					return
				}
				// 验证通过，可以继续下一步
				
				uni.navigateTo({
					url: '/subpackage/device/deviceaddroom?deviceId=' + this.deviceId
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.bj {
		width: 100%;
		height: 50vh;
		position: fixed;
		top: 0;
		z-index: -1;
		background-color: #0F0F0F;
	}

	.tabback {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;
		height: 126rpx;
		padding: 0 20rpx;
		box-sizing: border-box;
		background-color: #fff;
		border: 1rpx solid #D8D8D8;
		margin-top: 102rpx;
		border-radius: 30rpx 30rpx 0 0;

		.rtjt {
			font-size: 36rpx;
			color: #333;
		}

		.name {
			font-size: 36rpx;
			font-weight: bold;
			color: #333;
		}
	}

	.device-detail {
		min-height: 100vh;
	}

	// 内容容器
	.content-container {
		min-height: calc(100vh - 228rpx); // 减去导航栏高度
		padding: 0;
		display: flex;
		flex-direction: column;
	}

	// 顶部说明区域
	.instruction-section {
		background-color: #F3F5F6;
		padding: 80rpx 40rpx;
		text-align: center;

		.instruction-text {
			font-size: 32rpx;
			color: #666;
			line-height: 1.5;
			display: block;
		}
	}

	// 中间输入区域
	.input-section {
		background-color: #fff;
		padding: 60rpx 40rpx;

		.input-group {
			.input-label {
				display: block;
				font-size: 30rpx;
				color: #333;
				margin-bottom: 30rpx;
				font-weight: 500;
			}

			.device-input {
				width: 100%;
				height: 80rpx;
				border: none;
				border-bottom: 2rpx solid #E5E5E5;
				font-size: 32rpx;
				color: #333;
				background: transparent;
				padding: 0;
				box-sizing: border-box;

				&::placeholder {
					color: #999;
					font-size: 28rpx;
				}

				&:focus {
					border-bottom-color: #007AFF;
					outline: none;
				}
			}
		}
	}

	// 底部按钮区域
	.button-section {
		flex: 1;
		display: flex;
		align-items: flex-end;
		padding: 0 40rpx 80rpx;
		background-color: #F3F5F6;

		.continue-btn {
			width: 100%;
			height: 100rpx;
			background-color: #999;
			color: #fff;
			border: none;
			border-radius: 50rpx;
			font-size: 36rpx;
			font-weight: 500;
			display: flex;
			align-items: center;
			justify-content: center;
			transition: all 0.3s ease;

			&:active {
				transform: scale(0.98);
				background-color: #888;
			}

			&.active {
				background-color: #000;
				color: #fff;
			}
		}
	}

	.scan-tip {
		text-align: center;
		padding: 40rpx 20rpx;
		color: #666;
		font-size: 28rpx;
	}

	.scan-container {
		display: flex;
		justify-content: center;
		padding: 40rpx 20rpx;
	}

	@keyframes scan {
		0% {
			top: 20rpx;
		}

		100% {
			top: 580rpx;
		}
	}

	.flashlight-btn {
		display: flex;
		justify-content: center;
		margin: 40rpx 0;

		.flashlight-icon {
			width: 120rpx;
			height: 60rpx;
			background-color: #333;
			border-radius: 30rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			color: #fff;
			font-size: 32rpx;
			transition: all 0.3s ease;

			&.active {
				background-color: #007aff;
				transform: scale(1.1);
			}

			.icon {
				font-size: 28rpx;
			}
		}
	}
</style>