Compare commits
No commits in common. "db76832051661f0e2e3dbb11885b4451546592a7" and "e2333f8caa4642b4eda22c266bf11047c98db694" have entirely different histories.
db76832051
...
e2333f8caa
|
|
@ -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' : '1003'
|
'X-Tenant-Id' : '1002'
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
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" : "wxca651c881cfb603f",
|
"appid" : "wxc078890f8668ed2e",
|
||||||
"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">
|
||||||
|
|
@ -196,7 +196,7 @@ export default {
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%);
|
transform: translate(-50%);
|
||||||
color: #999;
|
color: #999;
|
||||||
width: 66%;
|
width: 52%;
|
||||||
}
|
}
|
||||||
.login-paddingtop {
|
.login-paddingtop {
|
||||||
padding-top: 100upx;
|
padding-top: 100upx;
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 64 KiB |
|
|
@ -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">
|
||||||
|
|
@ -80,8 +80,7 @@
|
||||||
<view class="bot_mid">
|
<view class="bot_mid">
|
||||||
<view class="bot_mid_left"
|
<view class="bot_mid_left"
|
||||||
:class="{'bot_mid_lefts':item.type == 2 || item.type == 0}">
|
:class="{'bot_mid_lefts':item.type == 2 || item.type == 0}">
|
||||||
{{ (item.value !== null && item.value !== undefined && item.value !== '' && !isNaN(item.value)) ? item.value + (item.unit || '') : '0' }}
|
{{ (item.value !== null && item.value !== undefined && item.value !== '' && !isNaN(item.value)) ? item.value + (item.unit || '') : '0' }}{{ item.unit }}
|
||||||
<!-- {{ item.unit }} -->
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="bot_rig" v-if="item.times">
|
<view class="bot_rig" v-if="item.times">
|
||||||
|
|
|
||||||
|
|
@ -17,57 +17,20 @@
|
||||||
农田污染监测站
|
农田污染监测站
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="zdxqitem" @click="switch2Change('enterprise')">
|
<!-- <view class="zdxqitem" @click="switch2Change('watershed')">
|
||||||
<image src="../../static/qiyebzIcon.png" mode="" style="width: 40rpx; height: 40rpx;"></image>
|
<image src="../../static/zhandian_xiaoliuyu_dingwei.png" mode=""></image>
|
||||||
<view class="textss">
|
<view class="textss">
|
||||||
企业监测点
|
小流域监测站
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="zdxqitem" @click="switch2Change('soil')">
|
||||||
|
<image src="../../static/iconsheturangzs.png" mode=""></image>
|
||||||
|
<view class="textss">
|
||||||
|
长期定位监测点
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 企业信息弹出框 -->
|
|
||||||
<view class="enterprise-popup" v-if="showEnterprisePopup" @click="closePopup">
|
|
||||||
<view class="popup-content" @click.stop>
|
|
||||||
<view class="popup-header">
|
|
||||||
<text class="popup-title">{{ currentEnterprise.entName || '企业信息' }}</text>
|
|
||||||
<text class="popup-close" @click="closePopup">×</text>
|
|
||||||
</view>
|
|
||||||
<view class="popup-body">
|
|
||||||
<view class="info-item">
|
|
||||||
<text class="label">企业简称:</text>
|
|
||||||
<text class="value">{{ currentEnterprise.entShortName || '-' }}</text>
|
|
||||||
</view>
|
|
||||||
<view class="info-item">
|
|
||||||
<text class="label">负责人:</text>
|
|
||||||
<text class="value">{{ currentEnterprise.entCharge || '-' }}</text>
|
|
||||||
</view>
|
|
||||||
<view class="info-item">
|
|
||||||
<text class="label">统一信用代码:</text>
|
|
||||||
<text class="value">{{ currentEnterprise.entCredit || '-' }}</text>
|
|
||||||
</view>
|
|
||||||
<view class="info-item">
|
|
||||||
<text class="label">企业编号:</text>
|
|
||||||
<text class="value">{{ currentEnterprise.entCode || '-' }}</text>
|
|
||||||
</view>
|
|
||||||
<view class="info-item">
|
|
||||||
<text class="label">企业简介:</text>
|
|
||||||
<text class="value">{{ currentEnterprise.entIntro || '暂无简介' }}</text>
|
|
||||||
</view>
|
|
||||||
<view class="info-item">
|
|
||||||
<text class="label">联系电话:</text>
|
|
||||||
<text class="value">{{ currentEnterprise.entPhone || '暂无' }}</text>
|
|
||||||
</view>
|
|
||||||
<view class="info-item">
|
|
||||||
<text class="label">创建时间:</text>
|
|
||||||
<text class="value">{{ currentEnterprise.createTime || '-' }}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<!-- <view class="popup-footer">
|
|
||||||
<button class="btn-detail" @click="goEnterpriseDetail">查看详情</button>
|
|
||||||
</view> -->
|
</view> -->
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -91,18 +54,13 @@
|
||||||
soilStationList: [],
|
soilStationList: [],
|
||||||
allStationList: [],
|
allStationList: [],
|
||||||
stationTwoList: [],
|
stationTwoList: [],
|
||||||
enterpriseList: [],
|
mapCtx: null // 添加地图上下文
|
||||||
mapCtx: null,
|
|
||||||
showEnterprisePopup: false,
|
|
||||||
currentEnterprise: {},
|
|
||||||
currentMarkerId: null,
|
|
||||||
maxMarkerId: 0,
|
|
||||||
// 添加调试开关
|
|
||||||
debugMode: true
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onLoad() {},
|
onLoad() {},
|
||||||
onReady() {
|
onReady() {
|
||||||
|
// 在onReady中初始化地图上下文
|
||||||
this.mapCtx = uni.createMapContext('map', this);
|
this.mapCtx = uni.createMapContext('map', this);
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
|
|
@ -117,6 +75,7 @@
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// kaihs
|
||||||
getList() {
|
getList() {
|
||||||
this.markers = []
|
this.markers = []
|
||||||
this.stationList = []
|
this.stationList = []
|
||||||
|
|
@ -124,14 +83,13 @@
|
||||||
this.soilStationList = []
|
this.soilStationList = []
|
||||||
this.allStationList = []
|
this.allStationList = []
|
||||||
this.stationTwoList = []
|
this.stationTwoList = []
|
||||||
this.enterpriseList = []
|
|
||||||
|
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '加载中'
|
title: '加载中'
|
||||||
});
|
});
|
||||||
|
|
||||||
// 获取监测站数据
|
|
||||||
this.$http.get('/applet/survStationInfo/stationMap').then(res => {
|
this.$http.get('/applet/survStationInfo/stationMap').then(res => {
|
||||||
|
// 处理数据
|
||||||
this.stationList = [...res.data.data.stationInfo];
|
this.stationList = [...res.data.data.stationInfo];
|
||||||
this.cusLocationList = [...res.data.data.cusLocation];
|
this.cusLocationList = [...res.data.data.cusLocation];
|
||||||
this.soilStationList = [...res.data.data.deviceList];
|
this.soilStationList = [...res.data.data.deviceList];
|
||||||
|
|
@ -139,20 +97,21 @@
|
||||||
this.allStationList.push(...this.cusLocationList);
|
this.allStationList.push(...this.cusLocationList);
|
||||||
this.allStationList.push(...this.soilStationList);
|
this.allStationList.push(...this.soilStationList);
|
||||||
this.allStationList.forEach((item, index) => {
|
this.allStationList.forEach((item, index) => {
|
||||||
item.id = index + 1; // 从1开始
|
item.id = index;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.issscd = false
|
this.issscd = false
|
||||||
this.isssscd = false
|
this.isssscd = false
|
||||||
this.isSoilShow = false
|
this.isSoilShow = false
|
||||||
|
|
||||||
// 设置初始最大ID
|
// 渲染所有标记
|
||||||
this.maxMarkerId = this.allStationList.length + 1;
|
|
||||||
|
|
||||||
this.enterpriseRender();
|
this.enterpriseRender();
|
||||||
this.stationRender();
|
this.stationRender();
|
||||||
this.monitorRender()
|
this.monitorRender()
|
||||||
|
|
||||||
|
// 使用增强的视野调整方法
|
||||||
|
this.ensureAllMarkersVisible();
|
||||||
|
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
|
@ -162,151 +121,153 @@
|
||||||
});
|
});
|
||||||
console.error('加载地图数据失败:', err);
|
console.error('加载地图数据失败:', err);
|
||||||
})
|
})
|
||||||
|
},
|
||||||
// 获取企业列表
|
ensureAllMarkersVisible() {
|
||||||
this.$http.get('/applet/wxclient/getEntList').then(res => {
|
// 确保地图上下文已初始化
|
||||||
if (res.data.data && res.data.data.result) {
|
if (!this.mapCtx) {
|
||||||
this.enterpriseList = res.data.data.result;
|
this.mapCtx = uni.createMapContext('map', this);
|
||||||
this.renderEnterpriseMarkers();
|
|
||||||
this.ensureAllMarkersVisible();
|
|
||||||
}
|
}
|
||||||
uni.hideLoading();
|
|
||||||
}).catch(err => {
|
// 过滤出有效的坐标点
|
||||||
uni.hideLoading();
|
const validPoints = this.markers
|
||||||
uni.showToast({
|
.filter(item => {
|
||||||
title: '企业数据加载失败',
|
const lat = Number(item.latitude);
|
||||||
icon: 'none'
|
const lng = Number(item.longitude);
|
||||||
|
return !isNaN(lat) && !isNaN(lng) && lat !== 0 && lng !== 0;
|
||||||
|
})
|
||||||
|
.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
|
||||||
});
|
});
|
||||||
console.error('加载企业数据失败:', err);
|
}
|
||||||
})
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('有效坐标点数量:', validPoints.length);
|
||||||
|
|
||||||
|
// 方法1:使用 includePoints(优先)
|
||||||
|
try {
|
||||||
|
this.mapCtx.includePoints({
|
||||||
|
points: validPoints,
|
||||||
|
padding: [80, 80, 80, 80], // 增加边距让点位不贴边
|
||||||
|
success: () => {
|
||||||
|
console.log('地图视野调整成功');
|
||||||
},
|
},
|
||||||
|
fail: (err) => {
|
||||||
renderEnterpriseMarkers() {
|
console.error('includePoints失败:', err);
|
||||||
if (!this.enterpriseList || this.enterpriseList.length === 0) {
|
// 如果失败,使用备用方案
|
||||||
console.warn('企业列表为空');
|
this.fallbackAdjustMap(validPoints);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.enterpriseList.forEach((item, index) => {
|
|
||||||
const lat = Number(item.entLat);
|
|
||||||
const lng = Number(item.entLong);
|
|
||||||
|
|
||||||
if (isNaN(lat) || isNaN(lng) || lat === 0 || lng === 0) {
|
|
||||||
console.warn('企业坐标无效:', item.entName, lat, lng);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const markerId = ++this.maxMarkerId;
|
|
||||||
|
|
||||||
let iconPath = '/static/qiyeIcon.png';
|
|
||||||
if (item.entMapIcon) {
|
|
||||||
iconPath = this.baseUrl + '/' + item.entMapIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
const markerItem = {
|
|
||||||
id: markerId,
|
|
||||||
iconPath: iconPath,
|
|
||||||
latitude: lat,
|
|
||||||
longitude: lng,
|
|
||||||
width: 40,
|
|
||||||
height: 50,
|
|
||||||
stationType: 'enterprise',
|
|
||||||
stationName: item.entName,
|
|
||||||
entShortName: item.entShortName,
|
|
||||||
entCharge: item.entCharge,
|
|
||||||
entCredit: item.entCredit,
|
|
||||||
entCode: item.entCode,
|
|
||||||
entIntro: item.entIntro,
|
|
||||||
entPhone: item.entPhone,
|
|
||||||
createTime: item.createTime,
|
|
||||||
entId: item.id,
|
|
||||||
joinCluster: false,
|
|
||||||
zIndex: this.markersZIndex++,
|
|
||||||
enterpriseData: item,
|
|
||||||
// 添加callout显示企业名称
|
|
||||||
callout: {
|
|
||||||
content: item.entName || '企业',
|
|
||||||
color: '#FFFFFF',
|
|
||||||
fontSize: 14,
|
|
||||||
borderRadius: 10,
|
|
||||||
bgColor: '#007AFF',
|
|
||||||
padding: 8,
|
|
||||||
display: 'ALWAYS'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.markers.push(markerItem);
|
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
},
|
console.error('调整地图视野异常:', e);
|
||||||
|
this.fallbackAdjustMap(validPoints);
|
||||||
markertap(e) {
|
|
||||||
const index = e.detail.markerId;
|
|
||||||
// 查找匹配的marker
|
|
||||||
const marker = this.markers.find(m => Number(m.id) === Number(index));
|
|
||||||
|
|
||||||
|
|
||||||
if (!marker) {
|
|
||||||
console.warn('未找到对应的marker, ID:', index);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 方法2:延迟重试(确保地图完全渲染)
|
||||||
if (marker.stationType === 'enterprise') {
|
setTimeout(() => {
|
||||||
this.currentEnterprise = marker.enterpriseData || {
|
if (this.mapCtx) {
|
||||||
entName: marker.stationName || '企业名称',
|
try {
|
||||||
entShortName: marker.entShortName || '',
|
this.mapCtx.includePoints({
|
||||||
entCharge: marker.entCharge || '',
|
points: validPoints,
|
||||||
entCredit: marker.entCredit || '',
|
padding: [80, 80, 80, 80]
|
||||||
entCode: marker.entCode || '',
|
});
|
||||||
entIntro: marker.entIntro || '暂无简介',
|
} catch (e) {
|
||||||
entPhone: marker.entPhone || '暂无',
|
console.error('第二次调整失败:', e);
|
||||||
createTime: marker.createTime || ''
|
|
||||||
};
|
|
||||||
|
|
||||||
this.currentMarkerId = marker.id;
|
|
||||||
this.showEnterprisePopup = true;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
|
||||||
// 原有的监测站逻辑
|
// 方法3:第三次重试(更长的延迟)
|
||||||
if (['orient', 'livestock'].includes(marker.stationType)) {
|
setTimeout(() => {
|
||||||
uni.navigateTo({
|
if (this.mapCtx) {
|
||||||
url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(marker))}`
|
try {
|
||||||
})
|
this.mapCtx.includePoints({
|
||||||
} else if (marker.stationType === 'device') {
|
points: validPoints,
|
||||||
uni.navigateTo({
|
padding: [120, 100, 100, 100]
|
||||||
url: `/packDetail/pages/vidio/soilindex`
|
});
|
||||||
})
|
} catch (e) {
|
||||||
|
console.error('第三次调整失败:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
},
|
||||||
|
fallbackAdjustMap(validPoints) {
|
||||||
|
if (!validPoints || validPoints.length === 0) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 计算所有点位的中心点和范围
|
||||||
|
const lats = validPoints.map(p => p.latitude);
|
||||||
|
const lngs = validPoints.map(p => p.longitude);
|
||||||
|
|
||||||
|
const minLat = Math.min(...lats);
|
||||||
|
const maxLat = Math.max(...lats);
|
||||||
|
const minLng = Math.min(...lngs);
|
||||||
|
const maxLng = Math.max(...lngs);
|
||||||
|
|
||||||
|
// 计算中心点
|
||||||
|
const centerLat = (minLat + maxLat) / 2;
|
||||||
|
const centerLng = (minLng + maxLng) / 2;
|
||||||
|
|
||||||
|
// 计算合适的缩放级别
|
||||||
|
const latDiff = maxLat - minLat;
|
||||||
|
const lngDiff = maxLng - minLng;
|
||||||
|
const maxDiff = Math.max(latDiff, lngDiff);
|
||||||
|
|
||||||
|
let scale = 13;
|
||||||
|
if (maxDiff > 2) scale = 6;
|
||||||
|
else if (maxDiff > 1) scale = 8;
|
||||||
|
else if (maxDiff > 0.5) scale = 10;
|
||||||
|
else if (maxDiff > 0.2) scale = 11;
|
||||||
|
else if (maxDiff > 0.1) scale = 12;
|
||||||
|
else scale = 13;
|
||||||
|
|
||||||
|
console.log('备用方案 - 中心点:', centerLat, centerLng, '缩放:', scale);
|
||||||
|
|
||||||
|
// 移动地图到计算出的中心位置
|
||||||
|
this.mapCtx.moveToLocation({
|
||||||
|
latitude: centerLat,
|
||||||
|
longitude: centerLng,
|
||||||
|
scale: scale
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error('备用方案失败:', e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 关闭企业信息弹窗
|
|
||||||
closePopup() {
|
|
||||||
this.showEnterprisePopup = false;
|
|
||||||
this.currentEnterprise = {};
|
|
||||||
this.currentMarkerId = null;
|
|
||||||
},
|
|
||||||
|
|
||||||
enterpriseRender() {
|
enterpriseRender() {
|
||||||
for (let i = 0; i < this.cusLocationList.length; i++) {
|
for (let i = 0; i < this.cusLocationList.length; i++) {
|
||||||
const item = this.cusLocationList[i];
|
const item = this.cusLocationList[i];
|
||||||
const lat = Number(item.stationLatitude);
|
const lat = Number(item.stationLatitude);
|
||||||
const lng = Number(item.stationLongitude);
|
const lng = Number(item.stationLongitude);
|
||||||
|
|
||||||
|
// 验证坐标有效性
|
||||||
if (isNaN(lat) || isNaN(lng) || lat === 0 || lng === 0) {
|
if (isNaN(lat) || isNaN(lng) || lat === 0 || lng === 0) {
|
||||||
console.warn('企业点位坐标无效:', item.stationName, lat, lng);
|
console.warn('企业点位坐标无效:', item.stationName, lat, lng);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const markerItem = {
|
const markerItem = {
|
||||||
id: ++this.maxMarkerId,
|
id: item.id || `enterprise_${i}`,
|
||||||
iconPath: '/static/qiyeIcon.png',
|
iconPath: '/static/qiyeIcon.png',
|
||||||
latitude: lat,
|
latitude: lat,
|
||||||
longitude: lng,
|
longitude: lng,
|
||||||
width: 35,
|
width: 35,
|
||||||
height: 52,
|
height: 52,
|
||||||
|
customCallout: {
|
||||||
|
anchorY: 0,
|
||||||
|
anchorX: 0,
|
||||||
|
display: 'ALWAYS'
|
||||||
|
},
|
||||||
stationType: item.stationType,
|
stationType: item.stationType,
|
||||||
stationName: item.stationName,
|
stationName: item.stationName,
|
||||||
stationCode: item.stationCode,
|
stationCode: item.stationCode,
|
||||||
|
|
@ -324,18 +285,24 @@
|
||||||
const lat = Number(item.stationLatitude);
|
const lat = Number(item.stationLatitude);
|
||||||
const lng = Number(item.stationLongitude);
|
const lng = Number(item.stationLongitude);
|
||||||
|
|
||||||
|
// 验证坐标有效性
|
||||||
if (isNaN(lat) || isNaN(lng) || lat === 0 || lng === 0) {
|
if (isNaN(lat) || isNaN(lng) || lat === 0 || lng === 0) {
|
||||||
console.warn('站房点位坐标无效:', item.stationName, lat, lng);
|
console.warn('站房点位坐标无效:', item.stationName, lat, lng);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const markerItem = {
|
const markerItem = {
|
||||||
id: ++this.maxMarkerId,
|
id: item.id || `station_${i}`,
|
||||||
iconPath: this.baseUrl + '/' + item.stationIcon,
|
iconPath: this.baseUrl + '/' + item.stationIcon,
|
||||||
latitude: lat,
|
latitude: lat,
|
||||||
longitude: lng,
|
longitude: lng,
|
||||||
width: 239,
|
width: 239,
|
||||||
height: 186,
|
height: 186,
|
||||||
|
customCallout: {
|
||||||
|
anchorY: 0,
|
||||||
|
anchorX: 0,
|
||||||
|
display: 'ALWAYS'
|
||||||
|
},
|
||||||
stationType: item.stationType,
|
stationType: item.stationType,
|
||||||
stationName: item.stationName,
|
stationName: item.stationName,
|
||||||
stationCode: item.stationCode,
|
stationCode: item.stationCode,
|
||||||
|
|
@ -352,6 +319,7 @@
|
||||||
const lat = Number(item.latitude);
|
const lat = Number(item.latitude);
|
||||||
const lng = Number(item.longitude);
|
const lng = Number(item.longitude);
|
||||||
|
|
||||||
|
// 验证坐标有效性
|
||||||
if (isNaN(lat) || isNaN(lng) || lat === 0 || lng === 0) {
|
if (isNaN(lat) || isNaN(lng) || lat === 0 || lng === 0) {
|
||||||
console.warn('监测点位坐标无效:', item.name, lat, lng);
|
console.warn('监测点位坐标无效:', item.name, lat, lng);
|
||||||
return;
|
return;
|
||||||
|
|
@ -377,12 +345,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const markerItem = {
|
const markerItem = {
|
||||||
id: ++this.maxMarkerId,
|
id: item.id || `device_${index}`,
|
||||||
iconPath: iconPath,
|
iconPath: iconPath,
|
||||||
latitude: lat,
|
latitude: lat,
|
||||||
longitude: lng,
|
longitude: lng,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
|
customCallout: {
|
||||||
|
anchorY: 0,
|
||||||
|
anchorX: 0,
|
||||||
|
display: 'ALWAYS'
|
||||||
|
},
|
||||||
stationType: 'device',
|
stationType: 'device',
|
||||||
stationName: item.name,
|
stationName: item.name,
|
||||||
stationCode: item.ids,
|
stationCode: item.ids,
|
||||||
|
|
@ -393,93 +366,35 @@
|
||||||
this.markers.push(markerItem);
|
this.markers.push(markerItem);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
markertap(e) {
|
||||||
ensureAllMarkersVisible() {
|
const index = e.detail.markerId
|
||||||
if (!this.mapCtx) {
|
const marker = this.markers.find(m => m.id === index);
|
||||||
this.mapCtx = uni.createMapContext('map', this);
|
if (marker) {
|
||||||
}
|
if (['orient', 'livestock'].includes(marker.stationType)) {
|
||||||
|
uni.navigateTo({
|
||||||
const validPoints = this.markers
|
url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(marker))}`
|
||||||
.filter(item => {
|
})
|
||||||
const lat = Number(item.latitude);
|
} else if (marker.stationType === 'device') {
|
||||||
const lng = Number(item.longitude);
|
uni.navigateTo({
|
||||||
return !isNaN(lat) && !isNaN(lng) && lat !== 0 && lng !== 0;
|
url: `/packDetail/pages/vidio/soilindex`
|
||||||
})
|
})
|
||||||
.map(item => ({
|
|
||||||
latitude: Number(item.latitude),
|
|
||||||
longitude: Number(item.longitude)
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (validPoints.length === 0) {
|
|
||||||
if (this.center.latitude && this.center.longitude) {
|
|
||||||
this.mapCtx.moveToLocation({
|
|
||||||
latitude: this.center.latitude,
|
|
||||||
longitude: this.center.longitude,
|
|
||||||
scale: 10
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.mapCtx.includePoints({
|
|
||||||
points: validPoints,
|
|
||||||
padding: [80, 80, 80, 80]
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
console.error('调整地图视野异常:', e);
|
|
||||||
this.fallbackAdjustMap(validPoints);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
switch2Change(name) { // 焦点显示图例
|
||||||
fallbackAdjustMap(validPoints) {
|
// 更新对应区域的状态
|
||||||
if (!validPoints || validPoints.length === 0) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const lats = validPoints.map(p => p.latitude);
|
|
||||||
const lngs = validPoints.map(p => p.longitude);
|
|
||||||
|
|
||||||
const minLat = Math.min(...lats);
|
|
||||||
const maxLat = Math.max(...lats);
|
|
||||||
const minLng = Math.min(...lngs);
|
|
||||||
const maxLng = Math.max(...lngs);
|
|
||||||
|
|
||||||
const centerLat = (minLat + maxLat) / 2;
|
|
||||||
const centerLng = (minLng + maxLng) / 2;
|
|
||||||
|
|
||||||
const latDiff = maxLat - minLat;
|
|
||||||
const lngDiff = maxLng - minLng;
|
|
||||||
const maxDiff = Math.max(latDiff, lngDiff);
|
|
||||||
|
|
||||||
let scale = 13;
|
|
||||||
if (maxDiff > 2) scale = 6;
|
|
||||||
else if (maxDiff > 1) scale = 8;
|
|
||||||
else if (maxDiff > 0.5) scale = 10;
|
|
||||||
else if (maxDiff > 0.2) scale = 11;
|
|
||||||
else if (maxDiff > 0.1) scale = 12;
|
|
||||||
else scale = 13;
|
|
||||||
|
|
||||||
this.mapCtx.moveToLocation({
|
|
||||||
latitude: centerLat,
|
|
||||||
longitude: centerLng,
|
|
||||||
scale: scale
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
console.error('备用方案失败:', e);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
switch2Change(name) {
|
|
||||||
let that = this;
|
let that = this;
|
||||||
if (name === that.lastTap) {
|
if (name === that.lastTap) {
|
||||||
that.adjustMapToFitAllMarkers();
|
that.adjustMapToFitAllMarkers();
|
||||||
that.lastTap = '';
|
that.lastTap = '';
|
||||||
} else {
|
} else {
|
||||||
|
// 聚焦到特定区域
|
||||||
that.adjustMapToRegion(name);
|
that.adjustMapToRegion(name);
|
||||||
that.lastTap = name;
|
that.lastTap = name;
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 调整地图视野以包含所有标记点(类似setFitView效果)
|
||||||
adjustMapToFitAllMarkers() {
|
adjustMapToFitAllMarkers() {
|
||||||
if (this.mapCtx && this.markers.length > 0) {
|
if (this.mapCtx && this.markers.length > 0) {
|
||||||
this.mapCtx.includePoints({
|
this.mapCtx.includePoints({
|
||||||
|
|
@ -487,24 +402,26 @@
|
||||||
latitude: item.latitude,
|
latitude: item.latitude,
|
||||||
longitude: item.longitude
|
longitude: item.longitude
|
||||||
})),
|
})),
|
||||||
padding: [60, 60, 60, 60]
|
padding: [60, 60, 60, 60] // 上下左右的边距
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
adjustMapToRegion(regionName) {
|
adjustMapToRegion(regionName) {
|
||||||
|
// 调整地图视野到特定区域的标记点
|
||||||
|
//stationType: "orient" 农田
|
||||||
|
//stationType: "livestock" 畜禽
|
||||||
|
//stationType: "watershed" 小流域
|
||||||
let that = this;
|
let that = this;
|
||||||
let points = [];
|
let points = [];
|
||||||
let markers = [];
|
let markers = [];
|
||||||
|
if (regionName === 'orient' || regionName === 'livestock' || regionName === 'watershed') {
|
||||||
if (regionName === 'enterprise') {
|
// 获取团柏河区域的所有标记点
|
||||||
markers = this.markers.filter(item => item.stationType === 'enterprise');
|
|
||||||
} else if (regionName === 'orient' || regionName === 'livestock' || regionName === 'watershed') {
|
|
||||||
markers = this.markers.filter(item => item.stationType === regionName);
|
markers = this.markers.filter(item => item.stationType === regionName);
|
||||||
} else if (regionName === 'soil') {
|
} else if (regionName === 'soil') {
|
||||||
|
// 获取所有土壤设备标记点
|
||||||
markers = this.markers.filter(item => item.type === 'soil' || item.deviceType === 'soil');
|
markers = this.markers.filter(item => item.type === 'soil' || item.deviceType === 'soil');
|
||||||
}
|
}
|
||||||
|
console.log(this.markers)
|
||||||
if (markers.length > 0) {
|
if (markers.length > 0) {
|
||||||
points = markers.map(item => {
|
points = markers.map(item => {
|
||||||
item.zIndex = (that.markersZIndex++);
|
item.zIndex = (that.markersZIndex++);
|
||||||
|
|
@ -514,12 +431,17 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (points.length > 0 && this.mapCtx) {
|
if (points.length > 0 && this.mapCtx) {
|
||||||
this.mapCtx.includePoints({
|
this.mapCtx.includePoints({
|
||||||
points: points,
|
points: points,
|
||||||
padding: [80, 110, 80, 110]
|
padding: [80, 110, 80, 110] // 增加边距以获得更好的显示效果
|
||||||
});
|
});
|
||||||
|
} else if (points.length === 0) {
|
||||||
|
// 如果没有找到对应的标记点,显示提示
|
||||||
|
// uni.showToast({
|
||||||
|
// title: `未找到${regionName}相关的监测点`,
|
||||||
|
// icon: 'none'
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -530,6 +452,7 @@
|
||||||
/* 样式保持不变 */
|
/* 样式保持不变 */
|
||||||
.bgimg {
|
.bgimg {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
// z-index: -99;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
@ -543,6 +466,7 @@
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
text-shadow: 1rpx 2rpx 0rpx #0D1934;
|
text-shadow: 1rpx 2rpx 0rpx #0D1934;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
// background-image: url('@/static/zhandian_icon_nongtian_title.png');
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-size: 100%;
|
background-size: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
@ -557,6 +481,7 @@
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
text-shadow: 1rpx 2rpx 0rpx #0D1934;
|
text-shadow: 1rpx 2rpx 0rpx #0D1934;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
// background-image: url('@/static/zhandian_icon_xuqin_title.png');
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-size: 100%;
|
background-size: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
@ -630,91 +555,4 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 企业信息弹窗样式 */
|
|
||||||
.enterprise-popup {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
background: rgba(0, 0, 0, 0.6);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
z-index: 9999;
|
|
||||||
}
|
|
||||||
|
|
||||||
.popup-content {
|
|
||||||
width: 600rpx;
|
|
||||||
max-height: 70vh;
|
|
||||||
background: #FFFFFF;
|
|
||||||
border-radius: 20rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.popup-header {
|
|
||||||
padding: 30rpx 30rpx 20rpx;
|
|
||||||
border-bottom: 1px solid #eee;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.popup-title {
|
|
||||||
font-size: 34rpx;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #333;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.popup-close {
|
|
||||||
font-size: 48rpx;
|
|
||||||
color: #999;
|
|
||||||
padding: 0 10rpx;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.popup-body {
|
|
||||||
padding: 20rpx 30rpx;
|
|
||||||
overflow-y: auto;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.info-item {
|
|
||||||
display: flex;
|
|
||||||
padding: 12rpx 0;
|
|
||||||
font-size: 28rpx;
|
|
||||||
border-bottom: 1px solid #f5f5f5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.info-item .label {
|
|
||||||
color: #666;
|
|
||||||
width: 160rpx;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.info-item .value {
|
|
||||||
color: #333;
|
|
||||||
flex: 1;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
|
|
||||||
.popup-footer {
|
|
||||||
padding: 20rpx 30rpx 30rpx;
|
|
||||||
border-top: 1px solid #eee;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-detail {
|
|
||||||
width: 100%;
|
|
||||||
height: 80rpx;
|
|
||||||
line-height: 80rpx;
|
|
||||||
background: #007AFF;
|
|
||||||
color: #FFFFFF;
|
|
||||||
font-size: 30rpx;
|
|
||||||
border-radius: 40rpx;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
Loading…
Reference in New Issue