<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="tipbox">
			<view class="tip_cont">
				<image src="https://api.ccttiot.com/smartmeter/img/static/uwO70CUV98b3maj6bfCF" mode=""></image>
				<view class="txt">
					{{listfz}}
				</view>
			</view>
			<view class="tip_cont" style="margin-top: 28rpx;">
				<image src="https://api.ccttiot.com/smartmeter/img/static/uQQym033Pvs3rirm9kP5" mode=""></image>
				<view class="txt">
					{{listmy}}
				</view>
			</view>
			<view class="tip_cont" style="margin-top: 28rpx;">
				<image src="https://api.ccttiot.com/smartmeter/img/static/u9wAWh1AIzSDGgKDKsKY" mode=""></image>
				<view class="txt">
					{{daily[0].tempMax == undefined ? '--' : daily[0].tempMax}} ℃
				</view>
			</view>
			<view class="tip_cont" style="margin-top: 28rpx;">
				<image src="https://api.ccttiot.com/smartmeter/img/static/uBIctX6qJ9yMtAZYuY0R" mode=""></image>
				<view class="txt">
					{{daily[0].humidity == undefined ? '--' : daily[0].humidity}} %
				</view>
			</view>
			<image @click="btnedfc" style="width: 44rpx;height: 44rpx;position: absolute;top: 224rpx;right:36rpx;"
				src="https://api.ccttiot.com/smartmeter/img/static/ulHBKvkXDfe9OIveIJKZ" mode=""></image>
		</view>
		<view class="info_box">
			<view class="cont_img" style="margin-top: 25rpx;" @click="showtqs()">
				<image src="https://api.ccttiot.com/smartmeter/img/static/uuDdvHXyO9xuWd3DqCLU" mode=""></image>

			</view>
			<view class="cont_img" style="margin-top: 15rpx;" @click="btnpage">
				<image src="https://api.ccttiot.com/smartmeter/img/static/urhdebIu3K8vqRb8leoH" mode=""></image>
			</view>
			<view class="cont_img" style="margin-top: 15rpx;" @click="btnyj">
				<image src="https://api.ccttiot.com/smartmeter/img/static/uTcBaMpmiZwS63GPCMBZ" mode=""></image>
				<view class="tip">
					{{apiaryobj.unReadWarnCount == undefined ? 0 : apiaryobj.unReadWarnCount}}
				</view>
			</view>
			<view class="cont_img" style="margin-top: 25rpx;" @click="btncaozuo">
				<image src="https://api.ccttiot.com/smartmeter/img/static/uZVc2GgYQoUmn6aJwVeR" mode=""></image>
			</view>
		</view>
		<view class="tit">
			具体位置
		</view>
		<view class="mapbox">
			<map class="map" id="map" ref="map" :scale="zoomSize" :latitude="latitude" :longitude="longitude"
				:show-location='true' :polygons="polygons" :markers="covers"> </map>
			<view class="num">
				<view class="txt">
					在线:{{apiaryobj.onlineBeehiveCount == undefined ? '--' : apiaryobj.onlineBeehiveCount}}
				</view>
				<view class="txt" style="color:#FF473E ;margin-top: 10rpx;">
					离线:{{apiaryobj.offlineBeehiveCount == undefined ? '--' : apiaryobj.offlineBeehiveCount}}
				</view>
			</view>
			<view class="btn" @click="showwl = true">
				<image src="https://api.ccttiot.com/smartmeter/img/static/uaGU0mFvFqbgAxAsFlUP" mode=""></image>
			</view>
		</view>
		<view class="tit">
			设置
		</view>
		<view class="setbox">
			<view class="setcard" @click="btnship">
				<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/ukN0K37DEPQQxFJ03Qi9" mode=""></image>
				</view>
			</view>
			<view class="setcard" @click="btnpageyj">
				<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>
		
		<view class="tit">
			蜂场变化
		</view>
		<view class="swiper-item" @click="btntu">
			<view class="card_box">
				<view class="card">
					<view class="card_top">
						<view class="top_left">
							<image src="https://api.ccttiot.com/smartmeter/img/static/uk7CvwzeU0ukxvS9cBtD"
								mode=""></image>
							近7天蜂箱总重量变化
						</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>
		</view>
		<view class="swiper-item" @click="btntu">
			<view class="card_box">
				<view class="card">
					<view class="card_top">
						<view class="top_left">
							<image src="https://api.ccttiot.com/smartmeter/img/static/uhsU6Y1K35jxA4aRauzy" mode=""></image>
							近7天蜜蜂总出勤变化
						</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>
		</view>
		
		
		
		
		<u-mask :show="showtq" @click="showtq = false" :z-index='100' duration='0' />


		<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;">{{apiaryobj.county}}</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>
		
		<u-mask :show="showwl" @click="showwl = false" :z-index='100' duration='0' />
		<view class="pops" v-if='showwl'>
			<image class="bgimg" src="https://api.ccttiot.com/smartmeter/img/static/uImWgTlNYBAv4SO02gSL" mode="">
			</image>
			<view class="tit">
				电子围栏(km)
			</view>
			<view class="cont">
				最大距离 <view class="ipt"><input type="text" class="ips" v-model="dzcode" placeholder=" "
						placeholder-class="my-placeholder" /></view>
			</view>
			<view class="btn" @click="btnqued">
				确定
			</view>
		</view>
	</view>
