<template>
	<view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
		<cus-header title='配置网络'></cus-header>
		<image src="http://106.54.209.120:8188/static/wifi_success.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(){
				uni.scanCode({
					success: (res) => {
						let result = JSON.parse(res.result);
						if(res.errMsg==='scanCode:ok'){
							this.$api.post('/device/bindAdd',{
								...result,
								"type": "",
								"userId": 0,
								"agentId": ""
							}).then(res=>{
								if(res.data.code!==0) return this.$showToast(res.data.msg)
								uni.navigateTo({
									url:'/pagesMy/scanResult'
								})
							})
						}
					}
				})
			},
			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>