<template>
	<view class="share">
		<!-- 内容区域 -->
		<view class="content">
			<!-- 分享设备 -->
			<view class="section" @click="shareDevice">
				<text class="section-title">分享设备</text>
			</view>
			<!-- 分享管理 -->
			<view class="section" @click="shareManagement">
				<text class="section-title">分享管理</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				itemInfo:""
			}
		},
		methods: {
			// 分享设备
			shareDevice(){
				uni.navigateTo({
					url: '/pages/common/shareDevices/index',
					events: {
						ack: function(data) {}
					},
					success: (res) => {
						res.eventChannel.emit('shareDevice', {
							data: this.itemInfo,
						});
					}
				});
			},
			// 分享管理
			shareManagement(){
				uni.navigateTo({
					url: '/pages/common/shareManagement/index',
					events: {
						ack: function(data) {}
					},
					success: (res) => {
						res.eventChannel.emit('shareManagement', {
							data: this.itemInfo,
						});
					}
				});
			}
		},
		onLoad() {
			const eventChannel = this.getOpenerEventChannel();
			// 监听 'shareDevice' 事件，获取传过来的数据
			eventChannel.on('share', (data) => {
				console.log(data,'datat');
				this.itemInfo = data.data;
			})
		}
	}
</script>

<style scoped>
	.share {
		padding: 30rpx;
		background: #121212;
		min-height: 100vh;
	}

	.status-bar {
		/* 根据实际情况设置状态栏高度 */
		width: 100%;
		height: 20px;
		background-color: #f3f3f3;
	}

	.title {
		font-size: 20px;
		margin-top: 10px;
	}

	.content {
		width: 100%;
		margin-top: 20px;
	}

	.section {
		margin-bottom: 20px;
		padding:50rpx;
		border-radius: 16rpx;
		background: rgba(26, 26, 26, 1);
		text-align: center;
		color: rgba(255, 255, 255, 0.87);
		width: 100%;
	}
</style>