</template>

<script>
	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 {
				ec: {
					lazyLoad: true
				},
				bgc: {
					backgroundColor: " #F4FAF8",
				},
				title: "蜂场详情",
				latitude: '',
				longitude: '',
				isMap: false,
				zoomSize: 13,
				markers: [],
				showtq: false,
				showwl: false,
				apiaryId: '',
				apiaryobj: {},
				listmy: '',
				listfz: '',
				daily: [],
				chartData7: [],
				chartData8: [],
				daytime: '',
				covers: [],
				dzcode:'',
				polygons: [{
					points: [],
					fillColor:'#cbdde954',
					strokeColor: "#78addd",
					strokeWidth: 1,
					zIndex: 1,
				}],
				yeartime: {
					year: '',
					month: '',
					day: ''
				},
				yeartimes: {
					year: '',
					month: '',
					day: ''
				},
				chartData3: [],
				chartData4: [],
			}
		},
		onLoad(option) {
			this.apiaryId = option.id
			setTimeout(() => {
				this.$refs.canvas7.init(this.initChart7)
				this.$refs.canvas3.init(this.initChart3)
				this.$refs.canvas4.init(this.initChart4)
			}, 1000)			
		},
		onShow() {
			this.getfcxq()
			this.getMyLocation()
            const now = new Date();
            const 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.getchartData3()
			this.getchartData4()
		},
		methods: {
			btntu(){
				uni.navigateTo({
					url:'/page_user/fengchangxq?beehiveId=' + this.apiaryId
				})
			},
			// 重量图表
			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}&apiaryId=${this.apiaryId}`).then(res => {
					if (res.code == 200) {
						this.chartData3 = res.data.map(item => item.value)
						this.$refs.canvas3.init(this.initChart3)
					}
				})
			},
			// 出勤图表
			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}&apiaryId=${this.apiaryId}`).then(res => {
					if (res.code == 200) {
						this.chartData4 = res.data.map(item => item.value)
						this.$refs.canvas4.init(this.initChart4)
					}
				})
			},
			// 跳转预警设置
			btnpageyj(){
				uni.navigateTo({
					url:'/pages/Apiary/early_Set ?apiaryId=' + this.apiaryId 
				})
			},
			//跳转视频监控 
			btnship(){
				uni.navigateTo({
					url:'/pages/Apiary/Apiary_vadio/Apiary_vadio?apiaryId=' + this.apiaryId
				})
			},
			// 跳转预警记录
			btnyj(){
				uni.navigateTo({
					url:'/page_Beehive/Beehive_woring?apiaryId=' + this.apiaryId + '&tit=' + '蜂场预警记录'
				})
			},
			
			// 请求指定蜂场蜂箱
			getMyLocation() {
				uni.getLocation({
					type: 'wgs84',
					success: (res) => {
						// this.latitude = Number(res.latitude.toFixed(5)) - 0.004
						// this.longitude = Number(res.longitude.toFixed(5)) + 0.004
						this.$u.get(`/farm/beehive/listByApiary/${this.apiaryId}`).then(
							res => {
								if (res.code == 200) {
									res.data.forEach(item => {
										this.covers.push({
											id: Number(item.storeId),
											latitude: item.lat,
											longitude: item.lng,
											width: 20,
											height: 20,
											iconPath: 'https://api.ccttiot.com/smartmeter/img/static/ukbyhyrDcp3VzgyeJo2G',
										})
									})
								}
							})
					},
					fail: (err) => {
						console.error('获取位置失败:', err)
					}
				});
			},
            
			// 点击确定电子围栏
			btnqued(){
				let data = {
					apiaryId:this.apiaryId,
					radius:this.dzcode
				}
				this.$u.put(`farm/apiary`,data).then(res =>{
					if(res.code == 200){
						uni.showToast({
							title: '修改成功',
							icon: 'none',
							duration: 2000
						})
						this.showwl = false
						this.getfcxq()
					}else{
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						})
					}
				})
			},

			btnedfc() {
				uni.navigateTo({
					url: '/pages/Apiary/Apiary_edit/Apiary_edit?apiaryId=' + this.apiaryId
				})
			},
			btncaozuo() {
				uni.navigateTo({
					url: '/page_Beehive/Beehive_log?apiaryId=' + this.apiaryId + '&name=' + this.apiaryobj.name
				})
			},
			btnpage() {
				uni.switchTab({
					url: '/pages/Beehive?apiaryId=' + this.apiaryId
				})
			},
			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}`
			},
			getfcxq() {
				this.$u.get(`/farm/apiary/${this.apiaryId}`).then(res => {
					if (res.code == 200) {
						this.apiaryobj = res.data
						this.latitude = res.data.lat
						this.longitude = res.data.lng
						this.covers.push({
							id: Number(res.data.apiaryId),
							latitude: res.data.lat,
							longitude: res.data.lng,
							width: 25,
							height: 30,
							iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uYrX2QTRLdVVDTB3E5cp',
						})
						this.polygons[0].points = []
						let centerLat = res.data.lat
						let centerLon = res.data.lng
						let radius = res.data.radius
						let circlePoints = this.calculateCirclePoints(centerLat, centerLon, radius)
						this.polygons[0].points = circlePoints

						this.gettq()
						this.getmy()
						this.getfz()
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						})
					}
				})
			},
			// 计算电子围栏
			calculateCirclePoints(lat, lon, radiusInKm, numPoints = 36) {
				let earthRadiusKm = 6371
				let radius = radiusInKm / earthRadiusKm 
				let points = []
				for (let i = 0; i < numPoints; i++) {
					let angle = (i / (numPoints - 1)) * 2 * Math.PI 
					let latRad = lat * Math.PI / 180 
					let lonRad = lon * Math.PI / 180 
					let newLatRad = Math.asin(Math.sin(latRad) * Math.cos(radius) +
						Math.cos(latRad) * Math.sin(radius) * Math.cos(angle))
					let newLonRad = lonRad + Math.atan2(
						Math.sin(angle) * Math.sin(radius) * Math.cos(latRad),
						Math.cos(radius) - Math.sin(latRad) * Math.sin(newLatRad)
					)
					let newLat = newLatRad * 180 / Math.PI
					let newLon = (newLonRad + 3 * Math.PI) % (2 * Math.PI) - Math.PI
					newLon = newLon * 180 / Math.PI
					points.push({
						latitude: newLat,
						longitude: newLon
					})
				}
				return points
			},
			getmy() {
				this.$u.get(`/common/getDictByType?dictType=apiary_honey_type`).then(res => {
					if (res.code == 200) {
						for (let i = 0; i < res.data.length; i++) {
							if (res.data[i].dictValue == this.apiaryobj.honeyType) {
								this.listmy = res.data[i].dictLabel
							}
						}
					}
				})
			},
			getfz() {
				this.$u.get(`/common/getDictByType?dictType=apiary_bee_type`).then(res => {
					if (res.code == 200) {
						for (let i = 0; i < res.data.length; i++) {
							if (res.data[i].dictValue == this.apiaryobj.beeType) {
								this.listfz = res.data[i].dictLabel
							}
						}
					}
				})
			},


			showtqs() {
				setTimeout(() => {
					this.$refs.canvas7.init(this.initChart7)
				}, 200);
				this.showtq = true
			},
			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
				})


				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
			},
			//重量
			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
			},

		}
	}
</script>

<style lang="scss">
	page {
		background-color: #FAFDFD;
		background-image: url('https://api.ccttiot.com/smartmeter/img/static/uzH4CBTO95bjOrhGDpAe');
		background-size: cover;
		/* 确保背景图覆盖整个区域 */
		background-repeat: no-repeat;
		/* 防止背景图重复 */
		background-position: center;
	}

	.page {
		position: relative;
		width: 750rpx;
         .swiper-item {
         	display: flex;
         	justify-content: center;
         	transition: height 0.3s ease-in-out;
            margin-top: 34rpx;
         	&.active {
         		height: 500rpx; // 激活状态的高度
         	}
         
         	&:not(.active) {
         		height: 426rpx; // 非激活状态的高度
         	}
         
         	.card_box {
         		display: flex;
         		flex-wrap: wrap;
         
         		.card {
         			padding: 18rpx;
         			width: 638rpx;
         			height: 426rpx;
         			background: #FFFFFF;
         			box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0, 0, 0, 0.15);
         			border-radius: 28rpx 28rpx 28rpx 28rpx;
         
         			.card_top {
         				display: flex;
         				align-items: center;
         
         				.top_left {
         
         					display: flex;
         					align-items: center;
         					font-weight: 400;
         					font-size: 36rpx;
         					color: #3D3D3D;
         
         					image {
         						margin-right: 24rpx;
         						margin-left: 28rpx;
         						width: 40rpx;
         						height: 45rpx;
         					}
         				}
         
         				.top_cont {
         					width: 33.33%;
         					text-align: center;
         					font-weight: 600;
         					font-size: 36rpx;
         					color: #3D3D3D;
         				}
         
         				.top_right {
         					margin-left: auto;
         					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;
         						}
         					}
         				}
         			}
         
         			.echarts {
         
         				margin-top: 24rpx;
         				width: 100%;
         				// height: 80%;
         
         				height: 344rpx;
         			}
         		}
         
         	}
         }
		.pops {
			position: fixed;
			left: 98rpx;
			top: 400rpx;
			z-index: 101;
			width: 554rpx;
			height: 420rpx;
			background: #FFFFFF;
			border-radius: 30rpx 30rpx 30rpx 30rpx;

			.bgimg {
				z-index: -1;
				position: absolute;
				top: 12rpx;
				right: 16rpx;
				width: 210rpx;
				height: 172rpx;
			}

			.tit {
				width: 100%;
				text-align: center;
				margin: 40rpx auto 0;
				font-weight: 600;
				font-size: 36rpx;
				color: #3D3D3D;
			}

			.cont {
				display: flex;
				align-items: center;
				justify-content: center;
				flex-wrap: nowrap;
				margin-top: 42rpx;
				width: 100%;

				font-weight: 400;
				font-size: 28rpx;
				color: #3D3D3D;

				.ipt {
					margin-left: 18rpx;
					width: 178rpx;
					height: 76rpx;
					border-radius: 10rpx 10rpx 10rpx 10rpx;
					border: 2rpx solid #808080;

					.ips {
						padding: 14rpx;
					}

					.my-placeholder {
						font-weight: 400;
						font-size: 32rpx;
						color: #808080;
					}
				}

			}

			.btn {
				display: flex;
				align-items: center;
				justify-content: center;
				margin-top: 60rpx;
				margin-left: 74rpx;
				width: 406rpx;
				height: 90rpx;
				background: #FFC107;
				border-radius: 54rpx 54rpx 54rpx 54rpx;

				font-weight: 500;
				font-size: 40rpx;
				color: #FFFFFF;
			}
		}

		.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: 100%;
				// height: 80%;
				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;
				}
			}
		}

		.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;

					}
				}
			}
		}

		.tit {
			margin-top: 40rpx;
			margin-left: 38rpx;
			font-weight: 600;
			font-size: 32rpx;
			color: #3D3D3D;
		}

		.mapbox {
			position: relative;
			margin: 0 auto;
			margin-top: 34rpx;
			width: 674rpx;
			height: 372rpx;
			border-radius: 20rpx;
			overflow: hidden;

			.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;

				// width: 70rpx;
				// height: 70rpx;
				image {
					width: 90rpx;
					height: 90rpx;
				}
			}

			.map {
				width: 672rpx;
				height: 372rpx;
				// border-radius:20rpx;
			}
		}

		.info_box {
			padding-left: 40rpx;
			margin: 138rpx auto 0;
			display: flex;
			flex-wrap: nowrap;
			width: 680rpx;
			height: 184rpx;

			.cont_img {
				position: relative;
				margin-right: 50rpx;

				image {

					width: 112rpx;
					height: 124rpx;
				}

				.tip {
					position: absolute;
					right: 0;
					top: 6rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					border-radius: 50%;
					background: #FF473E;
					width: 32rpx;
					height: 32rpx;
					font-weight: 500;
					font-size: 24rpx;
					color: #FAFDFD;

				}
			}
		}

		.tipbox {
			width: 300rpx;
			display: flex;
			flex-wrap: wrap;
			// position: relative;
			margin-top: 42rpx;
			margin-left: 38rpx;

			.tip_cont {
				display: flex;
				flex-wrap: nowrap;
				align-items: center;

				image {
					margin-right: 6rpx;
					width: 38rpx;
					height: 38rpx;
				}

				// display: inline-flexbox;
				flex-wrap: nowrap;
				padding: 8rpx 22rpx;
				background: rgba(61, 61, 61, 0.5);
				box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0, 0, 0, 0.15);
				border-radius: 20rpx 20rpx 20rpx 20rpx;

				font-weight: 500;
				font-size: 32rpx;
				color: #FAFDFD;

			}
		}




	}
</style>