<template>
	<view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
		<cus-header :title='htitle'></cus-header>
		<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/06/03/ea285d8f-ad96-447e-8f4a-77d495f2fac6.png"></image>
		<p>{{title}}</p>
		<template v-if="type=='jpw'">
			<p class="tip">设备配网成功<br>快去首页使用吧~</p>
			<div class="zt_btn" @tap="goBack">返回首页</div>
		</template>
		<template v-else>
			<p class="tip">设备已就绪，需添加角色才能使用<br>快去创建角色吧~</p>
			<div class="zt_btn" @tap="addRole">为设备添加角色</div>
		</template>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				scanParams:'',
				htitle:'扫码结果',
				title:'扫码成功',
				type:''
			}
		},
		onLoad(option) {
			this.type = option.pwtype||'';
			if(option.scanParams) this.scanParams = JSON.parse(option.scanParams);
			if(option.type&&option.type=='lanya'){
				this.htitle = '配网结果';
				this.title = '配网成功';
			}
		},
		methods:{
			addRole(){
				uni.navigateTo({
					url:'/pagesRole/addRole?type=1&scanParams='+JSON.stringify(this.scanParams)
				})
			},
			goBack(){
				uni.reLaunch({
					url:'/pages/home'
				})
			},
		}
	}
</script>

<style scoped lang="less">
	.page{
		background: #FFFFFF;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding: 0 60rpx;
		image{
			width: 400rpx;
			height: 430rpx;
			margin-top: 92rpx;
		}
		p{
			font-family: PingFang-SC, PingFang-SC;
			font-weight: bold;
			font-size: 40rpx;
			color: #111111;
			line-height: 40rpx;
			text-align: center;
			margin-top: 35rpx;
			&.tip{
				font-weight: 400;
				font-size: 26rpx;
				color: #7C8592;
				line-height: 41rpx;
				text-align: center;
				margin-top: 29rpx;
			}
		}
		.zt_btn{
			margin-top: 232rpx;
		}
		.qx_btn{
			margin-top: 60rpx;
		}
	}
</style>