<template>
	<view class="content p-rel">
		<view :style="{ paddingTop: statusBarHeight + 'px' }"></view>
		<view class="box">
			<view class="mgb-10">当前连接：YThuwai</view>
			<view class="listbox">
				<view class="flex jc_between pdy-30 border-bottom" v-for="wifi in list">
					<view class="flex">
						<i class="fas fa-wifi"></i> &nbsp;
						{{ wifi.SSID }}
					</view>
					<view @click="connectedWifi(wifi)" :class="wifi.status ?'c_btn':'btn'">
						{{ wifi.status? '已连接': '连接' }}
					</view>
				</view>
			</view>
		</view>
	</view>
	<view class="ADBox">
		横幅广告
	</view>
</template>

<script setup>
import { ref, onMounted } from "vue";
import { onShow } from "@dcloudio/uni-app";
var statusBarHeight = uni.getStorageSync('statusBarHeight')
const list = ref([
	{
	  "SSID": "YThuwai",
	  "BSSID": "XX:XX:XX:XX:XX:XX",
	  status:true,
	},
	{
	  "SSID": "YtZhe",
	  "BSSID": "XX:XX:XX:XX:XX:XX",
	  status:false,
	},
	{
	  "SSID": "DIRECT-GQDESKTOP2E4TVT1-msPR",
	  "BSSID": "YY:YY:YY:YY:YY:YY",
	  status:false,
	},
	{
	  "SSID": "4-426",
	  "BSSID": "XX:XX:XX:XX:XX:XX",
	  status:false,
	},
	{
	  "SSID": "Tech_xxx",
	  "BSSID": "YY:YY:YY:YY:YY:YY",
	  status:false,
	},
	{
	  "SSID": "88888888-pZ",
	  "BSSID": "XX:XX:XX:XX:XX:XX",
	  status:false,
	},
	{
	  "SSID": "ChinaNet-bG62",
	  "BSSID": "YY:YY:YY:YY:YY:YY",
	  status:false,
	},
	{
	  "SSID": "GF-1",
	  "BSSID": "XX:XX:XX:XX:XX:XX",
	  status:false,
	},
	{
	  "SSID": "GAIF",
	  "BSSID": "YY:YY:YY:YY:YY:YY",
	  status:false,
	},
	{
	  "SSID": "boss",
	  "BSSID": "XX:XX:XX:XX:XX:XX",
	  status:false,
	},
	{
	  "SSID": "ChinaNet-LJmh",
	  "BSSID": "YY:YY:YY:YY:YY:YY",
	  status:false,
	},
	{
	  "SSID": "Home_WiFi",
	  "BSSID": "XX:XX:XX:XX:XX:XX",
	  status:false,
	},
	{
	  "SSID": "Office_WiFi",
	  "BSSID": "YY:YY:YY:YY:YY:YY",
	  status:false,
	}
])
onMounted(()=>{
	// uni.getConnectedWifi({
	// 	success:(res)=>{
	// 		console.log('res',res)
	// 	}
	// })
	// uni.getWifiList({
	// 	success:(res)=>{
	// 		console.log('res',res.wifiList)
	// 	},
	// 	fail: (err) => {
	// 		console.log('err',err)
	// 	}
	// })
})
const connectedWifi = (wifi)=>{
	uni.showToast({
		title:`已连接`
	})
	list.value.map(item=>{ return item.status = false })
	wifi.status = true
}
</script>

<style lang="scss" scoped>
	.content{
		height: 100vh;
		padding: 28rpx;
		background: linear-gradient(to bottom, #a9d4ff, #cce6ff);
	}
	.box{
		background-color: #fff;
		border-radius: 30rpx;
		height: 95vh;
		padding: 30rpx 28rpx;
		.listbox{
			max-height: 85vh;
			overflow-y: scroll;
			.c_btn{
				background-color: #399bfc;
				color: #fff;
				font-size: 22rpx;
				line-height: 48rpx;
				border-radius: 30rpx;
				cursor: pointer;
				width: 120rpx;
				height: 48rpx;
				text-align: center;
			}
			.btn{
				width: 120rpx;
				height: 48rpx;
				line-height: 48rpx;
				text-align: center;
				background-color: #fff;
				color: #399bfc;
				border: 1rpx solid #399bfc;
				font-size: 22rpx;
				border-radius: 30rpx;
				cursor: pointer;
			}
		}
	}
	.ADBox{
		position: fixed;
		bottom: 0;
		height: 120rpx;
		width: 100%;
		background-color: #fff;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>