<template>
	<view class="page">
		<u-navbar :title="title" :border-bottom="false" :background="bgc" title-color='#000' title-size='36'
			:title-bold='true' height='45' id="navbar">
		</u-navbar>
		<view class="mapbox">
			<map class="map" id="map" ref="map" :scale="zoomSize" :latitude="latitude" :longitude="longitude"
				:show-location='true' :markers="covers"> </map>
			<view class="fxmask" v-if="dtflag">
				未找到位置信息
			</view>
			<!-- <view class="btn" @click="showwl = true">
				<image src="https://api.ccttiot.com/smartmeter/img/static/uAJBChYkLJO66dYUkJ8M" mode=""></image>
				
			</view> -->
		</view>
		<view class="tit">
			{{obj.apiaryName == undefined ? '--' : obj.apiaryName}}-{{obj.name == undefined ? '--' : obj.name}}
			
			<view class="sets">
				<view class="tongbu" v-if="tbszflag" @click="btntbsz">
					同步设置
				</view>
				<!-- <image @click="btnmenu" src="https://api.ccttiot.com/smartmeter/img/static/ulHBKvkXDfe9OIveIJKZ" mode=""></image> -->
				
				<!-- 正在连接 -->
				<image v-if="zcljflag" style="width: 180rpx;height: 40rpx;margin-right:20rpx" src="https://api.ccttiot.com/smartmeter/img/static/uYUoki4Tc56rzINzY2Ba" mode=""></image>
				<!-- 连接成功 -->
				<image v-if="ljcgflag" style="width: 40rpx;height: 40rpx;margin-right:20rpx" src="https://api.ccttiot.com/smartmeter/img/static/uhSqWj4f07z8oDMh0i8f" mode=""></image>
				<!-- 未连接 -->
				<image v-if="wljflag" style="width: 40rpx;height: 40rpx;margin-right:20rpx" src="https://api.ccttiot.com/smartmeter/img/static/uBp1lbXlGEMD4s5P8LGu" mode=""></image>
				
				<image @click="btnedit" src="https://api.ccttiot.com/smartmeter/img/static/ulHBKvkXDfe9OIveIJKZ"
					mode=""></image>
				<view class="menu" v-if="menuflag">
					<view class="menu_li" @click="btnedit">
						<image src="https://api.ccttiot.com/smartmeter/img/static/uE84FLJ6hKTfgt6gxYMw" mode=""></image>
						编辑信息
					</view>
					<!-- 	<view class="menu_li">
						<image src="https://api.ccttiot.com/smartmeter/img/static/uBfAFsDIhqFTFKxL0PVP" mode=""></image>
						投放认养
					</view>
					<view class="menu_li" @click="btnfx">
						<image src="https://api.ccttiot.com/smartmeter/img/static/uwkwkl1CDZfUhQyZdNFY" mode=""></image>
						分享认养
					</view> -->
				</view>
			</view>
		</view>
		<view class="address">
			<image src="https://api.ccttiot.com/smartmeter/img/static/uMOucOG04nN4PrLJfqj6" mode=""></image>
			{{obj.apiaryAddress == undefined ? '--' : obj.apiaryAddress}}
		</view>
		<view class="weather">
			<view class="weather_left">
				<view class="txt">
					多云 {{daily[0].tempMin == undefined ? '--' : daily[0].tempMin}}℃ ~
					{{daily[0].tempMax == undefined ? '--' : daily[0].tempMax}}℃
				</view>
				<view class="txt" style="margin-left: 40rpx;">
					{{daily[0].windDirDay == undefined ? '--' : daily[0].windDirDay }}
					{{daily[0].windSpeedDay == undefined ? '--' : daily[0].windSpeedDay}}级
				</view>
			</view>
			<view class="weather_right" @click="btngd">
				更多天气 <view class="iconfont icon-xiangyou1"></view>
			</view>
		</view>
		<view class="weather">
			<view class="weather_left">
				<view class="txt">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uZqKuAjf2idHAtkknKEU" mode=""></image>
					{{obj.innerHumidity < -40 || obj.innerHumidity > 100? '--' : obj.innerHumidity}}%
				</view>
				<view class="txt" style="margin-left: 26rpx;">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uJmWnkVE9UeIhNYdPexV" mode=""></image>
					{{obj.innerTemperature < -40 || obj.innerTemperature > 100? '--' : obj.innerTemperature}}℃
				</view>
			</view>
			<view class="weather_right" style="font-weight: 400;font-size: 24rpx;color: #808080;">
				更新于 {{obj.lastOnlineTime == undefined ? '--' : obj.lastOnlineTime}}
			</view>
		</view>
		<view class="setbox">
			<view class="setcard" @click="btnyj">
				<view class="top">
					<view class="left">
						预警记录
					</view>
					<view class="right iconfont icon-xiangyou1">

					</view>
				</view>
				<view class="bot">
					时刻注意蜂箱变化
				</view>
				<view class="img">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uxDnt5rGbJcc6mU6W3cE" mode=""></image>
				</view>
			</view>
			<view class="setcard" @click="btnvideo">
				<view class="top">
					<view class="left">
						操作日志
					</view>
					<view class="right iconfont icon-xiangyou1">

					</view>
				</view>
				<view class="bot">
					记录蜂箱情况
				</view>
				<view class="img">
					<image src="https://api.ccttiot.com/smartmeter/img/static/u90wdyoHsspUHR6tpifv" mode=""></image>
				</view>
			</view>

		</view>
		<view class="card_top">
			<view class="name">
				<!-- {{obj.name == undefined ? '--' : obj.name}} -->
				箱内环境
			</view>
			<view class="time">
				{{obj.lastOnlineTime == undefined ? '--' : obj.lastOnlineTime}}
			</view>
			<view class="ele" v-if="obj.onlineStatus == 1">
				<image style="height: 25rpx;" v-if="obj.surplusPowerPoint <= 100 && obj.surplusPowerPoint >= 80"
					src="https://api.ccttiot.com/smartmeter/img/static/uWbKPMvIuFZjzviEJjmP" mode=""></image>
				<image style="height: 25rpx;" v-if="obj.surplusPowerPoint < 80 && obj.surplusPowerPoint >= 50"
					src="https://api.ccttiot.com/smartmeter/img/static/u0mCXpSrvcROLCMsahNh" mode=""></image>
				<image style="height: 25rpx;" v-if="obj.surplusPowerPoint < 50 && obj.surplusPowerPoint >= 20"
					src="https://api.ccttiot.com/smartmeter/img/static/uGGgEPbe8ryHspQPL2o8" mode=""></image>
				<image style="height: 25rpx;" v-if="obj.surplusPowerPoint < 20"
					src="https://api.ccttiot.com/smartmeter/img/static/uIRhPmP5WUJaIg0nft9E" mode=""></image>
				{{obj.surplusPowerPoint == undefined ? '--' : obj.surplusPowerPoint}}%
			</view>
			<view class="ele" v-else>
				<image style="height: 25rpx;" v-if="ver_data.bat <= 100 && ver_data.bat >= 80"
					src="https://api.ccttiot.com/smartmeter/img/static/uWbKPMvIuFZjzviEJjmP" mode=""></image>
				<image style="height: 25rpx;" v-if="ver_data.bat < 80 && ver_data.bat >= 50"
					src="https://api.ccttiot.com/smartmeter/img/static/u0mCXpSrvcROLCMsahNh" mode=""></image>
				<image style="height: 25rpx;" v-if="ver_data.bat < 50 && ver_data.bat >= 20"
					src="https://api.ccttiot.com/smartmeter/img/static/uGGgEPbe8ryHspQPL2o8" mode=""></image>
				<image style="height: 25rpx;" v-if="ver_data.bat < 20"
					src="https://api.ccttiot.com/smartmeter/img/static/uIRhPmP5WUJaIg0nft9E" mode=""></image>
				{{this.point == undefined ? '--' : this.point}}%
			</view>
		</view>
		<view class="echarts_box" v-if="xnwd" @click="btnec(1)">
			<view class="echarts_top">
				<view class="top_left">
					温度
					<image style="width: 36rpx;height: 34rpx;"
						src="https://api.ccttiot.com/smartmeter/img/static/utoKXhZBoejfRZwNUMP9" mode=""></image>
				</view>
				<view class="top_cont" v-if="obj.onlineStatus == 1">
					当前 {{obj.innerTemperature == undefined ? '--' : obj.innerTemperature}}℃
				</view>
				<view class="top_cont" v-else>
					当前 {{ver_data.temp_n == undefined ? '--' : ver_data.temp_n}}℃
				</view>
				<view class="top_right">
					<view style="width: 1rpx;">

					</view>
					<view class="txt">
						历史走势<view class="iconfont icon-xiangyou1"></view>
					</view>

				</view>
			</view>
			<view class="echarts">
				<uni-ec-canvas class="uni-ec-canvas" id="uni-ec-canvas" ref="canvas1" canvas-id="uni-ec-canvas"
					:ec="ec">
				</uni-ec-canvas>
			</view>
		</view>
		<view class="echarts_box" v-if="xnsd" @click="btnec(2)">
			<view class="echarts_top">
				<view class="top_left">
					湿度
					<image style="width: 30rpx;height: 32rpx;"
						src="https://api.ccttiot.com/smartmeter/img/static/una6Kbd2gdBZ9gG6lg44" mode=""></image>
				</view>
				<view class="top_cont" v-if="obj.onlineStatus == 1">
					当前 {{obj.innerHumidity == undefined ? '--' : obj.innerHumidity}}%
				</view>
				<view class="top_cont" v-else>
					当前 {{ver_data.hp_n == undefined ? '--' : ver_data.hp_n}}%
				</view>
				<view class="top_right">
					<view style="width: 1rpx;">

					</view>
					<view class="txt">
						历史走势<view class="iconfont icon-xiangyou1"></view>
					</view>

				</view>
			</view>
			<view class="echarts">
				<uni-ec-canvas class="uni-ec-canvas" id="uni-ec-canvas" ref="canvas2" canvas-id="uni-ec-canvas"
					:ec="ec">
				</uni-ec-canvas>
			</view>
		</view>
		<view class="echarts_box" v-if="height" @click="btnec(3)">
			<view class="echarts_top">
				<view class="top_left">
					重量
					<image style="width: 28rpx;height: 33rpx;"
						src="https://api.ccttiot.com/smartmeter/img/static/uk7CvwzeU0ukxvS9cBtD" mode=""></image>
				</view>
				<view class="top_cont" v-if="obj.onlineStatus == 1">
					当前 {{obj.totalWeight == 999999 ? '--' : (obj.totalWeight / 1000).toFixed(1)}}kg
				</view>
				<view class="top_cont" v-else>
					当前 {{ver_data.weight == undefined ? '--' : (ver_data.weight / 1000).toFixed(1)}}kg
				</view>
				<view class="top_right">
					<view style="width: 1rpx;">

					</view>
					<view class="txt">
						历史走势<view class="iconfont icon-xiangyou1"></view>
					</view>

				</view>
			</view>
			<view class="echarts">
				<uni-ec-canvas class="uni-ec-canvas" id="uni-ec-canvas" ref="canvas3" canvas-id="uni-ec-canvas"
					:ec="ec">
				</uni-ec-canvas>
			</view>
		</view>
		<view class="echarts_box" v-if="io" @click="btnec(4)">
			<view class="echarts_top">
				<view class="top_left">
					进出量
					<image style="width: 33rpx;height: 33rpx;"
						src="https://api.ccttiot.com/smartmeter/img/static/uhsU6Y1K35jxA4aRauzy" mode=""></image>
				</view>
				<view class="top_cont" v-if="obj.onlineStatus == 1">
					当前 {{obj.ioCountDay  == undefined ? '--' : obj.ioCountDay}}只
				</view>
				<view class="top_cont" v-else>
					当前 {{ver_data.out_day == undefined ? '--' : ver_data.out_day}}只
				</view>
				<view class="top_right">
					<view style="width: 1rpx;">

					</view>
					<view class="txt">
						历史走势<view class="iconfont icon-xiangyou1"></view>
					</view>

				</view>
			</view>
			<view class="echarts">
				<uni-ec-canvas class="uni-ec-canvas" id="uni-ec-canvas" ref="canvas4" canvas-id="uni-ec-canvas"
					:ec="ec">
				</uni-ec-canvas>
			</view>
		</view>
		<view class="echarts_box" v-if="sypl" @click="btnec(5)">
			<view class="echarts_top">
				<view class="top_left">
					频率
					<image style="width: 38rpx;height: 32rpx;"
						src="https://api.ccttiot.com/smartmeter/img/static/up9IaGzSg1RKhIZz3V7a" mode=""></image>
				</view>
				<view class="top_cont" v-if="obj.onlineStatus == 1">
					当前 {{obj.volume / 1000 == 0 ? obj.volume : (obj.volume / 1000).toFixed(1)}}khz
				</view>
				<view class="top_cont" v-else>
					当前 {{(ver_data.MIC !== undefined && !isNaN(ver_data.MIC) && ver_data.MIC / 1000 === 0) ? ver_data.MIC : ((ver_data.MIC !== undefined && !isNaN(ver_data.MIC)) ? (ver_data.MIC / 1000).toFixed(1) : '--')}}khz
				</view>
				<view class="top_right">
					<view style="width: 1rpx;">

					</view>
					<view class="txt">
						历史走势<view class="iconfont icon-xiangyou1"></view>
					</view>

				</view>
			</view>
			<view class="echarts">
				<uni-ec-canvas class="uni-ec-canvas" id="uni-ec-canvas" ref="canvas5" canvas-id="uni-ec-canvas"
					:ec="ec">
				</uni-ec-canvas>
			</view>
		</view>
		<view class="echarts_box" v-if="eyht" @click="btnec(6)">
			<view class="echarts_top">
				<view class="top_left">
					二氧化碳
					<image style="width: 36rpx;height: 38rpx;"
						src="https://api.ccttiot.com/smartmeter/img/static/uAw3ZCXnMbekNML7CTSu" mode=""></image>
				</view>
				<view class="top_cont" v-if="obj.onlineStatus == 1">
					当前 {{obj.innerCo2}}ppm
				</view>
				<view class="top_cont" v-else>
					当前 {{ver_data.CO2 == undefined ? '--' : ver_data.CO2}}ppm
				</view>
				<view class="top_right">
					<view style="width: 1rpx;">

					</view>
					<view class="txt">
						历史走势<view class="iconfont icon-xiangyou1"></view>
					</view>

				</view>
			</view>
			<view class="echarts">
				<uni-ec-canvas class="uni-ec-canvas" id="uni-ec-canvas" ref="canvas6" canvas-id="uni-ec-canvas"
					:ec="ec">
				</uni-ec-canvas>
			</view>
		</view>
		<view class="weather_info" v-show="showtq">
			<view class="top">
				<view class="weather_info_tit">
					未来7日天气预知
				</view>
				<image src="https://api.ccttiot.com/smartmeter/img/static/uQK4q99a1Qb7LFD6O3Hw" mode=""
					@click="showtq = false"></image>
			</view>
			<view class="top" style="margin-top: 14rpx;">
				<view class="weather_add">
					蜂场位置:<span style="color: #42A5F5;">{{obj.apiaryCounty == undefined ? '--' : obj.apiaryCounty}}</span>
				</view>
				<view class="up_time">
					{{daytime}}更新
				</view>
			</view>
			<view class="weather_cont">
				<view class="weather_li" v-for="(item,index) in daily" :key="index">
					<view class="data">
						{{item.fxDate.slice(5)}}
					</view>
					<view class="week">
						{{item.textDay}}
					</view>
					<view class="week_weather" >
						{{item.windDirDay}}
					</view>
				</view>
			</view>
			<view class="echarts_box">
				<uni-ec-canvas class="uni-ec-canvas" id="uni-ec-canvas" ref="canvas7" canvas-id="uni-ec-canvas"
					:ec="ec">
				</uni-ec-canvas>
			</view>
		</view>
		<view class="bottom_box">
			<view class="type_li" @click="btndow(1)">
				去皮
			</view>
			<view class="type_li" @click="btndow(2)" v-if="beep">
				蜂鸣寻箱
			</view>
			<view class="type_li" :id="fskx == '关' ? 'active' : ''" @click="btndow(3)">
				风扇:{{fskx}}
			</view>
			<view class="type_li" :id="jrkg == '关' ? 'active' : ''" @click="btndow(4)">
				加热:{{jrkg}}
			</view>
		</view>
		<view class="mask" v-if="showtq"></view>
	</view>
