<template>
	<view class="content">
		<view class="content_top">
			<view class="icon_box" style="" v-for="(item,index) in images" :key="index">
				<view class="icon" style="" @click='urinometer_click(index)'>
					<img class="image" style="" :src="item.url" alt="" />
					<view class="">领透智能尿检仪</view>
				</view>
			</view>
		</view>
		<view class="content_bottom" style="">
			<view class="button_box" style="">
				<view class="button border" style="" @click='scanCode_click'>扫码添加</view>
				<view class="button" style="flex: 1;">手动添加</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				images:[{id:1,url:'../../static/urine/4.png'},{id:2,url:'../../static/urine/4.png'},
						{id:3,url:'../../static/urine/4.png'},{id:4,url:'../../static/urine/4.png'}],
			}
		},
		onLoad(){
			const _that = this
			// wx.startWifi({
			//   success(res) {
			// 	  console.log('success',res);
			//     // _this.getWifiInfo();
			// 	// _that.getWifilist()
			// 	_that.authorize()
			//   },
			//   fail: function (res) {
			// 	  // _that.authorize() 
			// 	  console.log('请连接路由器',res);
			//     // _this.showPopIs5G();
			//     // uni.showToast({
			//     //   title: "请连接路由器",
			//     //   duration: 2000,
			//     // });
			//   },
			// });
		},
		methods:{
			urinometer_click(index){
				console.log('index',index);
				// uni.openBluetoothAdapter({
				//   success(res) {
				//     console.log('success',res)
				// 	uni.startBluetoothDevicesDiscovery({
				// 		success: function(res) {
				// 			console.log('搜索蓝牙设备success',res)
				// 			uni.getBluetoothDevices({
				// 				success: function(res) {
				// 					// if()
				// 					console.log('获取蓝牙列表success',res)
				// 					uni.createBLEConnection({
				// 						// deviceId: this.deviceId,  // 在第 3 步可以拿到蓝牙的 deviceId 的值
				// 						success: (res) => {
				// 							console.log("连接成功", res)
				// 							uni.stopBluetoothDevicesDiscovery({
				// 								success(res) {
				// 								    console.log('停止搜索蓝牙',res)
				// 								}
				// 							})
				// 						},
				// 						fail: (error) => {
				// 							console.log("连接失败", error)
				// 						}
				// 					})
				// 				},
				// 				fail: function() {
				// 					console.log("获取蓝牙设备列表失败")
				// 				}
				// 			})
				// 		},
						
				// 		fail: function() {
				// 			console.log("获取蓝牙设备列表失败")
				// 		}
				// 	})
					
				//   },
				
				// })
				wx.navigateTo({
					url:'/pages/Health_monitor/urinometer'
				})
				
			},
			getWifilist(){
				wx.getWifiList({
					 success(res) {
						 console.log('获取wifi列表',res);
						 wx.onGetWifiList({
							 success(res){
								console.log('监听wifi列表',res); 
							 }
						 })
					 },
					 fail(res){
						 console.log('获取wifi列表失败',res);
					 }
				})
			},
			// 获取用户授权设置
			authorize() {
			    let that = this
			    wx.getSetting({
			      success(res) {
			        console.log('setting', res)
					console.log('dingwei',res.authSetting['scope.userLocation'] === undefined);
			        if (res.authSetting['scope.userLocation'] === undefined) {
						uni.showModal({
							title: '是否授权当前位置',
							content: '需要获取您的地理位置，请确认授权，否则无法相关功能！',
							success(res){
								if(res.confirm){
									wx.openSetting({
									  success: (add => {
										if (dataAu.authSetting['scope.userLocation'] === true){
											wx.getLocation({
												success(res){
													console.log('获取位置',res);
													that.getWifilist()
												}
											})
										}
									   
									  })
									})
								}
							}
						})
						
					  // 申请获取地理位置权限
			          // wx.authorize({
			          //   scope: 'scope.userLocation',
			          //   success: (res) => {
			          //     console.log('authorize succ', res)
			              
			          //   },
			          //   fail: (e) => {
			          //     console.log('authorize fail', e)
			          //   }
			          // })
			        }else{
			          // 开始wifi模块使用
					  that.getWifilist()
			        }
			      }
			    })
			},
			  // 提示用户打开设置页，打开
			openSetting() {
			    wx.openSetting({
			      success: (res => {
			      	// res也会返回用户设置的权限，可以把权限判断部分的代码单独抽出来
			        this.authorize() // 获取用户授权设置
			      })
			    })
			},
			scanCode_click(){
				uni.scanCode({
					success: function (res) {
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
					}
				})
			}

		}
	}
</script>

<style lang="scss" scoped>
	.content{
		.content_top{
			height: 80%;
			.icon_box{
				width: 49%;
				display: inline-block;
				flex-wrap: wrap;
				background: white;
				box-sizing: border-box;
				border: 1px solid #dcdcdc4d;
				.icon{
					width: 100%;
					text-align: center;
					padding: 10px;
					display: inline-block;
					// box-sizing: border-box;
					.image{
						height: 100rpx;
						width: 100rpx;
					}
				}
				
			}
		}
		.content_bottom{
			width: 100%;
			position: fixed;
			bottom: 30rpx;
			.button_box{
				margin: 0 auto;
				width: 80%;
				background:linear-gradient(#4dc691,#66cfa1,#7ad7ae);
				border-radius: 100rpx;
				display: flex;
				.button{
					flex: 1;
					line-height:90rpx;
					color: white;
					text-align: center;
				}
				.border{
					border-right:1px solid white;
				}
			}
		}
	}
</style>