From e40f4ad0f419c2fcf1ce93ad08bfb5c9d7a984bb Mon Sep 17 00:00:00 2001 From: "3321822538@qq.com" <3321822538@qq.com> Date: Mon, 1 Jul 2024 18:03:05 +0800 Subject: [PATCH] aaa --- common/http.interceptor.js | 2 +- page_Beehive/Beehive_detail.vue | 361 +++++++++++++++++++++++++++----- page_Beehive/add_Beehive.vue | 134 +++++++++--- pages/Apiary.vue | 98 +++++++-- pages/Apiary/AddApiary.vue | 98 ++++++--- pages/Beehive.vue | 137 +++++++++--- pages/index/index.vue | 2 +- 7 files changed, 679 insertions(+), 153 deletions(-) diff --git a/common/http.interceptor.js b/common/http.interceptor.js index c8d9ccf..9855d21 100644 --- a/common/http.interceptor.js +++ b/common/http.interceptor.js @@ -20,7 +20,7 @@ const install = (Vue, vm) => { // }, // }); Vue.prototype.$u.http.setConfig({ - baseUrl: 'http://192.168.2.10:3202', + baseUrl: 'http://192.168.2.17:3202', // baseUrl: '192.168.2.10:3202/app', loadingText: '努力加载中~', loadingTime: 800, diff --git a/page_Beehive/Beehive_detail.vue b/page_Beehive/Beehive_detail.vue index 0a33a61..f0f20e1 100644 --- a/page_Beehive/Beehive_detail.vue +++ b/page_Beehive/Beehive_detail.vue @@ -20,8 +20,8 @@ - 福鼎蜂场-001 - + {{obj.name}}-{{obj.sn}} + @@ -41,15 +41,15 @@ - 福建省宁德市福鼎市太姥山镇秦屿大道2号 + {{obj.apiaryAddress}} - 多云 15℃ ~ 25℃ + 多云 {{daily[0].tempMin}}℃ ~ {{daily[0].tempMax}}℃ - 西南风2级 + {{daily[0].windDirDay}} {{daily[0].windSpeedDay}}级 @@ -60,15 +60,15 @@ - 44% + {{obj.outerHumidity}}% - 23℃ + {{obj.outerTemperature}}℃ - 更新于 2024-05-15 15:22:36 + 更新于 {{obj.lastOnlineTime}} @@ -108,14 +108,14 @@ - 福鼎蜂场-001 + {{obj.name}}-{{obj.sn}} - 05-20 16:31:13 + {{obj.lastOnlineTime}} - 90% + {{obj.surplusPower}}% @@ -125,7 +125,7 @@ - 当前 40℃ + 当前 {{obj.innerTemperature}}℃ @@ -150,7 +150,7 @@ - 当前 38% + 当前 {{obj.innerHumidity}}% @@ -175,7 +175,7 @@ - 当前 55Kg + 当前 {{obj.totalWeight == 999999 ? '--' : obj.totalWeight}}Kg @@ -200,7 +200,7 @@ - 当前 552只 + 当前 {{obj.ioCount}}只 @@ -225,7 +225,7 @@ - 当前 55Hz + 当前 {{obj.volume}} @@ -250,7 +250,7 @@ - 当前 3% + 当前 {{obj.innerCo2}}ppm @@ -277,22 +277,22 @@ - 蜂场位置:福鼎市 + 蜂场位置:{{obj.apiaryCounty}} 1小时前更新 - + - 5/16 + {{item.fxDate.slice(5)}} - 今天 + {{item.textDay}} - 多云 + {{item.windDirDay}} @@ -305,17 +305,17 @@ - + 去皮 - + 蜂鸣寻箱 - - 风扇:关 + + 风扇:{{fskx}} - - 加热:关 + + 加热:{{jrkg}} @@ -355,15 +355,36 @@ }], chartday: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'], chartData: [120, 200, 150, 80, 70, 110, 130], - showtq:true + showtq:true, + beehiveId:'', + obj:{}, + daily:[], + fskx:'关', + jrkg:'关', + chartData1:[], + chartData2:[], + chartData3:[], + chartData4:[], + chartData5:[], + chartData6:[], + yeartime: { + year: '', + month: '', + day:'' + }, + yeartimes: { + year: '', + month: '', + day:'' + }, } }, - onLoad() { - + onLoad(option) { + this.beehiveId = option.beehiveId + this.getobj() }, onShow() { setTimeout(() => { - this.$refs.canvas1.init(this.initChart) this.$refs.canvas2.init(this.initChart2) this.$refs.canvas3.init(this.initChart3) @@ -371,9 +392,254 @@ this.$refs.canvas5.init(this.initChart5) this.$refs.canvas6.init(this.initChart6) this.$refs.canvas7.init(this.initChart7) - }, 200); + }, 1000) + + 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') + + // const now = new Date(); + // 创建一个新的Date对象,表示前一天 + 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() }, methods: { + // 温度图表 + getchartData1(){ + let time = this.yeartime.year +'-' + this.yeartime.month + '-' + this.yeartime.day + let times = this.yeartimes.year + '-' + this.yeartimes.month + '-' + this.yeartimes.day + console.log(this.yeartime,this.yeartimes); + 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){ + 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(){ + this.$u.get(`/farm/beehive/${this.beehiveId}`).then(res => { + if(res.code == 200){ + this.obj = res.data + this.latitude = res.data.apiaryLat + this.longitude = res.data.apiaryLng + if(res.data.enableFan == false){ + this.fskx = '关' + }else{ + this.fskx = '开' + } + if(res.data.enableHeat == false){ + this.jrkg = '关' + }else{ + this.jrkg = '开' + } + + this.gettq() + if(this.latitude == 0 && this.longitude == 0){ + this.zoomSize = 2 + } + }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 + } + }) + }, + + + + // 温度 initChart(canvas, width, height, canvasDpr) { let that = this @@ -469,7 +735,7 @@ }, ]), }, }, - data: that.chartData, + data: that.chartData1, }], }; chart = echarts.init(canvas, null, { @@ -477,8 +743,7 @@ height: height, devicePixelRatio: canvasDpr }) - - + option.series[0].data = that.chartData1 canvas.setChart(chart) chart.setOption(option) return chart @@ -578,7 +843,7 @@ }, ]), }, }, - data: that.chartData, + data: that.chartData2, }], }; chart = echarts.init(canvas, null, { @@ -587,7 +852,7 @@ devicePixelRatio: canvasDpr }) - + option.series[0].data = that.chartData2 canvas.setChart(chart) chart.setOption(option) return chart @@ -687,7 +952,7 @@ }, ]), }, }, - data: that.chartData, + data: that.chartData3, }], }; chart = echarts.init(canvas, null, { @@ -696,7 +961,7 @@ devicePixelRatio: canvasDpr }) - + option.series[0].data = that.chartData3 canvas.setChart(chart) chart.setOption(option) return chart @@ -796,7 +1061,7 @@ }, ]), }, }, - data: that.chartData, + data: that.chartData4, }], }; chart = echarts.init(canvas, null, { @@ -805,7 +1070,7 @@ devicePixelRatio: canvasDpr }) - + option.series[0].data = that.chartData4 canvas.setChart(chart) chart.setOption(option) return chart @@ -905,7 +1170,7 @@ }, ]), }, }, - data: that.chartData, + data: that.chartData5, }], }; chart = echarts.init(canvas, null, { @@ -914,7 +1179,7 @@ devicePixelRatio: canvasDpr }) - + option.series[0].data = that.chartData5 canvas.setChart(chart) chart.setOption(option) return chart @@ -1014,7 +1279,7 @@ }, ]), }, }, - data: that.chartData, + data: that.chartData6, }], }; chart = echarts.init(canvas, null, { @@ -1023,7 +1288,7 @@ devicePixelRatio: canvasDpr }) - + option.series[0].data = that.chartData6 canvas.setChart(chart) chart.setOption(option) return chart @@ -1189,7 +1454,7 @@ width: 750rpx; height: 820rpx; background: #FFFFFF; - z-index: 200; + z-index: 999 !important; border-radius: 20rpx 20rpx 0rpx 0rpx; @@ -1231,7 +1496,7 @@ .week_weather { margin-top: 14rpx; text-align: center; - width: 72rpx; + width: 82rpx; font-weight: 500; font-size: 28rpx; color: #50565A; diff --git a/page_Beehive/add_Beehive.vue b/page_Beehive/add_Beehive.vue index 048292b..82f1ea0 100644 --- a/page_Beehive/add_Beehive.vue +++ b/page_Beehive/add_Beehive.vue @@ -7,26 +7,26 @@ 扫描二维码 - + - - + 自定义蜂箱名称 - - + 所属蜂场 - - + @@ -35,12 +35,14 @@ - + placeholder-class="my-placeholder"/> + - + 确认添加 + + @@ -52,21 +54,95 @@ backgroundColor: " #F4FAF8", }, title: "添加蜂箱", - + sn: '', + name: '', + videoStream: '', + fc: '', + fcid:'', + showmiyuan: false, + miyuancolumns: [], + pagesum: 1, + pagesize: 99 } }, onLoad() { - + this.getmiyuancolumns() }, onShow() { }, methods: { - addApiary(){ - uni.navigateTo({ - url:'/pages/Apiary/AddApiary' + btnqrcode(){ + uni.scanCode({ + onlyFromCamera: true, + scanType: ['qrCode'], + success: res => { + this.sn = res.result + }, + fail: err => { + console.error('扫描失败:', err) + uni.showToast({ + title: '扫描失败', + icon: 'none' + }) + } + }) + }, + confirmmy(e){ + this.fc = e[0].label + this.fcid = e[0].value + }, + getmiyuancolumns() { + let data = { + pageNum: this.pagesum, + pageSize: this.pagesize + }; + this.$u.get('/farm/apiary/list', data).then((res) => { + if (res.code === 200) { + this.miyuancolumns = res.rows.map(item => ({ + value: item.apiaryId, + label: item.name + })) + } else { + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + } + }) + }, + btnadd() { + let data = { + sn:this.sn, + name:this.name, + apiaryId:this.fcid, + videoStream:this.videoStream + } + this.$u.put('farm/beehive/bind', data).then(res => { + if (res.code == 200) { + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 1000 + }) + setTimeout(()=>{ + uni.navigateBack() + },1500) + } else { + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + } }) } + // addApiary(){ + // uni.navigateTo({ + // url:'/pages/Apiary/AddApiary' + // }) + // } } } @@ -80,6 +156,7 @@ .page { // position: relative; width: 750rpx; + .tit { margin-top: 40rpx; margin-left: 50rpx; @@ -87,15 +164,18 @@ font-size: 32rpx; color: #3D3D3D; } - .imgbox{ + + .imgbox { margin-top: 28rpx; margin-left: 46rpx; - image{ + + image { width: 412rpx; height: 222rpx; } } - .btn{ + + .btn { margin: 160rpx auto; // position: fixed; display: flex; @@ -107,11 +187,12 @@ height: 88rpx; background: #FFCC25; border-radius: 20rpx 20rpx 20rpx 20rpx; - + font-weight: 500; font-size: 32rpx; color: #FFFFFF; } + .iptbox { display: flex; align-items: center; @@ -123,31 +204,34 @@ background: #FFFFFF; box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0, 0, 0, 0.15); border-radius: 20rpx 20rpx 20rpx 20rpx; - .qrcode{ + + .qrcode { padding-right: 20rpx; border-right: 2rpx solid #D8D8D8; - image{ + + image { width: 54rpx; height: 54rpx; } } + .ips { width: 630rpx; - + } - + image { width: 18rpx; height: 32rpx; } - + .my-placeholder { font-weight: 400; font-size: 32rpx; color: #808080; } } - + } diff --git a/pages/Apiary.vue b/pages/Apiary.vue index 4f995b4..d36de1f 100644 --- a/pages/Apiary.vue +++ b/pages/Apiary.vue @@ -23,9 +23,9 @@ 当前还没有添加蜂场哦 - - - + + + @@ -37,17 +37,17 @@ - 福鼎蜂场 + {{item.name}} - 8箱 + {{item.beehiveCount}}箱 - 福建省宁德市福鼎市太姥山镇秦屿大道2号 福建省宁德市福鼎市太姥山镇秦屿大道2号 + {{item.address}} - + @@ -61,21 +61,63 @@ bgc: { backgroundColor: " #FAFDFD", }, - + pagesum: 1, + list: [], + total: '', + pagesize:10 } }, onLoad() { }, onShow() { - + this.pagesum = 1 + this.list = [] + this.ishave() }, methods: { - addApiary(){ + // 跳转蜂场详情 + btnapiaryxq(id){ + + }, + loadMore() { + if (this.list.length < this.total) { + this.ishave(); + } else { + uni.showToast({ + title: '没有更多蜂场了', + icon: 'none', + duration: 1000 + }); + } + }, + addApiary() { uni.navigateTo({ - url:'/pages/Apiary/AddApiary' + url: '/pages/Apiary/AddApiary' }) - } + }, + ishave() { + let data = { + pageNum: this.pagesum, + pageSize: this.pagesize + }; + this.$u.get('/farm/apiary/list', data).then((res) => { + if (res.code === 200) { + this.total = res.total + let uniqueIds = new Set(this.list.map(item => item.apiaryId)) + let uniqueRows = res.rows.filter(row => !uniqueIds.has(row.apiaryId)) + uniqueRows.forEach(row => uniqueIds.add(row.apiaryId)) + this.list = this.list.concat(uniqueRows) + this.pagesum++ + } else { + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + } + }) + }, } } @@ -91,10 +133,14 @@ width: 750rpx; .Apiary_box { - display: flex; - justify-content: center; + padding-left: 40rpx; + box-sizing: border-box; + padding-bottom: 300rpx; + overflow-y: auto; + height: 100vh; .Apiary_card { + margin-top: 20rpx; position: relative; width: 674rpx; height: 512rpx; @@ -106,7 +152,8 @@ width: 674rpx; height: 360rpx; } - .address{ + + .address { margin-top: 18rpx; padding: 0 24rpx; font-weight: 500; @@ -118,24 +165,28 @@ /* 超出部分隐藏 */ text-overflow: ellipsis; } - .info{ + + .info { margin-top: 18rpx; padding: 0 24rpx; display: flex; align-items: center; flex-wrap: nowrap; justify-content: space-between; - .left{ + + .left { font-weight: 600; font-size: 36rpx; color: #3D3D3D; } - .right{ + + .right { font-weight: 600; font-size: 32rpx; color: #50565A; } } + .weather { padding: 20rpx 24rpx; position: absolute; @@ -146,19 +197,22 @@ top: 0; width: 674rpx; height: 70rpx; - + background: linear-gradient(to bottom, rgba(255, 255, 255, 0.8), transparent); - image{ + + image { width: 44rpx; height: 44rpx; } - .txt1{ + + .txt1 { margin-left: 16rpx; font-weight: 600; font-size: 32rpx; color: #3D3D3D; } - .txt2{ + + .txt2 { margin-left: 28rpx; font-weight: 600; font-size: 28rpx; diff --git a/pages/Apiary/AddApiary.vue b/pages/Apiary/AddApiary.vue index 67631e8..db4ebd2 100644 --- a/pages/Apiary/AddApiary.vue +++ b/pages/Apiary/AddApiary.vue @@ -24,14 +24,14 @@ 养殖蜂种 - + 采集蜜源 - + @@ -48,9 +48,9 @@ - - - + + + 确认添加