</template>

<script>
	var xBlufi = require("@/components/blufi/xBlufi.js")
	import uniEcCanvas from '@/components/uni-ec-canvas/uni-ec-canvas.vue'
	import * as echarts from '@/components/uni-ec-canvas/echarts'
	let chart = null
	export default {
		components: {
			uniEcCanvas
		},
		data() {
			return {
				menuflag: false,
				ec: {
					lazyLoad: true
				},
				bgc: {
					backgroundColor: " #FAFDFD",
				},
				title: "蜂箱详情",
				latitude: '7',
				longitude: '',
				isMap: false,
				zoomSize: 15,
				markers: [{
					id: 1,
					latitude: 39.90469,
					longitude: 116.40717,
					title: 'Marker1'
				}, {
					id: 2,
					latitude: 39.90969,
					longitude: 116.41217,
					title: 'Marker2'
				}],
				chartday: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
				chartData: [120, 200, 150, 80, 70, 110, 130],
				showtq: false,
				beehiveId: '',
				obj: {},
				daily: [],
				fskx: '关',
				jrkg: '关',
				chartData1: [],
				chartData2: [],
				chartData3: [],
				chartData4: [],
				chartData5: [],
				chartData6: [],
				chartData7: [],
				chartData8: [],
				yeartime: {
					year: '',
					month: '',
					day: ''
				},
				yeartimes: {
					year: '',
					month: '',
					day: ''
				},
				daytime: '',
				covers: [],
				dtflag: false,
				modelTags: [],

				height: false,
				io: false,
				xnwd: false,
				xnsd: false,
				sypl: false,
				eyht: false,
				beep: false,
				timer: null,
				mac:'',
				devicesList:[],
				ver_data:{},
				zcljflag:false,
				ljcgflag:false,
				wljflag:false,
				tbszflag:false,
				shezhiobj:{},
				scdeviceflag:true,
				point:''
			}
		},
		onLoad(option) {
			this.beehiveId = option.beehiveId
		},
		onShow() {
			this.zcljflag = false
			this.wljflag = false
			this.ljcgflag = false
			this.tbszflag = false
			setTimeout(() => {
				this.$refs.canvas1.init(this.initChart)
				this.$refs.canvas2.init(this.initChart2)
				this.$refs.canvas3.init(this.initChart3)
				this.$refs.canvas4.init(this.initChart4)
				this.$refs.canvas5.init(this.initChart5)
				this.$refs.canvas6.init(this.initChart6)
				this.$refs.canvas7.init(this.initChart7)
			}, 1000)
			this.getobj()
			let now = new Date();
			let previousDay = new Date(now)
			this.yeartime.year = now.getFullYear()
			this.yeartime.month = String(previousDay.getMonth() + 1).padStart(2, '0')
			this.yeartime.day = String(now.getDate()).padStart(2, '0')

			previousDay.setDate(now.getDate() - 7)
			this.yeartimes.year = previousDay.getFullYear()
			this.yeartimes.month = String(previousDay.getMonth() + 1).padStart(2, '0')
			this.yeartimes.day = String(previousDay.getDate()).padStart(2, '0')
			this.getchartData1()
			this.getchartData2()
			this.getchartData3()
			this.getchartData4()
			this.getchartData5()
			this.getchartData6()
		},
		onUnload() {
			// 页面即将销毁时销毁定时器  
			this.clearTimer()
		},
		methods: {
			// 获取设置数据值
			getinfo() {
				this.$u.get(`farm/userSetting/my`).then(res => {
					if (res.code == 200) {
						this.shezhiobj = res.data
						// miteInterval: '', //除螨间隔时间(天) 
						// minPower: '', //电量保护最低电量%
						// minHeat: '', //加热板开始工作的最低箱外温度℃
						// maxHeat: '', //加热板停止工作的箱内外温差℃
						// maxFan: '', //风扇开始工作的最高箱内温度℃
						// minFan: '', //风扇停止工作的最低箱内温度℃
						// minCo2: '', //风扇停止工作的最低二氧化碳浓度℃
						// maxCo2: '', //风扇开始工作的最高二氧化碳浓度℃
					}
				})
			},
			// 连接蓝牙成功 点击同步设置
			btntbsz(){
				// xBlufi.notifySendCustomData({
				//       customData: ""
				// })
			},
			// 根据蜂箱id获取设备信息
			getobj() {
				this.$u.get(`/app/beehive/${this.beehiveId}`).then(res => {
					if (res.code == 200) {
						if(res.data.onlineStatus == 0){ //判断蜂箱离线时
						 	this.mac = res.data.mac
						 	this.Binddevice() //执行连接蓝牙方法
						 	this.getinfo()  //获取设置数值
						}else{
							// 每次进入执行定时器
							this.startTimer()
						}
						this.obj = res.data
						if(res.data.lat == null  || res.data.lng == null){
							this.latitude = 27.100845
							this.longitude = 120.25469
						}else{
							this.latitude = res.data.lat
							this.longitude = res.data.lng
						}
						this.modelTags = res.data.modelTags
						this.modelTags.forEach(item => {
							if (item == 1) {
								this.height = true
							} else if (item == 2) {
								this.io = true
							} else if (item == 3) {
								this.xnwd = true
								this.xnsd = true
							} else if (item == 10) {
								this.sypl = true
							} else if (item == 9) {
								this.eyht = true
							} else if (item == 13) {
								this.beep = true
							}
						})
						if (res.data.enableFan == false) {
							this.fskx = '关'
						} else {
							this.fskx = '开'
						}
						if (res.data.enableHeat == false) {
							this.jrkg = '关'
						} else {
							this.jrkg = '开'
						}
						this.dtflag = false
						this.covers.push({
							id: parseFloat(res.data.beehiveId),
							latitude: this.latitude,
							longitude: this.longitude,
							width: 30,
							height: 33,
							iconPath: 'https://api.ccttiot.com/smartmeter/img/static/ukbyhyrDcp3VzgyeJo2G',
						})
			
						this.gettq()
					} else if(res.code == 401){
						uni.showModal({
							title: '温馨提示',
							content: '您还未登录,是否先去登录',
							showCancel: true ,
							success: function(res) {
							     if (res.confirm) { 
							        uni.reLaunch({
							        	url:'/pages/login/login'
							        })
							    }
							}	
						})
					}else{
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						})
					}
				})
			},
			
			// 蓝牙连接
			Binddevice() {
				this.zcljflag = true
				this.wljflag = false
				this.ljcgflag = false
				xBlufi.initXBlufi(1);
				xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
				xBlufi.notifyStartDiscoverBle({
					'isStart': true
				})
				// 两秒后停止蓝牙搜索
				setTimeout(() => {
					xBlufi.notifyStartDiscoverBle({
						'isStart': false
					})
					setTimeout(() => {
						if (this.devicesList.length == 0) {
							this.zcljflag = false
							this.wljflag = true
							this.ljcgflag = false
							// let that = this
							// uni.showModal({
							// 	title: '温馨提示',
							// 	content: '暂未发现蜂箱设备,是否重新搜索连接',
							// 	showCancel: true ,//是否显示取消按钮
							// 	success:function(res) {
							// 		that.Binddevice()
							// 	}			
							// })
						} else {
							let uniqueDevicesList = Array.from(new Set(this.devicesList))
							this.devicesList = uniqueDevicesList
							console.log(this.devicesList,'列表');
							// 初始化一个标志变量,用于跟踪是否有匹配
							let isMatched = false
							// 遍历设备列表
							this.devicesList.forEach(device => {
							    // 从设备名称中提取MAC地址(假设MAC地址是设备名称的最后12个字符)
							    let macFromName = device.name.substring(device.name.length - 12)
							    console.log(macFromName,this.mac)
							    // 检查MAC地址是否匹配
							    if (macFromName == this.mac) {
							        this.createBLEConnection(device)
							        console.log('对比正确')
							        isMatched = true // 设置标志为true,表示有匹配
							    } else {
							        console.log('对比错误')
							    }
							})
							// 循环结束后检查是否有匹配
							if (!isMatched) {
							    this.zcljflag = false
							    this.wljflag = true
							    this.ljcgflag = false
								let that = this
								uni.showModal({
									title: '温馨提示',
									content: '暂未发现蜂箱设备,是否重新搜索连接',
									showCancel: true ,
									success: function(res) {
									     if (res.confirm) { 
									        that.Binddevice()
									    }
									}	
								})
							}else{
								this.zcljflag = false
								this.wljflag = false
								this.ljcgflag = true
							}
						}
					}, 200)
				}, 3000)
			},
			// 收取蓝牙信息
			createBLEConnection(e) {
				xBlufi.notifyStartDiscoverBle({
					'isStart': false
				});
				console.log(e, '蓝牙信息')
				const deviceId = e.deviceId
				let name = e.name;
				xBlufi.notifyConnectBle({
					isStart: true,
					deviceId: e.deviceId,
					name
				})
			},
			// 处理蓝牙函数
			funListenDeviceMsgEvent: function(options) {
				let that = this;
				switch (options.type) {
					case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
						if (options.result) {
							let devicesarr = options.data
							devicesarr.forEach(device => {
								this.devicesList.push(device);
								let uniqueDevicesList = Array.from(new Set(this.devicesList));
								// 将去重后的数组重新赋值给 this.devicesList
								this.devicesList = uniqueDevicesList
							})
						}
						break
					case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
						console.log("连接回调:" + JSON.stringify(options))
                        uni.showToast({
                        	title: '连接成功',
                        	icon: 'success',
                        	duration:2000
                        })
						this.zcljflag = false
						this.wljflag = false
						this.ljcgflag = true
						this.tbszflag = true
						{
							xBlufi.notifyInitBleEsp32({
								deviceId: options.data.deviceId
							})
						}
						break
					case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA:
						this.loadPercent = options.data;
						this.loadText = '文件读取中'
						console.log("文件读取中", options.data);
						break
					case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
						let dataString = options.data
						// 移除字符串开头和结尾的花括号
						dataString = dataString.slice(1, -1);
						// 使用正则表达式和 split 方法将字符串分割成键值对
						let pairs = dataString.match(/([^,]+)/g);
						let obj = {};
						// 遍历键值对数组,并将它们添加到对象中
						pairs.forEach(pair => {
						    let [key, value] = pair.split(':');
						    obj[key] = !isNaN(value) ? parseFloat(value) : value;
						})
						this.ver_data = obj
                        if(this.ver_data.bat != '' || this.ver_data.bat != undefined){ //判断是否接受到设备数据
						    this.point =  (1 - (this.obj.modelMaxV - this.ver_data.bat) / (this.obj.modelMaxV -this.obj.modelMinV)) * 100
							if(this.scdeviceflag == true){ //判断是否已经上传过
							    let data = {
								   beehiveId:this.beehiveId,
								   sys:this.ver_data
							    }
								this.$u.put(`app/beehive/btUpload`,data).then(res => { 
									if(res.code == 200){
										this.scdeviceflag = false //一次性只上传一次
									}else{
										this.scdeviceflag = false //一次性只上传一次
									}
								})
							}
						}
						console.log('收取到的蓝牙数据',this.ver_data,options.data)
						break
					case xBlufi.XBLUFI_TYPE.TYPE_INIT_ESP32_RESULT:
						if (options.result) {
							console.log('初始化成功')
						} else {
							console.log('初始化失败')
							this.zcljflag = false
							this.wljflag = true
							this.ljcgflag = false
							break
						}
						break
					case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
						if (!options.result) {
							this.zcljflag = false
							this.wljflag = true
							this.ljcgflag = false
							uni.showToast({
								title: '蓝牙未开启',
								icon: 'none',
								duration: 3000
							})
							return
						}
						break
					case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: {
						console.log('蓝牙异常断开', options.result)
					}
					break;
				}
			},
			
			
			
			// 跳转天气
			btntqxq(){
				
			},
			// 每30秒上报数据
			startTimer() {
				if (this.timer) {
					clearInterval(this.timer); // 如果已存在,先清除  
				}
				this.timer = setInterval(() => {
					// 这里写你的定时任务  
                    this.$u.put(`/app/beehive/iot/${this.beehiveId}/upload`).then(res => {
                    	if (res.code == 200) {
                    		setTimeout(() => {
                    			this.$refs.canvas1.init(this.initChart)
                    			this.$refs.canvas2.init(this.initChart2)
                    			this.$refs.canvas3.init(this.initChart3)
                    			this.$refs.canvas4.init(this.initChart4)
                    			this.$refs.canvas5.init(this.initChart5)
                    			this.$refs.canvas6.init(this.initChart6)
                    			this.$refs.canvas7.init(this.initChart7)
                    		}, 1000)
                    		this.getobj()
                    		let now = new Date();
                    		let previousDay = new Date(now)
                    		this.yeartime.year = now.getFullYear()
                    		this.yeartime.month = String(previousDay.getMonth() + 1).padStart(2, '0')
                    		this.yeartime.day = String(now.getDate()).padStart(2, '0')
                    		previousDay.setDate(now.getDate() - 7)
                    		this.yeartimes.year = previousDay.getFullYear()
                    		this.yeartimes.month = String(previousDay.getMonth() + 1).padStart(2, '0')
                    		this.yeartimes.day = String(previousDay.getDate()).padStart(2, '0')
                    		this.getchartData1()
                    		this.getchartData2()
                    		this.getchartData3()
                    		this.getchartData4()
                    		this.getchartData5()
                    		this.getchartData6()
                    	}
                    })
				}, 30000); // 30秒  
			},
			clearTimer() {
				// 清除定时器  
				if (this.timer) {
					clearInterval(this.timer);
					this.timer = null; // 清除引用,避免内存泄漏  
				}
			},


			// 跳转图标详情
			btnec(num) {
				uni.navigateTo({
					url: '/page_Beehive/Beehive_ec?num=' + num + '&beehiveId=' + this.beehiveId
				})
			},
			// 点击跳转到操作详情
			btnvideo() {
				const user = uni.getStorageSync('user')
				if(this.obj.userId == user.userId){
					if(this.obj.apiaryId == '' || this.obj.apiaryId == null){
						let that = this
						uni.showModal({
							title: "提示",
							content: '请将该设备绑定蜂场在进行此操作',
							success: function(res) {
								if (res.confirm) {
					                uni.navigateTo({
					                	url:'/page_Beehive/add_Beehive?tit=' + '修改蜂箱' + '&beehiveId=' + that.beehiveId
					                })
								}
							}
						})
					}else{
					   uni.navigateTo({
					   	url: '/page_Beehive/Beehive_log?apiaryId=' + this.obj.apiaryId + ' &name=' + this.obj.apiaryName
					   })
					}
				}else{
					uni.showToast({
						title: '您没有权限操作',
						icon: 'none',
						duration: 2000
					})
				}
			},
			// 点击展开天气
			btngd() {
				// this.gettq()
				setTimeout(() => {
					this.$refs.canvas7.init(this.initChart7)
				}, 200);
				this.showtq = true
			},
			// 点击跳转预警
			btnyj() {
				const user = uni.getStorageSync('user')
				if(this.obj.userId == user.userId){
					uni.navigateTo({
						url: '/page_Beehive/Beehive_woring?apiaryId=' + this.beehiveId + '&tit=' + '蜂箱预警记录'
					})
				}else{
					uni.showToast({
						title: '您没有权限操作',
						icon: 'none',
						duration: 2000
					})
				}
			},
			// 点击编辑
			btnedit() {
				const user = uni.getStorageSync('user')
				if(this.obj.userId == user.userId){
					this.menuflag = false
					uni.navigateTo({
						url: '/page_Beehive/add_Beehive?tit=' + '修改蜂箱' + '&beehiveId=' + this.beehiveId
					}) 
				}else{
					uni.showToast({
						title: '您没有权限操作',
						icon: 'none',
						duration: 2000
					})
				}
			},
			btnfx() {
				this.menuflag = false
				uni.navigateTo({
					url: '/page_Beehive/share_Beehive'
				})
			},
			btnmenu() {
				if (this.menuflag == true) {
					this.menuflag = false
				} else {
					this.menuflag = true
				}
			},
			// 温度图表
			getchartData1() {
				let time = this.yeartime.year + '-' + this.yeartime.month + '-' + this.yeartime.day
				let times = this.yeartimes.year + '-' + this.yeartimes.month + '-' + this.yeartimes.day
				this.$u.get(`/farmer/report/tempN?dateRange=${times},${time}&beehiveId=${this.beehiveId}`).then(res => {
					if (res.code == 200) {
						this.chartData1 = res.data.map(item => item.value)
					}
				})
			},
			// 湿度图表
			getchartData2() {
				let time = this.yeartime.year + '-' + this.yeartime.month + '-' + this.yeartime.day
				let times = this.yeartimes.year + '-' + this.yeartimes.month + '-' + this.yeartimes.day
				this.$u.get(`/farmer/report/hpN?dateRange=${times},${time}&beehiveId=${this.beehiveId}`).then(res => {
					if (res.code == 200) {
						this.chartData2 = res.data.map(item => item.value)
					}
				})
			},
			// 重量图表
			getchartData3() {
				let time = this.yeartime.year + '-' + this.yeartime.month + '-' + this.yeartime.day
				let times = this.yeartimes.year + '-' + this.yeartimes.month + '-' + this.yeartimes.day
				this.$u.get(`/farmer/report/weightDay?dateRange=${times},${time}&beehiveId=${this.beehiveId}`).then(
					res => {
						if (res.code == 200) {
							this.chartData3 = res.data.map(item => item.value)
						}
					})
			},
			// 进出量图表
			getchartData4() {
				let time = this.yeartime.year + '-' + this.yeartime.month + '-' + this.yeartime.day
				let times = this.yeartimes.year + '-' + this.yeartimes.month + '-' + this.yeartimes.day
				this.$u.get(`/farmer/report/ioCount?dateRange=${times},${time}&beehiveId=${this.beehiveId}`).then(res => {
					if (res.code == 200) {
						this.chartData4 = res.data.map(item => item.value)
					}
				})
			},
			// 频率图表
			getchartData5() {
				let time = this.yeartime.year + '-' + this.yeartime.month + '-' + this.yeartime.day
				let times = this.yeartimes.year + '-' + this.yeartimes.month + '-' + this.yeartimes.day
				this.$u.get(`/farmer/report/mic?dateRange=${times},${time}&beehiveId=${this.beehiveId}`).then(res => {
					if (res.code == 200) {
						this.chartData5 = res.data.map(item => item.value)
					}
				})
			},
			// 二氧化碳图表
			getchartData6() {
				let time = this.yeartime.year + '-' + this.yeartime.month + '-' + this.yeartime.day
				let times = this.yeartimes.year + '-' + this.yeartimes.month + '-' + this.yeartimes.day
				this.$u.get(`/farmer/report/co2?dateRange=${times},${time}&beehiveId=${this.beehiveId}`).then(res => {
					if (res.code == 200) {
						this.chartData6 = res.data.map(item => item.value)
					}
				})
			},
            // 点击进行蜂箱操作
			btndow(num) {
				const user = uni.getStorageSync('user')
				if(this.obj.userId == user.userId){
					if (num == 1) {
						if(this.obj.onlineStatus == 0){
							xBlufi.notifySendCustomData({
							      customData: "11clear_weight@"
							 })
							uni.showToast({
								title: '去皮成功',
								icon: 'success',
								duration: 2000
							})
						}else{
							this.$u.put(`farm/beehive/iot/${this.beehiveId}/clearWeight`).then(res => {
								if (res.code == 200) {
									uni.showToast({
										title: '去皮成功',
										icon: 'success',
										duration: 2000
									})
								} else {
									uni.showToast({
										title: res.msg,
										icon: 'none',
										duration: 2000
									})
								}
							})
						}
					} else if (num == 2) {
						if(this.obj.onlineStatus == 0){
							xBlufi.notifySendCustomData({
							      customData: "11beep11@" + 10
							 })
							uni.showToast({
								title: '响铃成功',
								icon: 'success',
								duration: 2000
							})
						}else{
							this.$u.put(`farm/beehive/iot/${this.beehiveId}/buzzer`).then(res => {
								if (res.code == 200) {
									uni.showToast({
										title: '响铃成功',
										icon: 'success',
										duration: 2000
									})
								} else {
									uni.showToast({
										title: res.msg,
										icon: 'none',
										duration: 2000
									})
								}
							})
						}
					} else if (num == 3) {
						if (this.fskx == '关') {
							if(this.obj.onlineStatus == 0){
								xBlufi.notifySendCustomData({
								     customData: '11fan100@'
								})
								this.fskx = '开'
								uni.showToast({
									title: '风扇开启成功',
									icon: 'success',
									duration: 2000
								})
							}else{
								this.$u.put(`farm/beehive/iot/${this.beehiveId}/fan?open=true`).then(res => {
									if (res.code == 200) {
										if (this.fskx == '关') {
											this.fskx = '开'
										} else {
											this.fskx = '关'
										}
										uni.showToast({
											title: '风扇开启成功',
											icon: 'success',
											duration: 2000
										})
									} else {
										uni.showToast({
											title: res.msg,
											icon: 'none',
											duration: 2000
										})
									}
								})
							}
						} else {
							if(this.obj.onlineStatus == 0){
								xBlufi.notifySendCustomData({
								     customData: "11fan0@"
								})
								this.fskx = '关'
								uni.showToast({
									title: '风扇关闭成功',
									icon: 'success',
									duration: 2000
								})
							}else{
								this.$u.put(`farm/beehive/iot/${this.beehiveId}/fan?open=false`).then(res => {
									if (res.code == 200) {
										if (this.fskx == '关') {
											this.fskx = '开'
										} else {
											this.fskx = '关'
										}
										uni.showToast({
											title: '风扇关闭成功',
											icon: 'success',
											duration: 2000
										})
									} else {
										uni.showToast({
											title: res.msg,
											icon: 'none',
											duration: 2000
										})
									}
								})
							}
						}
					} else if (num == 4) {
						if (this.jrkg == '关') {
							if(this.obj.onlineStatus == 0){
								xBlufi.notifySendCustomData({
							         customData: "11hot100@"
							    })
								this.jrkg = '开'
								uni.showToast({
									title: '加热开启成功',
									icon: 'success',
									duration: 2000
								})
							}else{
								this.$u.put(`farm/beehive/iot/${this.beehiveId}/heat?open=true`).then(res => {
									if (res.code == 200) {
										if (this.jrkg == '关') {
											this.jrkg = '开'
										} else {
											this.jrkg = '关'
										}
										uni.showToast({
											title: '加热开启成功',
											icon: 'success',
											duration: 2000
										})
									} else {
										uni.showToast({
											title: res.msg,
											icon: 'none',
											duration: 2000
										})
									}
								})
							}
						} else {
							if(this.obj.onlineStatus == 0){
								xBlufi.notifySendCustomData({
								     customData: "11hot0@"
								})
								this.jrkg = '关'
								uni.showToast({
									title: '加热关闭成功',
									icon: 'success',
									duration: 2000
								})
							}else{
								this.$u.put(`farm/beehive/iot/${this.beehiveId}/heat?open=false`).then(res => {
									if (res.code == 200) {
										if (this.jrkg == '关') {
											this.jrkg = '开'
										} else {
											this.jrkg = '关'
										}
										uni.showToast({
											title: '加热关闭成功',
											icon: 'success',
											duration: 2000
										})
									} else {
										uni.showToast({
											title: res.msg,
											icon: 'none',
											duration: 2000
										})
									}
								})
							}
						}
					}
				}else{
					uni.showToast({
						title: '您没有权限操作',
						icon: 'none',
						duration: 2000
					})
				}
			},
			// 请求天气
			gettq() {
				this.$u.get(`weather/7d?location=${this.longitude},${this.latitude}`).then(res => {
					if (res.code == 200) {
						this.daily = res.data.daily
						this.chartData7 = res.data.daily.map(item => item.tempMin)
						this.chartData8 = res.data.daily.map(item => item.tempMax)
						this.daytime = res.data.updateTime
						let date = new Date(this.daytime);
						let formattedDate = this.formatDate(date)
						this.daytime = formattedDate
					}
				})
			},
			// 进行时间解析
			formatDate(date) {
				let year = date.getFullYear()
				let month = String(date.getMonth() + 1).padStart(2, '0')
				let day = String(date.getDate()).padStart(2, '0')
				let hours = String(date.getHours()).padStart(2, '0')
				let minutes = String(date.getMinutes()).padStart(2, '0')
				return `${year}-${month}-${day} ${hours}:${minutes}`
			},


			// 温度
			initChart(canvas, width, height, canvasDpr) {
				let that = this

				const option = {
					grid: {
						left: '4%',
						right: '4%',
						bottom: '3%',
						top: '4%',
						containLabel: true
					},
					xAxis: {
						show: true,
						type: 'category',
						boundaryGap: false,
						axisLine: {
							show: false // 隐藏X轴线
						},
						axisTick: {
							show: false // 隐藏X轴刻度
						},
						axisLabel: {
							show: false // 隐藏X轴标签
						},
						axisLabel: {
							show: true,
							color: '#ccc',
							fontSize: 11,
							rotate: 0,
						},
						splitLine: {
							show: false,
						},
						// data: that.chartday,
					},
					yAxis: {
						show: true,
						axisLine: {
							show: false,
						},
						axisTick: {
							show: false,
						},
						axisLabel: {
							show: true,
							color: '#ccc',
							fontSize: 11,
							formatter: function(value) {
								// 保留两位小数,没有小数时显示00
								return value + '℃'
							},
						},
						splitLine: {
							show: true, // 显示X轴网格线
							lineStyle: {
								type: 'dashed', // 设置网格线为虚线
								color: '#ccc', // 可以设置虚线的颜色
								width: 1 // 可以设置虚线的宽度
							}
						}
					},
					visualMap: {
						type: 'piecewise',
						show: false,
						dimension: 0,
						seriesIndex: 0,
						pieces: [{
								gt: 1,
								lt: 3,
								color: 'RGBA(255, 241, 201, 1)',
							},
							{
								gt: 5,
								lt: 7,
								color: 'RGBA(255, 241, 201, 1)',
							},
						],
					},
					series: [{
						type: 'line',
						smooth: 0.6,
						symbol: 'none',
						lineStyle: {
							color: '#FFE28C',
							width: 1,
						},
						areaStyle: {
							normal: {
								color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
									offset: 0,
									color: '#FFF1C9'
								}, ]),
							},
						},
						data: that.chartData1,
					}],
				};
				chart = echarts.init(canvas, null, {
					width: width,
					height: height,
					devicePixelRatio: canvasDpr
				})
				option.series[0].data = that.chartData1
				canvas.setChart(chart)
				chart.setOption(option)
				return chart
			},
			// 湿度
			initChart2(canvas, width, height, canvasDpr) {
				let that = this
				const option = {
					grid: {
						left: '4%',
						right: '4%',
						bottom: '3%',
						top: '4%',
						containLabel: true
					},
					xAxis: {
						show: true,
						type: 'category',
						boundaryGap: false,
						axisLine: {
							show: false // 隐藏X轴线
						},
						axisTick: {
							show: false // 隐藏X轴刻度
						},
						axisLabel: {
							show: false // 隐藏X轴标签
						},
						axisLabel: {
							show: true,
							color: '#ccc',
							fontSize: 11,
							rotate: 0,
						},
						splitLine: {
							show: false,
						},
						// data: that.chartday,
					},
					yAxis: {
						show: true,
						axisLine: {
							show: false,
						},
						axisTick: {
							show: false,
						},
						axisLabel: {
							show: true,
							color: '#ccc',
							fontSize: 11,
							formatter: function(value) {
								// 保留两位小数,没有小数时显示00
								return value + '%'
							},
						},
						splitLine: {
							show: true, // 显示X轴网格线
							lineStyle: {
								type: 'dashed', // 设置网格线为虚线
								color: '#ccc', // 可以设置虚线的颜色
								width: 1 // 可以设置虚线的宽度
							}
						}
					},
					visualMap: {
						type: 'piecewise',
						show: false,
						dimension: 0,
						seriesIndex: 0,
						pieces: [{
								gt: 1,
								lt: 3,
								color: 'RGBA(255, 241, 201, 1)',
							},
							{
								gt: 5,
								lt: 7,
								color: 'RGBA(255, 241, 201, 1)',
							},
						],
					},
					series: [{
						type: 'line',
						smooth: 0.6,
						symbol: 'none',
						lineStyle: {
							color: '#FFE28C',
							width: 1,
						},
						areaStyle: {
							normal: {
								color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
									offset: 0,
									color: '#FFF1C9'
								}, ]),
							},
						},
						data: that.chartData2,
					}],
				};
				chart = echarts.init(canvas, null, {
					width: width,
					height: height,
					devicePixelRatio: canvasDpr
				})
				option.series[0].data = that.chartData2
				canvas.setChart(chart)
				chart.setOption(option)
				return chart
			},
			//重量
			initChart3(canvas, width, height, canvasDpr) {
				let that = this
				const option = {
					grid: {
						left: '4%',
						right: '4%',
						bottom: '3%',
						top: '4%',
						containLabel: true
					},
					xAxis: {
						show: true,
						type: 'category',
						boundaryGap: false,
						axisLine: {
							show: false // 隐藏X轴线
						},
						axisTick: {
							show: false // 隐藏X轴刻度
						},
						axisLabel: {
							show: false // 隐藏X轴标签
						},
						axisLabel: {
							show: true,
							color: '#ccc',
							fontSize: 11,
							rotate: 0,
						},
						splitLine: {
							show: false,
						},
						// data: that.chartday,
					},
					yAxis: {
						show: true,
						axisLine: {
							show: false,
						},
						axisTick: {
							show: false,
						},
						axisLabel: {
							show: true,
							color: '#ccc',
							fontSize: 11,
							formatter: function(value) {
								// 保留两位小数,没有小数时显示00
								return (value / 1000).toFixed(1) + 'Kg'
							},
						},
						splitLine: {
							show: true, // 显示X轴网格线
							lineStyle: {
								type: 'dashed', // 设置网格线为虚线
								color: '#ccc', // 可以设置虚线的颜色
								width: 1 // 可以设置虚线的宽度
							}
						}
					},
					visualMap: {
						type: 'piecewise',
						show: false,
						dimension: 0,
						seriesIndex: 0,
						pieces: [{
								gt: 1,
								lt: 3,
								color: 'RGBA(255, 241, 201, 1)',
							},
							{
								gt: 5,
								lt: 7,
								color: 'RGBA(255, 241, 201, 1)',
							},
						],
					},
					series: [{
						type: 'line',
						smooth: 0.6,
						symbol: 'none',
						lineStyle: {
							color: '#FFE28C',
							width: 1,
						},
						areaStyle: {
							normal: {
								color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
									offset: 0,
									color: '#FFF1C9'
								}, ]),
							},
						},
						data: that.chartData3,
					}],
				};
				chart = echarts.init(canvas, null, {
					width: width,
					height: height,
					devicePixelRatio: canvasDpr
				})
				option.series[0].data = that.chartData3
				canvas.setChart(chart)
				chart.setOption(option)
				return chart
			},
			// 进出量
			initChart4(canvas, width, height, canvasDpr) {
				let that = this
				const option = {
					grid: {
						left: '4%',
						right: '4%',
						bottom: '3%',
						top: '4%',
						containLabel: true
					},
					xAxis: {
						show: true,
						type: 'category',
						boundaryGap: false,
						axisLine: {
							show: false // 隐藏X轴线
						},
						axisTick: {
							show: false // 隐藏X轴刻度
						},
						axisLabel: {
							show: false // 隐藏X轴标签
						},
						axisLabel: {
							show: true,
							color: '#ccc',
							fontSize: 11,
							rotate: 0,
						},
						splitLine: {
							show: false,
						},
						// data: that.chartday,
					},
					yAxis: {
						show: true,
						axisLine: {
							show: false,
						},
						axisTick: {
							show: false,
						},
						axisLabel: {
							show: true,
							color: '#ccc',
							fontSize: 11,
							formatter: function(value) {
								// 保留两位小数,没有小数时显示00
								return Math.ceil(value) + '只'
							},
						},
						splitLine: {
							show: true, // 显示X轴网格线
							lineStyle: {
								type: 'dashed', // 设置网格线为虚线
								color: '#ccc', // 可以设置虚线的颜色
								width: 1 // 可以设置虚线的宽度
							}
						}
					},
					visualMap: {
						type: 'piecewise',
						show: false,
						dimension: 0,
						seriesIndex: 0,
						pieces: [{
								gt: 1,
								lt: 3,
								color: 'RGBA(255, 241, 201, 1)',
							},
							{
								gt: 5,
								lt: 7,
								color: 'RGBA(255, 241, 201, 1)',
							},
						],
					},
					series: [{
						type: 'line',
						smooth: 0.6,
						symbol: 'none',
						lineStyle: {
							color: '#FFE28C',
							width: 1,
						},
						areaStyle: {
							normal: {
								color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
									offset: 0,
									color: '#FFF1C9'
								}, ]),
							},
						},
						data: that.chartData4,
					}],
				};
				chart = echarts.init(canvas, null, {
					width: width,
					height: height,
					devicePixelRatio: canvasDpr
				})
				option.series[0].data = that.chartData4
				canvas.setChart(chart)
				chart.setOption(option)
				return chart
			},
			// 频率
			initChart5(canvas, width, height, canvasDpr) {
				let that = this
				const option = {
					grid: {
						left: '4%',
						right: '4%',
						bottom: '3%',
						top: '4%',
						containLabel: true
					},
					xAxis: {
						show: true,
						type: 'category',
						boundaryGap: false,
						axisLine: {
							show: false // 隐藏X轴线
						},
						axisTick: {
							show: false // 隐藏X轴刻度
						},
						axisLabel: {
							show: false // 隐藏X轴标签
						},
						axisLabel: {
							show: true,
							color: '#ccc',
							fontSize: 11,
							rotate: 0,
						},
						splitLine: {
							show: false,
						},
						// data: that.chartday,
					},
					yAxis: {
						show: true,
						axisLine: {
							show: false,
						},
						axisTick: {
							show: false,
						},
						axisLabel: {
							show: true,
							color: '#ccc',
							fontSize: 11,
							formatter: function(value) {
								// 保留两位小数,没有小数时显示00
								return value / 1000 + 'khz'
							},
						},
						splitLine: {
							show: true, // 显示X轴网格线
							lineStyle: {
								type: 'dashed', // 设置网格线为虚线
								color: '#ccc', // 可以设置虚线的颜色
								width: 1 // 可以设置虚线的宽度
							}
						}
					},
					visualMap: {
						type: 'piecewise',
						show: false,
						dimension: 0,
						seriesIndex: 0,
						pieces: [{
								gt: 1,
								lt: 3,
								color: 'RGBA(255, 241, 201, 1)',
							},
							{
								gt: 5,
								lt: 7,
								color: 'RGBA(255, 241, 201, 1)',
							},
						],
					},
					series: [{
						type: 'line',
						smooth: 0.6,
						symbol: 'none',
						lineStyle: {
							color: '#FFE28C',
							width: 1,
						},
						areaStyle: {
							normal: {
								color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
									offset: 0,
									color: '#FFF1C9'
								}, ]),
							},
						},
						data: that.chartData5,
					}],
				};
				chart = echarts.init(canvas, null, {
					width: width,
					height: height,
					devicePixelRatio: canvasDpr
				})
				option.series[0].data = that.chartData5
				canvas.setChart(chart)
				chart.setOption(option)
				return chart
			},
			// 二氧化碳
			initChart6(canvas, width, height, canvasDpr) {
				let that = this
				const option = {
					grid: {
						left: '4%',
						right: '4%',
						bottom: '3%',
						top: '4%',
						containLabel: true
					},
					xAxis: {
						show: true,
						type: 'category',
						boundaryGap: false,
						axisLine: {
							show: false // 隐藏X轴线
						},
						axisTick: {
							show: false // 隐藏X轴刻度
						},
						axisLabel: {
							show: false // 隐藏X轴标签
						},
						axisLabel: {
							show: true,
							color: '#ccc',
							fontSize: 11,
							rotate: 0,
						},
						splitLine: {
							show: false,
						},
						// data: that.chartday,
					},
					yAxis: {
						show: true,
						axisLine: {
							show: false,
						},
						axisTick: {
							show: false,
						},
						axisLabel: {
							show: true,
							color: '#ccc',
							fontSize: 11,
							formatter: function(value) {
								// 保留两位小数,没有小数时显示00
								return value + '%'
							},
						},
						splitLine: {
							show: true, // 显示X轴网格线
							lineStyle: {
								type: 'dashed', // 设置网格线为虚线
								color: '#ccc', // 可以设置虚线的颜色
								width: 1 // 可以设置虚线的宽度
							}
						}
					},
					visualMap: {
						type: 'piecewise',
						show: false,
						dimension: 0,
						seriesIndex: 0,
						pieces: [{
								gt: 1,
								lt: 3,
								color: 'RGBA(255, 241, 201, 1)',
							},
							{
								gt: 5,
								lt: 7,
								color: 'RGBA(255, 241, 201, 1)',
							},
						],
					},
					series: [{
						type: 'line',
						smooth: 0.6,
						symbol: 'none',
						lineStyle: {
							color: '#FFE28C',
							width: 1,
						},
						areaStyle: {
							normal: {
								color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
									offset: 0,
									color: '#FFF1C9'
								}, ]),
							},
						},
						data: that.chartData6,
					}],
				};
				chart = echarts.init(canvas, null, {
					width: width,
					height: height,
					devicePixelRatio: canvasDpr
				})
				option.series[0].data = that.chartData6
				canvas.setChart(chart)
				chart.setOption(option)
				return chart
			},
			initChart7(canvas, width, height, canvasDpr) {
				let that = this
				const option = {
					grid: {
						left: '4%',
						right: '4%',
						bottom: '3%',
						top: '0%',
						containLabel: true
					},
					tooltip: {
						trigger: 'axis'
					},
					xAxis: {
						type: 'category',
						boundaryGap: false,
						data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
						axisLine: {
							show: false // 隐藏X轴线
						},
						axisTick: {
							show: false // 隐藏X轴刻度
						},
						axisLabel: {
							show: false // 隐藏X轴标签
						},
						splitLine: {
							show: true, // 显示X轴网格线
							lineStyle: {
								type: 'dashed', // 设置网格线为虚线
								color: '#ccc', // 可以设置虚线的颜色
								width: 1 // 可以设置虚线的宽度
							}
						}
					},
					yAxis: {
						type: 'value',
						max: 40, // 设置Y轴的最大值为40
						axisLabel: {
							show: false // 隐藏Y轴标签
						},
						axisLine: {
							show: false // 隐藏Y轴线
						},
						axisTick: {
							show: false // 隐藏Y轴刻度
						},
						splitLine: {
							show: false // 隐藏Y轴背景网格线
						}
					},
					dataZoom: [{
							show: true,
							type: 'inside',
							filterMode: 'none',
							xAxisIndex: [0],
							startValue: -20,
							endValue: 20
						},
						{
							show: true,
							type: 'inside',
							filterMode: 'none',
							yAxisIndex: [0],
							startValue: -20,
							endValue: 20
						}
					],
					series: [{
							name: '最高温度',
							type: 'line',
							data: this.chartData8,
							smooth: true,
							symbol: 'circle',
							symbolSize: 8,
							lineStyle: {
								width: 3
							},
							itemStyle: {
								color: '#42A5F5'
							},
							label: {
								show: true,
								position: 'top',
								formatter: '{c}°',
								color: '#42A5F5'
							},
							markLine: {
								silent: true, // 不响应鼠标事件
								symbol: ['none', 'none'], // 不显示标记
								lineStyle: {
									color: 'red', // 使虚线更明显
									type: 'dashed'
								},
								// data: [
								//     { yAxis: 'min' },
								//     { yAxis: 'max' }
								// ]
							},
						},
						{
							name: '最低温蒂',
							type: 'line',
							data: this.chartData7,
							smooth: true,
							symbol: 'circle',
							symbolSize: 8,
							lineStyle: {
								width: 3
							},
							itemStyle: {
								color: '#42A5F5'
							},
							label: {
								show: true,
								position: 'bottom',
								formatter: '{c}°',
								color: '#42A5F5'
							},
						}
					]
				}
				chart = echarts.init(canvas, null, {
					width: width,
					height: height,
					devicePixelRatio: canvasDpr
				})
				// option.series[0].data = that.chartData7
				canvas.setChart(chart)
				chart.setOption(option)
				return chart
			},
		}
	}
