<template>
	<view class="pageContent">
		<view class="pause" @click="scanCode">
			<uni-icons type="scan" size="100" color="rgba(255, 255, 255, 0.5)"></uni-icons>
			<view class="scanT">扫一扫添加设备</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
			}
		},
		methods: {
			// 扫描
			scanCode() {
				uni.scanCode({
					success: (res) => { 
						console.log('条码内容：' + res.result);
						// 跳转并传递扫描结果
						uni.navigateTo({
							url: `/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(res.result)}`
						});
					},
					fail: (err) => {
						console.log('扫码失败', err);
						uni.showToast({
							title: '扫码失败',
							icon: 'none'
						});
					}
				});
			}
		}
	}
</script>

<style scoped>
	.pageContent {
		height: 100vh;
		background-color: rgb(18, 18, 18);
		padding: 30rpx;
	}

	.pause {
		text-align: center;
		transform: translate(-50%, -100%);
		position: absolute;
		left: 50%;
		top: 40%;
	}

	.scanT {
		color: rgba(255, 255, 255, 0.87);
		font-size: 38rpx;
		padding-top: 20rpx;
	}
</style>