<template>
	<view class="page">
		<u-navbar title="房间详情" :border-bottom="false" :background="bgc" back-icon-color="#262B37" title-color='#262B37'
			title-size='36' height='50' id="navbar">
		</u-navbar>
        <view class="boxtop">
        	<view class="top">
        		<view class="name">
        			房间1
        		</view>
				<view class="yuny">
					<text></text> 运营中
				</view>
        	</view>
			<view class="bot">
				<view class="" @click="btnjfgz">
					<image src="https://api.ccttiot.com/smartmeter/img/static/udeYbjiOdwddMbUM90QB" mode=""></image> 计费规则
				</view>
				<view class="" @click="btnewm">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uT7NCRBVoRy8KFIF9Gtq" mode=""></image> 下载二维码
				</view>
				<view class="" @click="btnroomsz">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uTBNF3xzr0EAJjzJ3Ggc"mode=""></image> 房间设置
				</view>
			</view>
        </view>
		<view class="tops">
			<view class="lt">
				设施列表
			</view>
			<view class="rt" @click="flag = !flag">
				添加
			</view>
			<view class="tianjia" v-if="flag">
				<view class="" @click="btnaddfm(1)">
					添加房门
				</view>
				<view class="" @click="btnaddfm(2)">
					添加电源
				</view>
				<view class="" @click="btnaddfm(3)" style="border: none;">
					添加设施
				</view>
			</view>
		</view>
		<view class="list">
			<view class="item_list">
				<view class="lt">
					<view class="name">
						房间门   <text>设备离线</text>
					</view>
					<view class="sn">
						SN：2234681537
					</view>
				</view>
				<view class="rt">
					<view class="name">
						<text></text> 已关闭
					</view>
					<view class="img">
						<image src="https://api.ccttiot.com/smartmeter/img/static/uvqVahRyvBHooSDLQfED" mode=""></image>
					</view>
				</view>
			</view>
			<view class="item_list" @click="btnwbd">
				<view class="lt">
					<view class="name">
						房间灯  <text>设备离线</text>
					</view>
			
				</view>
				<view class="rt">
					<view class="name">
						<text></text> 未绑定
					</view>
					
				</view>
			</view>
		</view>
		<!-- 添加房门 -->
		<view class="mask" v-if="fmflag"></view>
		<view class="addmen" v-if="fmflag">
			<view class="top">
				<view class="cha" @click="fmflag = false">
					×
				</view>
				<view class="name">
					请选择添加{{roomtxt}}方式
				</view>
			</view>
			<view class="one" @click="btntoufcesuo">
				<view class="lt">
					<view class="saoma">
						扫码添加
					</view>
					<view class="saomas">
						扫描设备上的二维码
					</view>
					<view class="saomas">
						设置{{roomtxt}}
					</view>
				</view>
				<view class="rt">
					<image src="https://api.ccttiot.com/smartmeter/img/static/ukzEfdUUjPKUUOxonIgm" mode=""></image>
				</view>
			</view>
			<view class="one" @click="btntouffm">
				<view class="lt">
					<view class="saoma">
						未投放设备列表添加
					</view>
					<view class="saomas">
						选择列表中的设备
					</view>
					<view class="saomas">
						设置{{roomtxt}}
					</view>
				</view>
				<view class="rt">
					<image src="https://api.ccttiot.com/smartmeter/img/static/ukzEfdUUjPKUUOxonIgm" mode=""></image>
				</view>
			</view>
		</view>
        <view class="mask" v-if="pricegzflag"></view>
		<view class="pricegz" v-if="pricegzflag">
			<view class="top">
				下单须知：
			</view>
			<view class="shuom">
				基础单价每1小时10元，最低消费时长2小 时，押金金额100元（订单结束30分钟内退 还）注：订单提前结束剩余消费时长、金额 不返还
			</view>
			<view class="annius" @click="pricegzflag = false">
				确认
			</view>
		</view>
		
		<view class="anniu">
			<view class="xinjian" @click="btndt">
				下线维护
			</view>
			<view class="xinjian" @click="btndt">
				全开
			</view>
			<view class="xinjian" @click="btndt">
				全关
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
                bgc: {
                	backgroundColor: "#fff",
                },
				roomId:'',
				flag:false,
				fmflag:false,
				roomtxt:'',
				pricegzflag:false
			}
		},
		onLoad(option) {
            this.roomId = option.roomId
			this.getxq()
		},
		methods: {
			// 点击弹出计费规则
			btnjfgz(){
				this.pricegzflag = true
			},
			// 跳转到编辑房间页
			btnroomsz(){
				uni.navigateTo({
					url:'/page_shanghu/roomedit'
				})
			},
			// 跳转到保存二维码
			btnewm(){
				uni.navigateTo({
					url:'/page_shanghu/erwm'
				})
			},
			// 点击进行扫码
			btntoufcesuo(){
				this.fmflag = false
				uni.scanCode({
					onlyFromCamera: true,
					scanType: ['qrCode'],
					success: res => {
						function getQueryParam(url, paramName) {
							let regex = new RegExp(`[?&]${paramName}=([^&]*)`)
							let results = regex.exec(url);
							return results ? decodeURIComponent(results[1].replace(/\+/g, ' ')) : null
						}
						console.log(res);
						let sceneValue = res.result
						let decodedValue = decodeURIComponent(sceneValue)
						let id = getQueryParam(decodedValue, 'sn')
						let that = this
						let data = {
							sn: id,
							storeId:this.storeId
						}
                        uni.navigateTo({
                        	url:'/page_shanghu/weishebei'
                        })
					}
				})
			},
			// 点击未投放列表选择设备
			btntouffm(){
				this.fmflag = false
				uni.navigateTo({
					url:'/page_shanghu/weishebei'
				})
			},
			// 点击添加房门
			btnaddfm(num){
				if(num == 1){
					this.roomtxt = '房门'
					this.fmflag = true
					this.flag = false
				}else if(num == 2){
					this.roomtxt = '电源'
					this.fmflag = true
					this.flag = false
				}else if(num == 3){
					this.roomtxt = '设施'
					this.fmflag = true
					this.flag = false
				}
			},
			// 请求房间详情
			getxq(){
				this.$u.get(`/app/room/${this.roomId}`).then(res =>{
					if(res.code == 200){
						
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	/deep/ .u-iconfont,
	/deep/ .u-title{
		padding-bottom: 20rpx;
	}
	.pricegz{
		width: 636rpx;
		max-height: 438rpx;
		background: #FFFFFF;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		padding: 52rpx 46rpx;
		box-sizing: border-box;
		margin: auto;
		position: fixed;
		top: 490rpx;
		left: 50%;
		transform: translateX(-50%);
		z-index: 3;
		.top{
			font-weight: 600;
			font-size: 32rpx;
			color: #3D3D3D;
		}
		.shuom{
			font-size: 28rpx;
			color: #3D3D3D;
			margin-top: 24rpx;
		}
		.annius{
			width: 542rpx;
			height: 86rpx;
			background: #48893B;
			border-radius: 14rpx 14rpx 14rpx 14rpx;
			text-align: center;
			line-height: 86rpx;
			font-weight: 600;
			font-size: 36rpx;
			color: #FFFFFF;
			margin-top: 30rpx;
		}
	}
	.mask{
		width: 100%;
		height: 100vh;
		background-color: #000;
		opacity: .3;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 3;
	}
	.addmen{
		width: 694rpx;
		height: 702rpx;
		background: linear-gradient( 180deg, #DEF1DA 0%, #FFFFFF 100%, #FFFFFF 100%);
		border-radius: 36rpx 36rpx 36rpx 36rpx;
		position: fixed;
		top: 464rpx;
		left: 50%;
		transform: translateX(-50%);
		z-index: 3;
		box-shadow: 1px 2px 4px -3px;
		.one{
			display: flex;
			align-items: center;
			justify-content: space-between;
			width: 100%;
			.rt{
				image{
					width: 60rpx;
					height: 60rpx;
				}
			}
			.saoma{
				font-weight: 600;
				font-size: 36rpx;
				color: #48893B;
				margin-top: 10rpx;
			}
			.saomas{
	            font-size: 28rpx;
	            color: #48893B;		
				margin-top: 10rpx;
			}
			width: 584rpx;
			height: 224rpx;
			border: 2rpx solid #48893B;
			border-radius: 20rpx;
			margin: auto;
			margin-top: 48rpx;
			padding: 38rpx 44rpx;
			box-sizing: border-box;
		}
		.top{
			display: flex;
			flex-wrap: wrap;
			padding: 0 26rpx;
			box-sizing: border-box;
			.name{
				font-weight: 600;
				font-size: 44rpx;
				color: #48893B;
				width: 100%;
				text-align: center;
				position: absolute;
				top: 56rpx;
				left: 50%;
				transform: translateX(-50%);
			}
			.cha{
				font-size: 68rpx;
				font-weight: 600;
				width: 100%;
				text-align: right;
			}
		}
	}
	.anniu{
		width: 750rpx;
		height: 152rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 8rpx 20rpx 0rpx rgba(0,0,0,0.3);
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		position: fixed;
		left: 0;
		bottom: 0;
		display: flex;
		justify-content: space-between;
		padding: 0 36rpx;
		box-sizing: border-box;
		padding-top: 24rpx;
		.xinjian{
			width: 214rpx;
			height: 104rpx;
			border: 2rpx solid #48893B;
			border-radius: 20rpx;
			text-align: center;
			line-height: 104rpx;
			font-weight: 600;
			font-size: 36rpx;
			color: #48893B;
		}
	}
	page {
		background: #F6F6F6;
	}
	.list{
		padding: 0 32rpx;
		box-sizing: border-box;
		margin-top: 42rpx;
		.item_list{
			display: flex;
			justify-content: space-between;
			margin-top: 18rpx;
			max-height: 184rpx;
			.rt{
				.name{
					display: flex;
					align-items: center;
					text{
						width: 10rpx;
						height: 10rpx;
						background: #7C7C7C;
						border-radius: 50%;
						margin-right: 10rpx;
						font-size: 28rpx;
						color: #969696;
					}
				}
				.img{
					text-align: right;
					margin-top: 20rpx;
					image{
						width: 50rpx;
						height: 50rpx;
					}
				}
			}
			.lt{
				.name{
					font-weight: 600;
					font-size: 32rpx;
					color: #3D3D3D;
					text{
						font-size: 28rpx;
						color: #969696;
						font-weight: 400;
						margin-left: 30rpx;
					}
				}
				.sn{
					font-size: 26rpx;
					color: #3D3D3D;
					margin-top: 26rpx;
				}
			}
			padding: 32rpx 30rpx;
			box-sizing: border-box;
			width: 680rpx;
			background: #FFFFFF;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
		}
	}
	.boxtop{
		width: 680rpx;
		height: 244rpx;
		background: #FFFFFF;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		margin: auto;
		margin-top: 22rpx;
		padding: 34rpx 30rpx;
		box-sizing: border-box;
		.bot{
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 40rpx;
			view{
				display: flex;
				align-items: center;
				justify-content: center;
				width: 204rpx;
				height: 54rpx;
				border-radius: 27rpx 27rpx 27rpx 27rpx;
				border: 1rpx solid #7C7C7C;
				image{
					width: 32rpx;
					height: 32rpx;
					margin-right: 6rpx;
				}
			}
		}
		.name{
			font-weight: 600;
			font-size: 30rpx;
			color: #3D3D3D;
		}
		.yuny{
			display: flex;
			align-items: center;
			font-weight: 600;
			font-size: 28rpx;
			color: #48893B;
			text{
				width: 10rpx;
				height: 10rpx;
				background: #48893B;
				border-radius: 50%;
				margin-right: 10rpx;
			}
		}
		.top{
			display: flex;
			justify-content: space-between;
			border-bottom: 1px solid #D8D8D8;
			padding-bottom: 22rpx;
			box-sizing: border-box;
		}
	}
	.tops{
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 36rpx;
		box-sizing: border-box;
		margin-top: 70rpx;
		position: relative;
		.tianjia{
			width: 170rpx;
			height: 214rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 6rpx 0rpx rgba(0,0,0,0.3);
			border-radius: 12rpx 12rpx 12rpx 12rpx;
			position: absolute;
			top: 80rpx;
			right: 36rpx;
			view{
				width: 120rpx;
				height: 70rpx;
				line-height: 70rpx;
				text-align: center;
				margin: auto;
				border-bottom: 1px solid #D8D8D8;
				font-size: 28rpx;
				color: #3D3D3D;
			}
		}
		.lt{
			font-weight: 600;
			font-size: 36rpx;
			color: #3D3D3D;
		}
		.rt{
			width: 126rpx;
			height: 58rpx;
			background: #48893B;
			border-radius: 6rpx 6rpx 6rpx 6rpx;
			font-weight: 600;
			text-align: center;
			line-height: 58rpx;
			font-size: 28rpx;
			color: #FFFFFF;
		}
	}

 
</style>