</script>

<style lang="scss">
	#active{
        color: red !important;		
	}
	.mask {
		width: 100%;
		height: 100vh;
		position: fixed;
		top: 0;
		left: 0;
		background-color: #3D3D3D;
		opacity: .6;
	}
	page {
		background-color: #FAFDFD;
	}
	.page {
		padding: 38rpx;
		padding-bottom: 200rpx;
		width: 750rpx;
		.weather_info {
			position: fixed;
			padding: 30rpx 50rpx;
			bottom: 0;
			right: 0;
			width: 750rpx;
			height: 820rpx;
			background: #FFFFFF;
			z-index: 999 !important;
			border-radius: 20rpx 20rpx 0rpx 0rpx;
			.echarts_box {
				margin-top: 24rpx;
				width: 646rpx;
				height: 344rpx;
			}
			.weather_cont {
				margin-top: 42rpx;
				width: 100%;
				display: flex;
				flex-wrap: nowrap;
				align-items: center;
				justify-content: space-between;
				.weather_li {
					.data {
						text-align: center;
						width: 72rpx;
						font-weight: 400;
						font-size: 24rpx;
						color: #50565A;
					}
					.week {
						margin-top: 4rpx;
						text-align: center;
						width: 72rpx;
						font-weight: 600;
						font-size: 24rpx;
						color: #50565A;
					}
					.week_weather {
						margin-top: 14rpx;
						text-align: center;
						width: 82rpx;
						font-weight: 500;
						font-size: 28rpx;
						color: #50565A;
					}
					.week_weather_img {
						margin-top: 4rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						width: 72rpx;
						image {
							width: 48rpx;
							height: 48rpx;
						}
					}
				}
			}
			.top {
				display: flex;
				flex-wrap: nowrap;
				justify-content: space-between;
				align-items: center;
				.weather_info_tit {
					font-weight: 600;
					font-size: 36rpx;
					color: #3D3D3D;
				}
				image {
					width: 42rpx;
					height: 42rpx;
				}
				.weather_add {
					font-weight: 600;
					font-size: 32rpx;
					color: #50565A;
				}
				.up_time {
					font-weight: 400;
					font-size: 32rpx;
					color: #808080;
				}
			}
		}
		.echarts_box {
			margin-top: 26rpx;
			padding: 18rpx 24rpx;
			width: 674rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0, 0, 0, 0.15);
			border-radius: 28rpx 28rpx 28rpx 28rpx;
			.echarts {
				margin-top: 24rpx;
				width: 100%;
				height: 330rpx;
			}
			.echarts_top {
				display: flex;
				align-items: center;
				.top_left {
					width: 33.33%;
					display: flex;
					align-items: center;
					font-weight: 500;
					font-size: 36rpx;
					color: #3D3D3D;
					image {
						margin-left: 10rpx;
						width: 25.03rpx;
						height: 34rpx;
					}
				}
				.top_cont {
					width: 33.33%;
					text-align: center;
					font-weight: 600;
					font-size: 36rpx;
					color: #3D3D3D;
				}
				.top_right {
					width: 33.33%;
					display: flex;
					align-items: center;
					.txt {
						display: flex;
						align-items: center;
						flex-wrap: nowrap;
						margin-left: auto;
						font-weight: 400;
						font-size: 32rpx;
						color: #4D4D4D;
						.icon-xiangyou1 {
							margin-top: 4rpx;
							margin-left: 8rpx;
						}
					}
				}
			}
		}
		.bottom_box {
			padding: 38rpx 20rpx;
			position: fixed;
			display: flex;
			align-items: center;
			justify-content: space-around;
			width: 750rpx;
			height: 142rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0, 0, 0, 0.15);
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			bottom: 0;
			left: 0;
			.type_li {
				padding: 12rpx 26rpx;
				background: #FFF5D6;
				border-radius: 12rpx 12rpx 12rpx 12rpx;
				border: 2rpx solid #FFC107;
				font-weight: 600;
				font-size: 32rpx;
				color: #3D3D3D;
			}
			.act1 {
				background: #FFC107;
				border-radius: 12rpx 12rpx 12rpx 12rpx;
				border: 2rpx solid #FFC107;
				color: #FFFFFF;
			}
		}
		.card_top {
			margin-top: 28rpx;
			display: flex;
			flex-wrap: nowrap;
			align-items: center;
			.name {
				font-weight: 600;
				font-size: 36rpx;
				color: #3D3D3D;
			}
			.time {
				margin-left: 18rpx;
				font-weight: 400;
				font-size: 28rpx;
				color: #808080;
			}
			.ele {
				margin-left: auto;
				display: flex;
				align-items: center;
				flex-wrap: nowrap;
				font-weight: 400;
				font-size: 28rpx;
				color: #808080;
				image {
					margin-right: 12rpx;
					width: 46rpx;
					height: 46rpx;
				}
			}
		}
		.setbox {
			margin: 0 auto;
			margin-top: 34rpx;
			width: 674rpx;
			display: flex;
			flex-wrap: nowrap;
			justify-content: space-between;
			.setcard {
				position: relative;
				padding: 14rpx 22rpx;
				width: 320rpx;
				height: 132rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0, 0, 0, 0.15);
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				.top {
					display: flex;
					flex-wrap: nowrap;
					align-items: center;
					justify-content: space-between;
					.left {
						font-weight: 600;
						font-size: 28rpx;
						color: #3D3D3D;
					}
					.right {
						font-size: 24rpx;
						color: #808080;
					}
				}
				.bot {
					margin-top: 14rpx;
					font-weight: 400;
					font-size: 24rpx;
					color: #808080;
				}
				.img {
					position: absolute;
					right: 24rpx;
					bottom: 24rpx;
					width: 82rpx;
					height: 82rpx;
					image {
						width: 82rpx;
						height: 82rpx;
					}
				}
			}
		}
		.weather {
			margin-top: 12rpx;
			display: flex;
			flex-wrap: nowrap;
			align-items: center;
			justify-content: space-between;
			.weather_left {
				display: flex;
				flex-wrap: nowrap;
				align-items: center;
				.txt {
					display: flex;
					flex-wrap: nowrap;
					align-items: center;
					image {
						width: 38rpx;
						height: 38rpx;
						margin-right: 8rpx;
					}
					font-weight: 400;
					font-size: 28rpx;
					color: #3D3D3D;
				}
			}
			.weather_right {
				display: flex;
				flex-wrap: nowrap;
				align-items: center;
				font-weight: 400;
				font-size: 28rpx;
				color: #42A5F5;
				.icon-xiangyou1 {}
			}
		}
		.address {
			display: flex;
			align-items: center;
			margin-top: 8rpx;
			image {
				margin-right: 8rpx;
				width: 20rpx;
				height: 24rpx;
			}
			font-weight: 400;
			font-size: 28rpx;
			color: #808080;
		}
		.tit {
			display: flex;
			flex-wrap: nowrap;
			align-items: center;
			justify-content: space-between;
			margin-top: 24rpx;
			font-weight: 600;
			font-size: 32rpx;
			color: #3D3D3D;
			.sets {
				position: relative;
				display: flex;
				align-items: center;
				.tongbu{
					width: 130rpx;
					height: 40rpx;
					border-radius: 4rpx;
					text-align: center;
					line-height: 40rpx;
					font-size: 28rpx;
					color: #fff;
					background-color: #FFC107;
					margin-right: 20rpx;
				}
				.menu {
					padding: 20rpx;
					position: absolute;
					right: 20rpx;
					width: 218rpx;
					height: 234rpx;
					background: #FFFFFF;
					box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0, 0, 0, 0.15);
					border-radius: 20rpx 20rpx 20rpx 20rpx;
					z-index: 10;
					.menu_li:first-child {
						margin-top: 10rpx;
					}
					.menu_li {
						image {
							margin-right: 14rpx;
							width: 38rpx;
							height: 38rpx;
						}
						font-weight: 400;
						font-size: 32rpx;
						color: #3D3D3D;
						margin-top: 26rpx;
						display: flex;
						flex-wrap: nowrap;
						align-items: center;
					}
				}
				image {
					width: 36rpx;
					height: 36rpx;
				}
			}
		}
		.mapbox {
			position: relative;
			margin: 0 auto;
			margin-top: 34rpx;
			width: 674rpx;
			height: 372rpx;
			border-radius: 20rpx;
			overflow: hidden;
			.fxmask {
				position: absolute;
				top: 0;
				left: 0;
				width: 100%;
				height: 100%;
				background-color: #3D3D3D;
				opacity: .5;
				z-index: 99;
				color: #fff;
				padding-left: 10rpx;
				font-size: 36rpx;
				padding-top: 288rpx;
				box-sizing: border-box;
				font-weight: 600;
			}
			.num {
				width: 180rpx;
				position: absolute;
				top: 24rpx;
				left: 30rpx;
				.txt {
					width: 180rpx;
					font-weight: 600;
					font-size: 32rpx;
					color: #FFC107;
				}
			}
			.btn {
				position: absolute;
				right: 0rpx;
				bottom: 0rpx;
				image {
					width: 90rpx;
					height: 90rpx;
				}
			}
			.map {
				width: 672rpx;
				height: 372rpx;
			}
		}
	}
</style>