<template>
	<u-popup :show="show" :round="36" mode="bottom" @close="close">
		<view class="bind_device">
			<div class="top adfacjb">
				<div class="pre adffcacjc" @tap="scanBind">
					<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/06/03/7d603c9a-6b47-40b3-9a49-46638ed677ee.png"></image>
					<text>扫码绑定设备</text>
				</div>
				<div class="pre adffcacjc" @tap="wifiBind">
					<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/06/03/58afeb20-9bea-46e3-b31c-7be2b9b7014d.png"></image>
					<text>配网并绑定设备</text>
				</div>
			</div>
			<div class="close">
				<u-icon name="close" color="#5C5C5C" size="50" @tap="close"></u-icon>
			</div>
		</view>
	</u-popup>
</template>

<script>
	export default {
		data(){
			return {
				show:false
			}
		},
		methods:{
			close(){
				this.show = false;
			},
			scanBind(){
				this.show = false;
				let that = this;
				uni.scanCode({
					success: (res) => {
						let result = JSON.parse(res.result);
						if(res.errMsg==='scanCode:ok'){
							uni.navigateTo({
								url:'/pagesMy/scanResult?scanParams='+JSON.stringify(result)
							})
							
							// 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
							// 	})
							// })
						}
					}
				})
			},
			wifiBind(){
				this.show = false;
				uni.navigateTo({
					url:'/pagesMy/deviceAdd'
				})
			},
		}
	}
</script>

<style scoped lang="less">
	.bind_device{
		width: 100%;
		padding: 74rpx 74rpx 20rpx;
		box-sizing: border-box;
		.top{
			.pre{
				width: calc(50% - 51rpx);
				image{
					width: 110rpx;
					height: 110rpx;
				}
				text{
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #111111;
					line-height: 32rpx;
					text-align: center;
					margin-top: 24rpx;
				}
			}
		}
		.close{
			width: 100%;
			margin-top: 113rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
</style>