按照租户信息修改河津的新小程序第分支提交
This commit is contained in:
parent
81a0a7ba3d
commit
816306b598
|
|
@ -48,7 +48,7 @@ http.interceptor.request((config, cancel) => { /* 请求之前拦截器 */
|
||||||
'app-id' : uni.getAccountInfoSync().miniProgram.appId,
|
'app-id' : uni.getAccountInfoSync().miniProgram.appId,
|
||||||
"client-type" : "MA",
|
"client-type" : "MA",
|
||||||
'third-session' : uni.getStorageSync('third_session')||'123',
|
'third-session' : uni.getStorageSync('third_session')||'123',
|
||||||
'X-Tenant-Id' : '1002'
|
'X-Tenant-Id' : '1004'
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
if (!token) { // 如果token不存在,调用cancel 会取消本次请求,但是该函数的catch() 仍会执行
|
if (!token) { // 如果token不存在,调用cancel 会取消本次请求,但是该函数的catch() 仍会执行
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name" : "吉县面源污染监测平台",
|
"name" : "河津市农业面源污染监测系统",
|
||||||
"appid" : "__UNI__A58A5D7",
|
"appid" : "__UNI__A58A5D7",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "2.2.22",
|
"versionName" : "2.2.22",
|
||||||
|
|
@ -84,7 +84,7 @@
|
||||||
"quickapp" : {},
|
"quickapp" : {},
|
||||||
/* 快应用特有相关 */
|
/* 快应用特有相关 */
|
||||||
"mp-weixin" : {
|
"mp-weixin" : {
|
||||||
"appid" : "wxc078890f8668ed2e",
|
"appid" : "wx2fb61322f3042141",
|
||||||
"setting" : {
|
"setting" : {
|
||||||
"urlCheck" : false,
|
"urlCheck" : false,
|
||||||
"es6" : true,
|
"es6" : true,
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<text class="botmTetx">Copyright <text style="font-size: 30rpx;padding:0rpx 7rpx;"> © </text> 吉县现代农业发展中心</text>
|
<!-- <text class="botmTetx">Copyright <text style="font-size: 30rpx;padding:0rpx 7rpx;"> © </text> 河津市现代农业发展中心</text> -->
|
||||||
<!-- <view class="loginpage">
|
<!-- <view class="loginpage">
|
||||||
<image class="bigimg" src="../../static/dls.jpg" mode=""></image>
|
<image class="bigimg" src="../../static/dls.jpg" mode=""></image>
|
||||||
<view class="padding text-center margin-top">
|
<view class="padding text-center margin-top">
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
</view>
|
</view>
|
||||||
</view> -->
|
</view> -->
|
||||||
</view>
|
</view>
|
||||||
<text class="botmTetx">Copyright <text style="font-size: 30rpx;padding:0rpx 7rpx;"> © </text> 吉县现代农业发展中心</text>
|
<!-- <text class="botmTetx">Copyright <text style="font-size: 30rpx;padding:0rpx 7rpx;"> © </text> 河津市现代农业发展中心</text> -->
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
{
|
{
|
||||||
"path": "pages/index/index",
|
"path": "pages/index/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "吉县小流域面源污染监测",
|
"navigationBarTitleText": "河津市农业面源污染监测系统",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<uni-nav-bar :fixed="true" leftWidth="00rpx" rightWidth="0rpx" background-color="transparent" status-bar title="吉县农业面源污染在线监测小程序" />
|
<uni-nav-bar :fixed="true" leftWidth="00rpx" rightWidth="0rpx" background-color="transparent" status-bar title="河津市农业面源污染监测系统" />
|
||||||
<image src="../../static/home_top_bg.png" mode="" class="bgimg"></image>
|
<image src="../../static/home_top_bg.png" mode="" class="bgimg"></image>
|
||||||
<scroll-view class="content" scroll-y="true" :style="{height:contentheight + 'rpx'}">
|
<scroll-view class="content" scroll-y="true" :style="{height:contentheight + 'rpx'}">
|
||||||
<view class="top_address">
|
<view class="top_address">
|
||||||
|
|
|
||||||
|
|
@ -1,455 +1,421 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<map id="map" ref="map" style="width: 100%; height: calc(100vh + 50rpx);" :scale="mapScale" :markers="markers"
|
<!-- <image src="../../static/zddt.jpg" mode="" class="bgimg" @click="todetail()"></image> -->
|
||||||
longitude="112.83100231396601" latitude="36.872032399813556" show-location show-compass show-scale
|
<map id="map" style="width: 100%; height:2000rpx;" scale="13" :markers="markers" longitude="110.628279"
|
||||||
@markertap="markertap">
|
latitude="35.546105" show-location @markertap="markertap" @callouttap="callouttap">
|
||||||
|
<cover-view slot="callout">
|
||||||
|
<cover-view v-for="(item,index) in markers" :key="index" class="customCallout" :marker-id="item.id">
|
||||||
|
<cover-image class="imgs" src="@/static/zhandian_icon_xuqin_title.png"
|
||||||
|
v-if="item.stationType == 'livestock'"></cover-image>
|
||||||
|
<cover-image class="imgs" src="@/static/zhandian_icon_nongtian_title.png"
|
||||||
|
v-if="item.stationType == 'orient'"></cover-image>
|
||||||
|
<cover-image class="imgs" src="@/static/zhandian_icon_qiye_title.png"
|
||||||
|
v-if="item.stationType == 'cusLocaltion'"></cover-image>
|
||||||
|
<cover-view class="content"
|
||||||
|
v-if="item.stationType == 'livestock' || item.stationType == 'orient'|| item.stationType == 'cusLocaltion'">
|
||||||
|
{{item.stationName}}
|
||||||
|
</cover-view>
|
||||||
|
</cover-view>
|
||||||
|
</cover-view>
|
||||||
</map>
|
</map>
|
||||||
<view class="zdxq">
|
<view class="zdxq">
|
||||||
<view class="zdxqitem" @click="switch2Change('livestock')">
|
<view class="zdxqitem" @click="switch1Change">
|
||||||
|
<image src="../../static/zhandian_sahchong_dingwei.png" mode=""></image>
|
||||||
|
<view class="textss">
|
||||||
|
联网式太阳能杀虫灯
|
||||||
|
</view>
|
||||||
|
<view class="crildon" :style="!isscd?'background:#00ff37':'background: #ccc;'"></view>
|
||||||
|
</view>
|
||||||
|
<view class="zdxqitem" @click="switch2Change">
|
||||||
<image src="../../static/zhandian_xuqin_dingwei.png" mode=""></image>
|
<image src="../../static/zhandian_xuqin_dingwei.png" mode=""></image>
|
||||||
<view class="textss">
|
<view class="textss">
|
||||||
畜禽污染监测站
|
畜禽养殖污染监测站
|
||||||
</view>
|
</view>
|
||||||
|
<view class="crildon" :style="!issscd?'background:#00ff37':'background: #ccc;'"></view>
|
||||||
</view>
|
</view>
|
||||||
<view class="zdxqitem" @click="switch2Change('orient')">
|
<view class="zdxqitem" @click="switch3Change">
|
||||||
<image src="../../static/zhandian_nongtian_dingwei.png" mode=""></image>
|
<image src="../../static/zhandian_nongtian_dingwei.png" mode=""></image>
|
||||||
<view class="textss">
|
<view class="textss">
|
||||||
农田污染监测站
|
农田面源污染监测站
|
||||||
</view>
|
</view>
|
||||||
|
<view class="crildon" :style="!isssscd?'background:#00ff37':'background: #ccc;'"></view>
|
||||||
</view>
|
</view>
|
||||||
<!-- <view class="zdxqitem" @click="switch2Change('watershed')">
|
|
||||||
<image src="../../static/zhandian_xiaoliuyu_dingwei.png" mode=""></image>
|
|
||||||
<view class="textss">
|
|
||||||
小流域监测站
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="zdxqitem" @click="switch2Change('soil')">
|
|
||||||
<image src="../../static/iconsheturangzs.png" mode=""></image>
|
|
||||||
<view class="textss">
|
|
||||||
长期定位监测点
|
|
||||||
</view>
|
|
||||||
</view> -->
|
|
||||||
</view>
|
</view>
|
||||||
|
<!-- <view class="switchs" :defaultSwitch="isscd">-->
|
||||||
|
<!-- <selectSwitch @change="switch1Change" :defaultSwitch="isscd" checked_bj_color="#13ce66"/>-->
|
||||||
|
<!-- <switch style="margin-right: 10rpx;" :checked="isscd" @change="switch1Change" />-->
|
||||||
|
<!-- <!– 显示/隐藏杀虫灯 –>-->
|
||||||
|
<!-- </view>-->
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import api from '@/api/api'
|
import api from '@/api/api'
|
||||||
import configService from '@/common/service/config.service.js';
|
import selectSwitch from "@/components/xuan-switch/xuan-switch.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
selectSwitch
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
baseUrl: configService.staticDomainURL,
|
|
||||||
center: {
|
|
||||||
latitude: 36.5,
|
|
||||||
longitude: 111.7
|
|
||||||
},
|
|
||||||
mapScale: 13,
|
|
||||||
markers: [],
|
markers: [],
|
||||||
markersZIndex: 1,
|
markersNoPest: [],
|
||||||
lastTap: '',
|
list: [],
|
||||||
stationList: [],
|
pointers: [],
|
||||||
cusLocationList: [],
|
imgurl1: '@/static/zhandian_icon_nongtian_title.png',
|
||||||
soilStationList: [],
|
imgurl2: '@/static/zhandian_icon_xuqin_title.png',
|
||||||
allStationList: [],
|
isscd: true,
|
||||||
stationTwoList: [],
|
issscd: true,
|
||||||
mapCtx: null // 添加地图上下文
|
isssscd: true,
|
||||||
|
pestlight: [],
|
||||||
|
cusLocation: [],
|
||||||
|
stationInfo: [],
|
||||||
|
pestlightMarker: null,
|
||||||
|
stationlist: [],
|
||||||
|
timerSet: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onLoad() {},
|
onLoad() {
|
||||||
onReady() {
|
// this.isscd = true
|
||||||
// 在onReady中初始化地图上下文
|
// this.getList()
|
||||||
this.mapCtx = uni.createMapContext('map', this);
|
this.$nextTick(() => {
|
||||||
|
this.getList()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
api.checkLogin(() => {
|
var that = this
|
||||||
this.$nextTick(() => {
|
if (uni.getStorageSync('third_session')) {
|
||||||
this.getList()
|
uni.login({
|
||||||
})
|
success: function(res) {
|
||||||
}, () => {
|
console.log(res.code)
|
||||||
|
this.code = res.code
|
||||||
|
let params = {}
|
||||||
|
params.jsCode = this.code
|
||||||
|
console.log(params, 152)
|
||||||
|
api.wxlogin(params).then(res => {
|
||||||
|
console.log(res, 165)
|
||||||
|
if (res.data.code == 0) {
|
||||||
|
let userInfo = res.data.data;
|
||||||
|
// uni.setStorageSync('third_session', userInfo.thirdSession);
|
||||||
|
if (!userInfo.id) {
|
||||||
|
uni.reLaunch({
|
||||||
|
url: '/packDetail/pages/login/login'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// that.isscd = true
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (!uni.getStorageSync('third_session')) {
|
||||||
uni.reLaunch({
|
uni.reLaunch({
|
||||||
url: '/packDetail/pages/login/login'
|
url: '/pages/loginindex'
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
onReady() {
|
||||||
|
// 1.页面准备好后,获取到map组件的执行上下文。注意:这里是取的map的id属性
|
||||||
|
this.mapContext = uni.createMapContext("alarm_map", this);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// kaihs
|
|
||||||
getList() {
|
getList() {
|
||||||
this.markers = []
|
this.markers = []
|
||||||
this.stationList = []
|
this.markersNoPest = []
|
||||||
this.cusLocationList = []
|
this.pointers = []
|
||||||
this.soilStationList = []
|
this.list = []
|
||||||
this.allStationList = []
|
uni.showLoading({
|
||||||
this.stationTwoList = []
|
title: '加载中'
|
||||||
|
});
|
||||||
uni.showLoading({
|
this.$http.get('/applet/survStationInfo/stationMap').then(res => {
|
||||||
title: '加载中'
|
this.stationlist = [...res.data.data.pestlight, ...res.data.data.cusLocation, ...res.data.data.stationInfo]
|
||||||
});
|
this.stationlist.forEach((item,index) => {
|
||||||
|
item.id = index;
|
||||||
this.$http.get('/applet/survStationInfo/stationMap').then(res => {
|
if(item.inType == 'pestlight'){
|
||||||
// 处理数据
|
this.pestlight.push(item)
|
||||||
this.stationList = [...res.data.data.stationInfo];
|
}
|
||||||
this.cusLocationList = [...res.data.data.cusLocation];
|
if(item.stationType == 'cusLocaltion'){
|
||||||
this.soilStationList = [...res.data.data.deviceList];
|
this.cusLocation.push(item)
|
||||||
this.allStationList.push(...this.stationList);
|
}
|
||||||
this.allStationList.push(...this.cusLocationList);
|
if(item.stationType == 'orient' || item.stationType == 'livestock'){
|
||||||
this.allStationList.push(...this.soilStationList);
|
this.stationInfo.push(item)
|
||||||
this.allStationList.forEach((item, index) => {
|
}
|
||||||
item.id = index;
|
this.list.push({
|
||||||
});
|
latitude:Number(item.stationLatitude),
|
||||||
|
longitude: Number(item.stationLongitude),
|
||||||
this.issscd = false
|
stationType:item.stationType,
|
||||||
this.isssscd = false
|
sortNo: item.sortNo,
|
||||||
this.isSoilShow = false
|
stationName: item.stationName,
|
||||||
|
stationCode: item.stationCode
|
||||||
// 渲染所有标记
|
})
|
||||||
this.enterpriseRender();
|
})
|
||||||
this.stationRender();
|
this.issscd = false
|
||||||
this.monitorRender()
|
this.isssscd = false
|
||||||
|
this.qiyeChange()
|
||||||
// 使用增强的视野调整方法
|
this.list1query()
|
||||||
this.ensureAllMarkersVisible();
|
this.list2query()
|
||||||
|
uni.hideLoading();
|
||||||
uni.hideLoading();
|
})
|
||||||
}).catch(err => {
|
|
||||||
uni.hideLoading();
|
|
||||||
uni.showToast({
|
|
||||||
title: '数据加载失败',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
console.error('加载地图数据失败:', err);
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
ensureAllMarkersVisible() {
|
// 处理 stationlist 数据方法
|
||||||
// 确保地图上下文已初始化
|
processStationList(stationlist) {
|
||||||
if (!this.mapCtx) {
|
if (stationlist) {
|
||||||
this.mapCtx = uni.createMapContext('map', this);
|
stationlist.forEach(item => {
|
||||||
}
|
this.list.push({
|
||||||
|
latitude: item.inType === 'pestlight' ? Number(item.latitude) : Number(item
|
||||||
// 过滤出有效的坐标点
|
.stationLatitude),
|
||||||
const validPoints = this.markers
|
longitude: item.inType === 'pestlight' ? Number(item.longitude) : Number(item
|
||||||
.filter(item => {
|
.stationLongitude),
|
||||||
const lat = Number(item.latitude);
|
stationType: item.inType === 'pestlight' ? 'pestlight' : item.stationType,
|
||||||
const lng = Number(item.longitude);
|
sortNo: item.sortNo,
|
||||||
return !isNaN(lat) && !isNaN(lng) && lat !== 0 && lng !== 0;
|
stationName: item.stationName,
|
||||||
})
|
stationCode: item.stationCode
|
||||||
.map(item => ({
|
})
|
||||||
latitude: Number(item.latitude),
|
})
|
||||||
longitude: Number(item.longitude)
|
}
|
||||||
}));
|
|
||||||
|
|
||||||
if (validPoints.length === 0) {
|
|
||||||
console.warn('没有有效的坐标点');
|
|
||||||
// 如果有默认坐标,使用默认坐标
|
|
||||||
if (this.center.latitude && this.center.longitude) {
|
|
||||||
this.mapCtx.moveToLocation({
|
|
||||||
latitude: this.center.latitude,
|
|
||||||
longitude: this.center.longitude,
|
|
||||||
scale: 10
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('有效坐标点数量:', validPoints.length);
|
|
||||||
|
|
||||||
// 方法1:使用 includePoints(优先)
|
|
||||||
try {
|
|
||||||
this.mapCtx.includePoints({
|
|
||||||
points: validPoints,
|
|
||||||
padding: [120, 120, 120, 120], // 增加边距让点位不贴边
|
|
||||||
success: () => {
|
|
||||||
console.log('地图视野调整成功');
|
|
||||||
},
|
|
||||||
fail: (err) => {
|
|
||||||
console.error('includePoints失败:', err);
|
|
||||||
// 如果失败,使用备用方案
|
|
||||||
this.fallbackAdjustMap(validPoints);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
console.error('调整地图视野异常:', e);
|
|
||||||
this.fallbackAdjustMap(validPoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 方法2:延迟重试(确保地图完全渲染)
|
|
||||||
setTimeout(() => {
|
|
||||||
if (this.mapCtx) {
|
|
||||||
try {
|
|
||||||
this.mapCtx.includePoints({
|
|
||||||
points: validPoints,
|
|
||||||
padding: [150, 150, 150, 150]
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
console.error('第二次调整失败:', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 500);
|
|
||||||
|
|
||||||
// 方法3:第三次重试(更长的延迟)
|
|
||||||
setTimeout(() => {
|
|
||||||
if (this.mapCtx) {
|
|
||||||
try {
|
|
||||||
this.mapCtx.includePoints({
|
|
||||||
points: validPoints,
|
|
||||||
padding: [180, 160, 160, 160]
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
console.error('第三次调整失败:', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
},
|
},
|
||||||
fallbackAdjustMap(validPoints) {
|
// 生成 pointers 数据方法
|
||||||
if (!validPoints || validPoints.length === 0) return;
|
generatePointers() {
|
||||||
|
const iconConfig = {
|
||||||
try {
|
// pestlight: {
|
||||||
// 计算所有点位的中心点和范围
|
// iconPath: '/static/zhandian_sahchong_dingwei.png',
|
||||||
const lats = validPoints.map(p => p.latitude);
|
// width: 15,
|
||||||
const lngs = validPoints.map(p => p.longitude);
|
// height: 20
|
||||||
|
// },
|
||||||
const minLat = Math.min(...lats);
|
orient: {
|
||||||
const maxLat = Math.max(...lats);
|
iconPath: '/static/zhandian_nongtian_dingwei.png',
|
||||||
const minLng = Math.min(...lngs);
|
width: 35,
|
||||||
const maxLng = Math.max(...lngs);
|
height: 52
|
||||||
|
},
|
||||||
// 计算中心点
|
livestock: {
|
||||||
const centerLat = (minLat + maxLat) / 2;
|
iconPath: '/static/zhandian_xuqin_dingwei.png',
|
||||||
const centerLng = (minLng + maxLng) / 2;
|
width: 35,
|
||||||
|
height: 52
|
||||||
// 计算合适的缩放级别
|
},
|
||||||
const latDiff = maxLat - minLat;
|
cusLocaltion: {
|
||||||
const lngDiff = maxLng - minLng;
|
iconPath: '/static/qiyeIcon.png',
|
||||||
const maxDiff = Math.max(latDiff, lngDiff);
|
width: 35,
|
||||||
|
height: 52
|
||||||
let scale = 13;
|
}
|
||||||
if (maxDiff > 2) scale = 6;
|
}
|
||||||
else if (maxDiff > 1) scale = 8;
|
this.list.forEach((item, i) => {
|
||||||
else if (maxDiff > 0.5) scale = 10;
|
const config = iconConfig[item.stationType] || {}
|
||||||
else if (maxDiff > 0.2) scale = 11;
|
item.iconPath = config.iconPath || ''
|
||||||
else if (maxDiff > 0.1) scale = 12;
|
item.width = config.width || 0
|
||||||
else scale = 13;
|
item.height = config.height || 0
|
||||||
|
this.pointers.push({
|
||||||
console.log('备用方案 - 中心点:', centerLat, centerLng, '缩放:', scale);
|
id: i,
|
||||||
|
iconPath: item.iconPath,
|
||||||
// 移动地图到计算出的中心位置
|
latitude: Number(item.latitude),
|
||||||
this.mapCtx.moveToLocation({
|
longitude: Number(item.longitude),
|
||||||
latitude: centerLat,
|
width: item.width,
|
||||||
longitude: centerLng,
|
height: item.height,
|
||||||
scale: scale
|
customCallout: {
|
||||||
});
|
anchorY: 0, // Y轴偏移量
|
||||||
} catch (e) {
|
anchorX: 0, // X轴偏移量
|
||||||
console.error('备用方案失败:', e);
|
display: 'ALWAYS' // 一直展示
|
||||||
}
|
},
|
||||||
},
|
stationType: item.stationType,
|
||||||
enterpriseRender() {
|
stationName: item.stationName,
|
||||||
for (let i = 0; i < this.cusLocationList.length; i++) {
|
stationCode: item.stationCode,
|
||||||
const item = this.cusLocationList[i];
|
joinCluster: true // 是否参与点聚合
|
||||||
const lat = Number(item.stationLatitude);
|
})
|
||||||
const lng = Number(item.stationLongitude);
|
})
|
||||||
|
|
||||||
// 验证坐标有效性
|
|
||||||
if (isNaN(lat) || isNaN(lng) || lat === 0 || lng === 0) {
|
|
||||||
console.warn('企业点位坐标无效:', item.stationName, lat, lng);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const markerItem = {
|
|
||||||
id: item.id || `enterprise_${i}`,
|
|
||||||
iconPath: '/static/qiyeIcon.png',
|
|
||||||
latitude: lat,
|
|
||||||
longitude: lng,
|
|
||||||
width: 35,
|
|
||||||
height: 52,
|
|
||||||
customCallout: {
|
|
||||||
anchorY: 0,
|
|
||||||
anchorX: 0,
|
|
||||||
display: 'ALWAYS'
|
|
||||||
},
|
|
||||||
stationType: item.stationType,
|
|
||||||
stationName: item.stationName,
|
|
||||||
stationCode: item.stationCode,
|
|
||||||
joinCluster: false,
|
|
||||||
zIndex: this.markersZIndex,
|
|
||||||
};
|
|
||||||
this.markers.push(markerItem);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
stationRender() {
|
|
||||||
if (!this.issscd) {
|
|
||||||
for (let i = 0; i < this.stationList.length; i++) {
|
|
||||||
const item = this.stationList[i];
|
|
||||||
const lat = Number(item.stationLatitude);
|
|
||||||
const lng = Number(item.stationLongitude);
|
|
||||||
|
|
||||||
// 验证坐标有效性
|
|
||||||
if (isNaN(lat) || isNaN(lng) || lat === 0 || lng === 0) {
|
|
||||||
console.warn('站房点位坐标无效:', item.stationName, lat, lng);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const markerItem = {
|
|
||||||
id: item.id || `station_${i}`,
|
|
||||||
iconPath: this.baseUrl + '/' + item.stationIcon,
|
|
||||||
latitude: lat,
|
|
||||||
longitude: lng,
|
|
||||||
width: 239,
|
|
||||||
height: 186,
|
|
||||||
customCallout: {
|
|
||||||
anchorY: 0,
|
|
||||||
anchorX: 0,
|
|
||||||
display: 'ALWAYS'
|
|
||||||
},
|
|
||||||
stationType: item.stationType,
|
|
||||||
stationName: item.stationName,
|
|
||||||
stationCode: item.stationCode,
|
|
||||||
joinCluster: false,
|
|
||||||
zIndex: this.markersZIndex,
|
|
||||||
};
|
|
||||||
this.markers.push(markerItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
monitorRender() {
|
|
||||||
this.soilStationList.forEach((item, index) => {
|
|
||||||
const lat = Number(item.latitude);
|
|
||||||
const lng = Number(item.longitude);
|
|
||||||
|
|
||||||
// 验证坐标有效性
|
|
||||||
if (isNaN(lat) || isNaN(lng) || lat === 0 || lng === 0) {
|
|
||||||
console.warn('监测点位坐标无效:', item.name, lat, lng);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let iconPath = '';
|
|
||||||
let width = 35;
|
|
||||||
let height = 35;
|
|
||||||
|
|
||||||
switch (item.type) {
|
|
||||||
case 'soil':
|
|
||||||
iconPath = this.baseUrl + '/icon/device/soil.png';
|
|
||||||
width = 32;
|
|
||||||
height = 47;
|
|
||||||
break;
|
|
||||||
case 'camera':
|
|
||||||
iconPath = this.baseUrl + '/icon/device/cam.png';
|
|
||||||
width = 45;
|
|
||||||
height = 45;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
iconPath = this.baseUrl + '/icon/device/default.png';
|
|
||||||
}
|
|
||||||
|
|
||||||
const markerItem = {
|
|
||||||
id: item.id || `device_${index}`,
|
|
||||||
iconPath: iconPath,
|
|
||||||
latitude: lat,
|
|
||||||
longitude: lng,
|
|
||||||
width: width,
|
|
||||||
height: height,
|
|
||||||
customCallout: {
|
|
||||||
anchorY: 0,
|
|
||||||
anchorX: 0,
|
|
||||||
display: 'ALWAYS'
|
|
||||||
},
|
|
||||||
stationType: 'device',
|
|
||||||
stationName: item.name,
|
|
||||||
stationCode: item.ids,
|
|
||||||
deviceType: item.type,
|
|
||||||
joinCluster: false,
|
|
||||||
zIndex: this.markersZIndex,
|
|
||||||
};
|
|
||||||
this.markers.push(markerItem);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
markertap(e) {
|
markertap(e) {
|
||||||
const index = e.detail.markerId
|
const index = e.detail.markerId
|
||||||
const marker = this.markers.find(m => m.id === index);
|
console.log(e.detail,'index')
|
||||||
if (marker) {
|
if (['orient', 'livestock'].includes(this.list[index].stationType)) {
|
||||||
if (['orient', 'livestock'].includes(marker.stationType)) {
|
uni.navigateTo({
|
||||||
uni.navigateTo({
|
url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(this.list[index]))}`
|
||||||
url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(marker))}`
|
})
|
||||||
})
|
|
||||||
} else if (marker.stationType === 'device') {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: `/packDetail/pages/vidio/soilindex`
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
switch2Change(name) { // 焦点显示图例
|
callouttap(e) {
|
||||||
// 更新对应区域的状态
|
const index = e.detail.markerId
|
||||||
let that = this;
|
if (['orient', 'livestock'].includes(this.list[index].stationType)) {
|
||||||
if (name === that.lastTap) {
|
uni.navigateTo({
|
||||||
that.adjustMapToFitAllMarkers();
|
url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(this.list[index]))}`
|
||||||
that.lastTap = '';
|
})
|
||||||
} else {
|
|
||||||
// 聚焦到特定区域
|
|
||||||
that.adjustMapToRegion(name);
|
|
||||||
that.lastTap = name;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 调整地图视野以包含所有标记点(类似setFitView效果)
|
todetails(item) {
|
||||||
adjustMapToFitAllMarkers() {
|
console.log(item, '还是个然后')
|
||||||
if (this.mapCtx && this.markers.length > 0) {
|
|
||||||
this.mapCtx.includePoints({
|
|
||||||
points: this.markers.map(item => ({
|
|
||||||
latitude: item.latitude,
|
|
||||||
longitude: item.longitude
|
|
||||||
})),
|
|
||||||
padding: [60, 60, 60, 60] // 上下左右的边距
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
adjustMapToRegion(regionName) {
|
switch1Change() {
|
||||||
// 调整地图视野到特定区域的标记点
|
this.isscd = !this.isscd;
|
||||||
//stationType: "orient" 农田
|
let index = 0;
|
||||||
//stationType: "livestock" 畜禽
|
if (!this.isscd) {
|
||||||
//stationType: "watershed" 小流域
|
this.pestlightMarker = [];
|
||||||
let that = this;
|
this.timerSet = setInterval(() => {
|
||||||
let points = [];
|
for (let i = 0; i < 50 && index < this.pestlight.length; i++) {
|
||||||
let markers = [];
|
const item = this.pestlight[index];
|
||||||
if (regionName === 'orient' || regionName === 'livestock' || regionName === 'watershed') {
|
item.iconPath = '/static/zhandian_sahchong_dingwei.png';
|
||||||
// 获取团柏河区域的所有标记点
|
item.latitude = Number(item.latitude);
|
||||||
markers = this.markers.filter(item => item.stationType === regionName);
|
item.longitude = Number(item.longitude);
|
||||||
} else if (regionName === 'soil') {
|
item.width = 15;
|
||||||
// 获取所有土壤设备标记点
|
item.height = 20;
|
||||||
markers = this.markers.filter(item => item.type === 'soil' || item.deviceType === 'soil');
|
// 创建符合 markers 格式的对象
|
||||||
}
|
const markerItem = {
|
||||||
console.log(this.markers)
|
id: item.id,
|
||||||
if (markers.length > 0) {
|
iconPath: item.iconPath,
|
||||||
points = markers.map(item => {
|
latitude: item.latitude,
|
||||||
item.zIndex = (that.markersZIndex++);
|
longitude: item.longitude,
|
||||||
return {
|
width: item.width,
|
||||||
latitude: Number(item.latitude || item.stationLatitude),
|
height: item.height,
|
||||||
longitude: Number(item.longitude || item.stationLongitude)
|
customCallout: {
|
||||||
|
anchorY: 0, // Y轴偏移量
|
||||||
|
anchorX: 0, // X轴偏移量
|
||||||
|
display: 'ALWAYS' // 一直展示
|
||||||
|
},
|
||||||
|
// stationType: item.stationType,
|
||||||
|
inType: item.inType,
|
||||||
|
stationName: item.stationName,
|
||||||
|
stationCode: item.stationCode,
|
||||||
|
joinCluster: false // 是否参与点聚合
|
||||||
|
};
|
||||||
|
this.markers.push(markerItem);
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
});
|
// this.markers = this.markers.concat(aa);
|
||||||
}
|
if (index >= this.pestlight.length) {
|
||||||
if (points.length > 0 && this.mapCtx) {
|
clearInterval(this.timerSet);
|
||||||
this.mapCtx.includePoints({
|
}
|
||||||
points: points,
|
}, 1000);
|
||||||
padding: [80, 110, 80, 110] // 增加边距以获得更好的显示效果
|
|
||||||
});
|
} else {
|
||||||
} else if (points.length === 0) {
|
clearInterval(this.timerSet);
|
||||||
// 如果没有找到对应的标记点,显示提示
|
this.markers = this.markers.filter((item)=>{
|
||||||
// uni.showToast({
|
return item.inType !== 'pestlight'
|
||||||
// title: `未找到${regionName}相关的监测点`,
|
})
|
||||||
// icon: 'none'
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
qiyeChange() {
|
||||||
|
for (let i = 0; i < this.cusLocation.length; i++) {
|
||||||
|
const item = this.cusLocation[i];
|
||||||
|
item.iconPath = '/static/qiyeIcon.png';
|
||||||
|
item.latitude = Number(item.stationLatitude);
|
||||||
|
item.longitude = Number(item.stationLongitude);
|
||||||
|
item.width = 35;
|
||||||
|
item.height = 52;
|
||||||
|
this.list.push({
|
||||||
|
latitude:Number(item.stationLatitude),
|
||||||
|
longitude: Number(item.stationLongitude),
|
||||||
|
stationType:item.stationType,
|
||||||
|
sortNo: item.sortNo,
|
||||||
|
stationName: item.stationName,
|
||||||
|
stationCode: item.stationCode
|
||||||
|
})
|
||||||
|
// 创建符合 markers 格式的对象
|
||||||
|
const markerItem = {
|
||||||
|
id: item.id,
|
||||||
|
iconPath: item.iconPath,
|
||||||
|
latitude: item.latitude,
|
||||||
|
longitude: item.longitude,
|
||||||
|
width: item.width,
|
||||||
|
height: item.height,
|
||||||
|
customCallout: {
|
||||||
|
anchorY: 0, // Y轴偏移量
|
||||||
|
anchorX: 0, // X轴偏移量
|
||||||
|
display: 'ALWAYS' // 一直展示
|
||||||
|
},
|
||||||
|
stationType: item.stationType,
|
||||||
|
stationName: item.stationName,
|
||||||
|
stationCode: item.stationCode,
|
||||||
|
joinCluster: true // 是否参与点聚合
|
||||||
|
};
|
||||||
|
this.markers.push(markerItem);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
switch2Change() {
|
||||||
|
this.issscd = !this.issscd
|
||||||
|
this.list1query()
|
||||||
|
},
|
||||||
|
switch3Change() {
|
||||||
|
this.isssscd = !this.isssscd
|
||||||
|
this.list2query()
|
||||||
|
},
|
||||||
|
list1query(){
|
||||||
|
if (!this.issscd) {
|
||||||
|
for (let i = 0; i < this.stationInfo.length; i++) {
|
||||||
|
const item = this.stationInfo[i];
|
||||||
|
if(item.stationType === 'orient'){
|
||||||
|
item.iconPath = '/static/zhandian_nongtian_dingwei.png';
|
||||||
|
item.latitude = Number(item.stationLatitude);
|
||||||
|
item.longitude = Number(item.stationLongitude);
|
||||||
|
item.width = 35;
|
||||||
|
item.height = 52;
|
||||||
|
// 创建符合 markers 格式的对象
|
||||||
|
const markerItem = {
|
||||||
|
id: item.id,
|
||||||
|
iconPath: item.iconPath,
|
||||||
|
latitude: item.latitude,
|
||||||
|
longitude: item.longitude,
|
||||||
|
width: item.width,
|
||||||
|
height: item.height,
|
||||||
|
customCallout: {
|
||||||
|
anchorY: 0, // Y轴偏移量
|
||||||
|
anchorX: 0, // X轴偏移量
|
||||||
|
display: 'ALWAYS' // 一直展示
|
||||||
|
},
|
||||||
|
stationType: item.stationType,
|
||||||
|
stationName: item.stationName,
|
||||||
|
stationCode: item.stationCode,
|
||||||
|
joinCluster: true // 是否参与点聚合
|
||||||
|
};
|
||||||
|
this.markers.push(markerItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.markers = this.markers.filter((item)=>{
|
||||||
|
return item.stationType !== 'orient'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
list2query(){
|
||||||
|
if (!this.isssscd) {
|
||||||
|
for (let i = 0; i < this.stationInfo.length; i++) {
|
||||||
|
const item = this.stationInfo[i];
|
||||||
|
if(item.stationType === 'livestock'){
|
||||||
|
item.iconPath = '/static/zhandian_xuqin_dingwei.png';
|
||||||
|
item.latitude = Number(item.stationLatitude);
|
||||||
|
item.longitude = Number(item.stationLongitude);
|
||||||
|
item.width = 35;
|
||||||
|
item.height = 52;
|
||||||
|
// 创建符合 markers 格式的对象
|
||||||
|
const markerItem = {
|
||||||
|
id: item.id,
|
||||||
|
iconPath: item.iconPath,
|
||||||
|
latitude: item.latitude,
|
||||||
|
longitude: item.longitude,
|
||||||
|
width: item.width,
|
||||||
|
height: item.height,
|
||||||
|
customCallout: {
|
||||||
|
anchorY: 0, // Y轴偏移量
|
||||||
|
anchorX: 0, // X轴偏移量
|
||||||
|
display: 'ALWAYS' // 一直展示
|
||||||
|
},
|
||||||
|
stationType: item.stationType,
|
||||||
|
stationName: item.stationName,
|
||||||
|
stationCode: item.stationCode,
|
||||||
|
joinCluster: true // 是否参与点聚合
|
||||||
|
};
|
||||||
|
this.markers.push(markerItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.markers = this.markers.filter((item)=>{
|
||||||
|
return item.stationType !== 'livestock'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
/* 样式保持不变 */
|
|
||||||
.bgimg {
|
.bgimg {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
// z-index: -99;
|
// z-index: -99;
|
||||||
|
|
@ -505,7 +471,7 @@
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #FFFFFF;
|
color: #FFFFFF;
|
||||||
text-shadow: 0rpx 1rpx 0rpx rgba(4, 49, 52, 0.55);
|
text-shadow: 0rpx 1rpx 0rpx rgba(4, 49, 52, 0.55);
|
||||||
width: 240rpx;
|
width: 299rpx;
|
||||||
background: rgba(0, 0, 0, 0.52);
|
background: rgba(0, 0, 0, 0.52);
|
||||||
border: 1px solid #4B677C;
|
border: 1px solid #4B677C;
|
||||||
border-radius: 6rpx;
|
border-radius: 6rpx;
|
||||||
|
|
@ -555,4 +521,4 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue