aaa
This commit is contained in:
parent
c543391de9
commit
758102723d
|
@ -5,19 +5,14 @@
|
|||
</u-navbar>
|
||||
<view class="mapbox">
|
||||
<map class="map" id="map" ref="map" :scale="zoomSize" :latitude="latitude" :longitude="longitude"
|
||||
:show-location='true'> </map>
|
||||
<!-- <view class="num">
|
||||
<view class="txt">
|
||||
在线:1001
|
||||
</view>
|
||||
<view class="txt" style="color:#FF473E ;margin-top: 10rpx;">
|
||||
在线:100
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="btn" @click="showwl = true">
|
||||
:show-location='true' :markers="covers"> </map>
|
||||
<view class="fxmask">
|
||||
未找到位置信息
|
||||
</view>
|
||||
<!-- <view class="btn" @click="showwl = true">
|
||||
<image src="https://api.ccttiot.com/smartmeter/img/static/uAJBChYkLJO66dYUkJ8M" mode=""></image>
|
||||
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="tit">
|
||||
{{obj.name}}-{{obj.sn}}
|
||||
|
@ -340,8 +335,8 @@
|
|||
backgroundColor: " #FAFDFD",
|
||||
},
|
||||
title: "蜂箱详情",
|
||||
latitude: '39.916527',
|
||||
longitude: ' 116.397128',
|
||||
latitude: '7',
|
||||
longitude: '',
|
||||
isMap: false,
|
||||
zoomSize: 15,
|
||||
markers: [{
|
||||
|
@ -381,7 +376,8 @@
|
|||
month: '',
|
||||
day:''
|
||||
},
|
||||
daytime:''
|
||||
daytime:'',
|
||||
covers: [],
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
|
@ -398,8 +394,8 @@
|
|||
this.$refs.canvas7.init(this.initChart7)
|
||||
}, 1000)
|
||||
this.getobj()
|
||||
const now = new Date();
|
||||
const previousDay = new Date(now)
|
||||
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')
|
||||
|
@ -440,7 +436,6 @@
|
|||
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)
|
||||
|
@ -625,8 +620,8 @@
|
|||
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
|
||||
this.latitude = res.data.lat
|
||||
this.longitude = res.data.lng
|
||||
if(res.data.enableFan == false){
|
||||
this.fskx = '关'
|
||||
}else{
|
||||
|
@ -637,11 +632,21 @@
|
|||
}else{
|
||||
this.jrkg = '开'
|
||||
}
|
||||
if(res.data.lat == 0 && res.data.lng == 0){
|
||||
console.log('未找到位置信息');
|
||||
this.zoomSize = 5
|
||||
}else{
|
||||
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()
|
||||
if(this.latitude == 0 && this.longitude == 0){
|
||||
this.zoomSize = 2
|
||||
}
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
|
@ -661,7 +666,6 @@
|
|||
let date = new Date(this.daytime);
|
||||
let formattedDate = this.formatDate(date)
|
||||
this.daytime = formattedDate
|
||||
console.log(this.daytime);
|
||||
}
|
||||
})
|
||||
},
|
||||
|
@ -1906,7 +1910,22 @@
|
|||
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;
|
||||
font-size: 36rpx;
|
||||
padding-top: 288rpx;
|
||||
box-sizing: border-box;
|
||||
font-weight: 600;
|
||||
}
|
||||
.num {
|
||||
width: 180rpx;
|
||||
position: absolute;
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
{{daily[0].humidity}} %
|
||||
</view>
|
||||
</view>
|
||||
<image @click="btnedfc" style="width: 44rpx;height: 44rpx;position: absolute;top: 240rpx;right:20rpx ;" src="https://api.ccttiot.com/smartmeter/img/static/ulHBKvkXDfe9OIveIJKZ" mode=""></image>
|
||||
<image @click="btnedfc" style="width: 44rpx;height: 44rpx;position: absolute;top: 240rpx;right:20rpx ;"
|
||||
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()">
|
||||
|
@ -49,11 +50,11 @@
|
|||
</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'> </map>
|
||||
:show-location='true' :polygons="polygons" :markers="covers"> </map>
|
||||
<view class="num">
|
||||
<view class="txt">
|
||||
在线:{{apiaryobj.onlineBeehiveCount}}
|
||||
|
@ -137,8 +138,9 @@
|
|||
</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>
|
||||
<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' />
|
||||
|
@ -196,60 +198,101 @@
|
|||
apiaryId: '',
|
||||
apiaryobj: {},
|
||||
listmy: '',
|
||||
listfz:'',
|
||||
daily:[],
|
||||
chartData7:[],
|
||||
chartData8:[],
|
||||
daytime:''
|
||||
listfz: '',
|
||||
daily: [],
|
||||
chartData7: [],
|
||||
chartData8: [],
|
||||
daytime: '',
|
||||
covers: [],
|
||||
polygons: [{
|
||||
//多边形的坐标数组
|
||||
points: [],
|
||||
fillColor: "#cbdde9",
|
||||
strokeColor: "#78addd",
|
||||
strokeWidth: 1,
|
||||
zIndex: 1,
|
||||
}]
|
||||
|
||||
}
|
||||
},
|
||||
},
|
||||
onLoad(option) {
|
||||
setTimeout(() => {
|
||||
this.$refs.canvas7.init(this.initChart7)
|
||||
}, 1000)
|
||||
this.apiaryId = option.id
|
||||
this.getfcxq()
|
||||
this.getMyLocation()
|
||||
},
|
||||
onShow() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
btnedfc(){
|
||||
methods: {
|
||||
// 请求指定蜂场蜂箱
|
||||
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: 25,
|
||||
height: 30,
|
||||
iconPath: 'https://api.ccttiot.com/smartmeter/img/static/ukbyhyrDcp3VzgyeJo2G',
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('获取位置失败:', err)
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
btnedfc() {
|
||||
uni.navigateTo({
|
||||
url:'/pages/Apiary/Apiary_edit/Apiary_edit?apiaryId=' + this.apiaryId
|
||||
url: '/pages/Apiary/Apiary_edit/Apiary_edit?apiaryId=' + this.apiaryId
|
||||
})
|
||||
},
|
||||
btncaozuo(){
|
||||
btncaozuo() {
|
||||
uni.navigateTo({
|
||||
url:'/page_Beehive/Beehive_log?apiaryId=' + this.apiaryId + '&name=' + this.apiaryobj.name
|
||||
url: '/page_Beehive/Beehive_log?apiaryId=' + this.apiaryId + '&name=' + this.apiaryobj.name
|
||||
})
|
||||
},
|
||||
btnpage(){
|
||||
btnpage() {
|
||||
uni.switchTab({
|
||||
url:'/pages/Beehive'
|
||||
url: '/pages/Beehive'
|
||||
})
|
||||
},
|
||||
gettq(){
|
||||
console.log(this.latitude,this.longitude);
|
||||
gettq() {
|
||||
console.log(this.latitude, this.longitude);
|
||||
this.$u.get(`weather/7d?location=${this.longitude},${this.latitude}`).then(res => {
|
||||
if(res.code == 200){
|
||||
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 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}`
|
||||
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 => {
|
||||
|
@ -257,6 +300,22 @@
|
|||
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',
|
||||
})
|
||||
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
|
||||
|
||||
console.log(this.polygons[0].points, '圆形电子围栏点')
|
||||
|
||||
this.gettq()
|
||||
this.getmy()
|
||||
this.getfz()
|
||||
|
@ -269,11 +328,44 @@
|
|||
}
|
||||
})
|
||||
},
|
||||
// 计算电子围栏
|
||||
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; // 角度从0到2π
|
||||
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; // 转换到-180到180的范围
|
||||
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){
|
||||
for (let i = 0; i < res.data.length; i++) {
|
||||
if (res.data[i].dictValue == this.apiaryobj.honeyType) {
|
||||
this.listmy = res.data[i].dictLabel
|
||||
}
|
||||
}
|
||||
|
@ -283,8 +375,8 @@
|
|||
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){
|
||||
for (let i = 0; i < res.data.length; i++) {
|
||||
if (res.data[i].dictValue == this.apiaryobj.beeType) {
|
||||
this.listfz = res.data[i].dictLabel
|
||||
}
|
||||
}
|
||||
|
@ -454,7 +546,7 @@
|
|||
.page {
|
||||
position: relative;
|
||||
width: 750rpx;
|
||||
|
||||
|
||||
.pops {
|
||||
position: fixed;
|
||||
left: 98rpx;
|
||||
|
@ -789,6 +881,7 @@
|
|||
// position: relative;
|
||||
margin-top: 42rpx;
|
||||
margin-left: 38rpx;
|
||||
|
||||
.tip_cont {
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
|
|
|
@ -323,8 +323,8 @@
|
|||
this.$u.get('/farm/apiary/list?', data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
if (res.total >= 1) {
|
||||
this.getnum()
|
||||
this.getnums()
|
||||
// this.getnum()
|
||||
// this.getnums()
|
||||
this.haveApiary = true
|
||||
} else {
|
||||
this.haveApiary = false
|
||||
|
|
|
@ -167,8 +167,6 @@
|
|||
this.jinweidu = res.longitude + ',' + res.latitude
|
||||
this.latitude = Number(res.latitude.toFixed(5)) - 0.004
|
||||
this.longitude = Number(res.longitude.toFixed(5)) + 0.004
|
||||
// this.setMapScale()
|
||||
// 请求附近的店铺
|
||||
this.$u.get("/farm/apiary/listNearBy?center=" + this.jinweidu + '&radius=' + 1000).then(
|
||||
res => {
|
||||
if (res.code == 200) {
|
||||
|
@ -208,11 +206,9 @@
|
|||
textShadow: '2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white',
|
||||
borderColor:'#fff',
|
||||
borderRadius:5,
|
||||
// bgColor: 'rgba(255, 255, 255, 0.7)'
|
||||
}
|
||||
})
|
||||
// this.covers.push(shopCover)
|
||||
});
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user