<template>
	<view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
		<cus-header title='配置网络'></cus-header>
		<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/06/03/e6540154-b4da-4ddd-ab9b-8f219d5c18a6.png"></image>
		<p>网络配置成功</p>
		<p class="tip">请扫描设备或说明书上的二维码<br>点击下方扫码绑定设备，<br>如您已添加过设备，可返回首页开始使用</p>
		<div class="zt_btn" @tap="scanDevice">扫码绑定设备</div>
		<div class="qx_btn" @tap="goBack">返回首页</div>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				
			}
		},
		methods:{
			scanDevice(){
				let that = this;
				uni.scanCode({
					success: (res) => {
						let result = JSON.parse(res.result);
						if(res.errMsg==='scanCode:ok'){
							that.$api.post('/device/bind',{
								...result,
								"type": "",
								"userId": 0,
								"agentId": ""
							}).then(res=>{
								if(res.data.code!==0) return that.$showToast(res.data.msg)
								uni.navigateTo({
									url:'/pagesMy/scanResult?deviceId='+res.data.data
								})
							})
						}
					}
				})
			},
			goBack(){
				uni.reLaunch({
					url:'/pages/home'
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.page{
		background: #FFFFFF;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding: 0 70rpx;
		
		image{
			width: 213rpx;
			height: 163rpx;
			margin-top: 198rpx;
		}
		p{
			font-family: PingFang-SC, PingFang-SC;
			font-weight: bold;
			font-size: 40rpx;
			color: #111111;
			line-height: 40rpx;
			text-align: center;
			margin-top: 54rpx;
			&.tip{
				font-weight: 400;
				font-size: 28rpx;
				color: #7C8592;
				line-height: 42rpx;
				text-align: center;
				margin-top: 40rpx;
			}
		}
		.zt_btn{
			margin-top: 193rpx;
		}
		.qx_btn{
			margin-top: 60rpx;
		}
	}
</style>