<template>
	<view class="device-detail">
		<view class="bj"></view>
		<!-- 顶部导航 -->
            <view class="tabback">
            <view class="rtjt" @click="btnback" style="font-size: 50rpx;">×</view>
            <view class="name">{{$i18n.t('fsyq')}}</view>
			<view style="width: 36rpx;"></view>
		</view>
		<view class="content-container">
			<!-- 设备ID 灰条 -->
            <view class="id-strip">
				<view class="id-text" style="margin-top: 20rpx;">{{$i18n.t('fsyq')}}</view>
			</view>
			<view class="card">
                <view class="field">
                    <text class="field-label">{{$i18n.t('yhyq')}}</text>
                    <input class="field-input" type="text" v-model="deviceName" :placeholder="$i18n.t('emwz')"
						placeholder-style="color:#BFBFBF" maxlength="100" />
				</view>
			</view>
			<!-- 提示说明 -->
            <view class="tip-box">
                <text class="tip-text">{{$i18n.t('yqts')}}</text>
			</view>
		</view>
		<!-- 底部添加设备按钮 -->
        <view class="button-section">
            <button class="continue-btn" @click="handleContinue">{{$i18n.t('confirm')}}</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				deviceName: '',
				kjid:'',
				fangdouflag:true
			}
		},
		onLoad(option) {
			this.kjid = uni.getStorageSync('kjid');
		},
		methods: {
			// 点击添加成功
			handleContinue(){
				let data = {
					spaceId:this.kjid,
					email:this.deviceName
				}
				if(this.fangdouflag == true){
					this.fangdouflag = false
					this.$http.post(`/bst/spaceUser/invite`,data).then(res =>{
						if(res.code == 200){
							uni.showToast({
								title: res.msg,
								icon: 'success',
								duration:3000
							})
							setTimeout(()=>{
								this.fangdouflag = true
								uni.navigateBack()
							},1500)
						}else{
							uni.showToast({
								title: res.msg,
								icon: 'none',
								duration:3000
							})
							this.fangdouflag = true
						}
					})
				}
			},
			// 返回上一页
			btnback() {
				uni.navigateBack({
					delta: 1
				})
			},
		}
	}
</script>

<style scoped lang="less">
	.active{
		background-color: #d8d9da;
		color: #000 !important;
		.cell-title{
			font-weight: 600 !important;
		}
	}
	// 底部按钮区域
	.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: #000;
			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;
		}
	}
	.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 {
		height: 93vh;
	}

	// 顶部导航样式（贴近系统样式）
	.tabback {
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 98rpx;
		padding: 0 24rpx;
		background: #fff;
		border-bottom: 2rpx solid #ECECEC;

		.name {
			font-size: 32rpx;
			color: #333;
		}

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

	// 页面容器
	.content-container {
		height: 74vh;
		background: #F3F5F6;
		padding-bottom: 40rpx;
	}

	// 顶部设备ID灰条
	.id-strip {
		height: 110rpx;
		background: #F3F5F6;
		text-align: left;
		padding: 0 24rpx;
		padding-top: 30rpx;
		box-sizing: border-box;
		border-bottom: 2rpx solid #ECECEC;
	}

	// 卡片
	.card {
		background: #fff;
		margin-top: 0;
		padding: 0 24rpx;
	}

	.id-text {
		color: #9EA3A8;
		font-size: 26rpx;
	}

	.field {
		padding: 24rpx 0 32rpx;
	}

	.field-label {
		color: #9EA3A8;
		font-size: 26rpx;
	}

	.field-input {
		margin-top: 16rpx;
		height: 72rpx;
		border: 0;
		border-bottom: 2rpx solid #E6E6E6;
		font-size: 28rpx;
	}

	// 提示
	.tip-box {
		padding: 20rpx 24rpx;
		background: #F3F5F6;
		border-top: 2rpx solid #ECECEC;
	}

	.tip-text {
		color: #9EA3A8;
		font-size: 24rpx;
		line-height: 40rpx;
	}

	// 列表
	.list {
		background: #fff;
		margin-top: 12rpx;
		max-height: 44vh;
		overflow: scroll;
		view {
			height: 96rpx;
			padding: 0 24rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-top: 2rpx solid #ECECEC;
		}
	}

	

	.cell-title {
		color: #333;
		font-size: 30rpx;
		font-weight: 500;
	}

	.arrow {
		color: #C0C0C0;
		font-size: 44rpx;
		line-height: 1;
	}

	.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>