SmartBeehive/page_adoptBee/adopxq.vue

2109 lines
48 KiB
Vue
Raw Normal View History

2024-10-10 17:03:59 +08:00
<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>
2024-11-21 17:41:44 +08:00
</view>
2024-10-10 17:03:59 +08:00
<view class="tit">
{{obj.name == undefined ? '--' : obj.name}}-{{obj.sn == undefined ? '--' : obj.sn}}
<view class="sets">
<!-- <image @click="btnmenu" src="https://api.ccttiot.com/smartmeter/img/static/ulHBKvkXDfe9OIveIJKZ" 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">
<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>
<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">
当前 {{obj.innerTemperature == undefined ? '--' : obj.innerTemperature}}
</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">
当前 {{obj.innerHumidity}}%
</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">
当前 {{obj.totalWeight == 999999 ? '--' : (obj.totalWeight / 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">
当前 {{obj.ioCountDay}}
</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">
当前 {{obj.volume / 1000 == 0 ? obj.volume : (obj.volume / 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">
当前 {{obj.innerCo2}}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}}</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 class="week_weather_img">
<image src="https://api.ccttiot.com/smartmeter/img/static/u6wWpgZOuId6JSX8LGmz" mode=""></image>
</view> -->
</view>
</view>
<!-- <view class="xqtq" style="color: #42A5F5;" @click="btntqxq">
天气详情
</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" @click="btndow(3)">
风扇{{fskx}}
</view>
<view class="type_li" @click="btndow(4)">
加热{{jrkg}}
</view>
</view>
<view class="mask" v-if="showtq"></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 {
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,
}
},
onLoad(option) {
this.beehiveId = option.beehiveId
},
onShow() {
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()
// 每次进入执行定时器
this.startTimer()
},
onUnload() {
// 页面即将销毁时销毁定时器
this.clearTimer()
},
methods: {
// 跳转天气
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
})
},
2024-11-18 18:01:16 +08:00
// 如果设备未ios机型 则跳转最新数中
2024-10-10 17:03:59 +08:00
btnvideo() {
uni.navigateTo({
url: '/page_Beehive/Beehive_log?apiaryId=' + this.obj.apiaryId + ' &name=' + this.obj
.apiaryName
})
},
btngd() {
// this.gettq()
setTimeout(() => {
this.$refs.canvas7.init(this.initChart7)
}, 200);
this.showtq = true
},
btnyj() {
uni.navigateTo({
url: '/page_Beehive/Beehive_woring?apiaryId=' + this.beehiveId + '&tit=' + '蜂箱预警记录'
})
},
btnedit() {
this.menuflag = false
uni.navigateTo({
url: '/page_Beehive/add_Beehive?tit=' + '修改蜂箱' + '&beehiveId=' + this.beehiveId
})
},
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)
}
})
},
2024-11-18 18:01:16 +08:00
// 操作蜂箱进行去皮等操作
2024-10-10 17:03:59 +08:00
btndow(num) {
if (num == 1) {
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) {
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 == '关') {
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 {
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 == '关') {
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 {
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
})
}
})
}
}
},
getobj() {
2024-11-18 18:01:16 +08:00
this.$u.get(`/app/beehive/${this.beehiveId}`).then(res => {
2024-10-10 17:03:59 +08:00
if (res.code == 200) {
this.obj = res.data
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 = '开'
}
if (res.data.lat == 0 && res.data.lng == 0) {
this.latitude = 39.56
this.longitude = 116.20
this.zoomSize = 1
this.dtflag = true
} else {
this.dtflag = false
this.covers.push({
id: parseFloat(res.data.beehiveId),
latitude: res.data.lat,
longitude: res.data.lng,
width: 25,
height: 30,
iconPath: 'https://api.ccttiot.com/smartmeter/img/static/ukbyhyrDcp3VzgyeJo2G',
})
}
this.gettq()
} else {
uni.showToast({
title: res.msg,
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: 4,
},
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: 4,
},
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: 4,
},
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: 4,
},
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: 4,
},
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: 4,
},
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">
.mask {
width: 100%;
height: 100vh;
position: fixed;
top: 0;
left: 0;
background-color: #3D3D3D;
opacity: .6;
}
page {
background-color: #FAFDFD;
}
.page {
// position: relative;
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: 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;
}
}
}
.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: 80%;
width: 100%;
height: 330rpx;
}
.echarts_top {
display: flex;
align-items: center;
// justify-content: space-between;
.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 {
// margin-top: 26rpx;
// margin-right: 18rpx;
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;
.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;
// text-align: center;
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;
// width: 70rpx;
// height: 70rpx;
image {
width: 90rpx;
height: 90rpx;
}
}
.map {
width: 672rpx;
height: 372rpx;
// border-radius:20rpx;
}
}
}
</style>