From d2194a55c832469d5f47dc852c67d9baf3980a33 Mon Sep 17 00:00:00 2001
From: wgx <31655391@qq.com>
Date: Wed, 29 Jul 2026 15:39:28 +0800
Subject: [PATCH 1/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=99=BB=E5=BD=95?=
=?UTF-8?q?=E3=80=81=E4=BC=98=E5=8C=96=E5=9B=BE=E7=89=87=E5=8A=A0=E8=BD=BD?=
=?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=AD=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 25 +-
components/my-icon/my-icon.vue | 460 +++++++++++++++++++++++++++++++++
2 files changed, 483 insertions(+), 2 deletions(-)
create mode 100644 components/my-icon/my-icon.vue
diff --git a/.gitignore b/.gitignore
index d6212fc..403adbc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,23 @@
-/unpackage/
-/.idea/
+.DS_Store
+node_modules
+/dist
+
+
+# local env files
+.env.local
+.env.*.local
+
+# Log files
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+
+# Editor directories and files
+.idea
+.vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?
diff --git a/components/my-icon/my-icon.vue b/components/my-icon/my-icon.vue
new file mode 100644
index 0000000..317de3f
--- /dev/null
+++ b/components/my-icon/my-icon.vue
@@ -0,0 +1,460 @@
+
+
+
+
+
+
+
From 314b87149311e63ff630d7a3bc4c70558411a030 Mon Sep 17 00:00:00 2001
From: wgx <31655391@qq.com>
Date: Wed, 29 Jul 2026 15:40:09 +0800
Subject: [PATCH 2/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=99=BB=E5=BD=95?=
=?UTF-8?q?=E3=80=81=E4=BC=98=E5=8C=96=E5=9B=BE=E7=89=87=E5=8A=A0=E8=BD=BD?=
=?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=AD=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 403adbc..3806f96 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
node_modules
/dist
+/unpackage
# local env files
.env.local
From 246f34358c6f57284acedc7e0ce1443c1a916726 Mon Sep 17 00:00:00 2001
From: "978184212@qq.com" <978184212@qq.com>
Date: Thu, 30 Jul 2026 17:02:24 +0800
Subject: [PATCH 3/6] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E5=86=85=E5=AE=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/maps/index.vue | 39 ++++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/pages/maps/index.vue b/pages/maps/index.vue
index 77352c4..f569ccb 100644
--- a/pages/maps/index.vue
+++ b/pages/maps/index.vue
@@ -187,26 +187,31 @@
monitorRender() {// 监测点位渲染
this.soilStationList.forEach((item, index) => {
let iconPath = '';
- let width = 35;
- let height = 35;
+ let width = 32;
+ let height = 47;
// 根据设备类型设置不同的图标
- 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';
- }
+ // 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;
+ // case '10_flowmeter':
+ // iconPath = this.baseUrl + '/icon/device/liuliang.png';
+ // width = 45;
+ // height = 45;
+ // break;
+ // default:
+ // iconPath = this.baseUrl + '/icon/device/default.png';
+ // }
const markerItem = {
id: item.id,
- iconPath: iconPath,
+ iconPath: this.baseUrl +'/' + item.mapIcon,
latitude: Number(item.latitude),
longitude: Number(item.longitude),
width: width,
From bbf08640b4d088a2a66bc9465ed5c9fc041961c2 Mon Sep 17 00:00:00 2001
From: "978184212@qq.com" <978184212@qq.com>
Date: Fri, 7 Aug 2026 15:10:51 +0800
Subject: [PATCH 4/6] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E7=89=88=E6=B5=8B?=
=?UTF-8?q?=E8=AF=95=E5=88=86=E6=94=AF=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pages.json b/pages.json
index 8e543a9..f975f36 100644
--- a/pages.json
+++ b/pages.json
@@ -4,7 +4,7 @@
{
"path": "pages/index/index",
"style": {
- "navigationBarTitleText": "汾西小流域面源污染监测",
+ "navigationBarTitleText": "稷山小流域面源污染监测",
"navigationStyle": "custom"
}
},
From 6f4f11be3ad0155a431a4c9e89e3f1a0ad85ed1c Mon Sep 17 00:00:00 2001
From: "978184212@qq.com" <978184212@qq.com>
Date: Fri, 7 Aug 2026 18:13:29 +0800
Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=86=E8=8A=82?=
=?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
manifest.json | 4 ++--
packDetail/pages/login/login.vue | 2 +-
packDetail1/pages/about/index.vue | 2 +-
pages.json | 2 +-
pages/index/index.vue | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/manifest.json b/manifest.json
index 719d0a2..b71972f 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,5 +1,5 @@
{
- "name" : "汾西小流域面源污染监测",
+ "name" : "稷山面源污染监测",
"appid" : "__UNI__44A8AB0",
"description" : "",
"versionName" : "2.2.22",
@@ -84,7 +84,7 @@
"quickapp" : {},
/* 快应用特有相关 */
"mp-weixin" : {
- "appid" : "wx54f76f700fe3a498",
+ "appid" : "wxca651c881cfb603f",
"setting" : {
"urlCheck" : false,
"es6" : true,
diff --git a/packDetail/pages/login/login.vue b/packDetail/pages/login/login.vue
index ab13469..b3e62b1 100644
--- a/packDetail/pages/login/login.vue
+++ b/packDetail/pages/login/login.vue
@@ -35,7 +35,7 @@
- Copyright © 汾西县农业农村局
+ Copyright © 稷山县农业农村局
- Copyright © 汾西县农业农村局
+ Copyright © 稷山县农业农村局
diff --git a/pages.json b/pages.json
index f975f36..fc74cd9 100644
--- a/pages.json
+++ b/pages.json
@@ -4,7 +4,7 @@
{
"path": "pages/index/index",
"style": {
- "navigationBarTitleText": "稷山小流域面源污染监测",
+ "navigationBarTitleText": "稷山面源污染监测",
"navigationStyle": "custom"
}
},
diff --git a/pages/index/index.vue b/pages/index/index.vue
index ccf26a6..0f39ebb 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -1,6 +1,6 @@
-
+
From eae52816825342acd2310bc9b373807f87e96550 Mon Sep 17 00:00:00 2001
From: "978184212@qq.com" <978184212@qq.com>
Date: Wed, 12 Aug 2026 18:54:14 +0800
Subject: [PATCH 6/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=A1=B5=E9=9D=A2?=
=?UTF-8?q?=E5=86=85=E5=AE=B9=EF=BC=8C=E6=8F=90=E4=BA=A4=E5=88=87=E6=8D=A2?=
=?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=90=8E=E7=9A=84=E7=AC=AC=E4=B8=80=E7=89=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
common/service/service.js | 2 +-
manifest.json | 4 +-
packDetail/pages/login/login.vue | 2 +-
packDetail/static/dls.jpg | Bin 65738 -> 68338 bytes
packDetail1/pages/about/index.vue | 2 +-
pages.json | 2 +-
pages/index/index.vue | 2 +-
pages/maps/index.vue | 822 ++++++++++++++++++------------
8 files changed, 499 insertions(+), 337 deletions(-)
diff --git a/common/service/service.js b/common/service/service.js
index 2660df0..584488a 100644
--- a/common/service/service.js
+++ b/common/service/service.js
@@ -48,7 +48,7 @@ http.interceptor.request((config, cancel) => { /* 请求之前拦截器 */
'app-id' : uni.getAccountInfoSync().miniProgram.appId,
"client-type" : "MA",
'third-session' : uni.getStorageSync('third_session')||'123',
- 'X-Tenant-Id' : '1002'
+ 'X-Tenant-Id' : '1003'
}
/*
if (!token) { // 如果token不存在,调用cancel 会取消本次请求,但是该函数的catch() 仍会执行
diff --git a/manifest.json b/manifest.json
index 236dc4b..28dcf2a 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,5 +1,5 @@
{
- "name" : "吉县面源污染监测平台",
+ "name" : "稷山县县面源污染监测平台",
"appid" : "__UNI__A58A5D7",
"description" : "",
"versionName" : "2.2.22",
@@ -84,7 +84,7 @@
"quickapp" : {},
/* 快应用特有相关 */
"mp-weixin" : {
- "appid" : "wxc078890f8668ed2e",
+ "appid" : "wxca651c881cfb603f",
"setting" : {
"urlCheck" : false,
"es6" : true,
diff --git a/packDetail/pages/login/login.vue b/packDetail/pages/login/login.vue
index 63ff5a7..04ae7ea 100644
--- a/packDetail/pages/login/login.vue
+++ b/packDetail/pages/login/login.vue
@@ -35,7 +35,7 @@
- Copyright © 吉县现代农业发展中心
+ Copyright © 稷山县县现代农业发展中心
- Copyright © 吉县现代农业发展中心
+ Copyright © 稷山县县现代农业发展中心
diff --git a/pages.json b/pages.json
index 6baf09a..a4e49a2 100644
--- a/pages.json
+++ b/pages.json
@@ -4,7 +4,7 @@
{
"path": "pages/index/index",
"style": {
- "navigationBarTitleText": "吉县小流域面源污染监测",
+ "navigationBarTitleText": "稷山县县小流域面源污染监测",
"navigationStyle": "custom"
}
},
diff --git a/pages/index/index.vue b/pages/index/index.vue
index a4311ee..d641f17 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -1,6 +1,6 @@
-
+
diff --git a/pages/maps/index.vue b/pages/maps/index.vue
index 21daf1a..d6ac2bd 100644
--- a/pages/maps/index.vue
+++ b/pages/maps/index.vue
@@ -17,18 +17,55 @@
农田污染监测站
-
+
@@ -54,13 +91,18 @@
soilStationList: [],
allStationList: [],
stationTwoList: [],
- mapCtx: null // 添加地图上下文
-
+ enterpriseList: [],
+ mapCtx: null,
+ showEnterprisePopup: false,
+ currentEnterprise: {},
+ currentMarkerId: null,
+ maxMarkerId: 0,
+ // 添加调试开关
+ debugMode: true
};
},
onLoad() {},
onReady() {
- // 在onReady中初始化地图上下文
this.mapCtx = uni.createMapContext('map', this);
},
onShow() {
@@ -75,326 +117,369 @@
})
},
methods: {
- // kaihs
getList() {
- this.markers = []
- this.stationList = []
- this.cusLocationList = []
- this.soilStationList = []
- this.allStationList = []
- this.stationTwoList = []
-
- uni.showLoading({
- title: '加载中'
- });
-
- this.$http.get('/applet/survStationInfo/stationMap').then(res => {
- // 处理数据
- this.stationList = [...res.data.data.stationInfo];
- this.cusLocationList = [...res.data.data.cusLocation];
- this.soilStationList = [...res.data.data.deviceList];
- this.allStationList.push(...this.stationList);
- this.allStationList.push(...this.cusLocationList);
- this.allStationList.push(...this.soilStationList);
- this.allStationList.forEach((item, index) => {
- item.id = index;
- });
-
- this.issscd = false
- this.isssscd = false
- this.isSoilShow = false
-
- // 渲染所有标记
- this.enterpriseRender();
- this.stationRender();
- this.monitorRender()
-
- // 使用增强的视野调整方法
- this.ensureAllMarkersVisible();
-
- uni.hideLoading();
- }).catch(err => {
- uni.hideLoading();
- uni.showToast({
- title: '数据加载失败',
- icon: 'none'
- });
- console.error('加载地图数据失败:', err);
- })
+ this.markers = []
+ this.stationList = []
+ this.cusLocationList = []
+ this.soilStationList = []
+ this.allStationList = []
+ this.stationTwoList = []
+ this.enterpriseList = []
+
+ uni.showLoading({
+ title: '加载中'
+ });
+
+ // 获取监测站数据
+ this.$http.get('/applet/survStationInfo/stationMap').then(res => {
+ this.stationList = [...res.data.data.stationInfo];
+ this.cusLocationList = [...res.data.data.cusLocation];
+ this.soilStationList = [...res.data.data.deviceList];
+ this.allStationList.push(...this.stationList);
+ this.allStationList.push(...this.cusLocationList);
+ this.allStationList.push(...this.soilStationList);
+ this.allStationList.forEach((item, index) => {
+ item.id = index + 1; // 从1开始
+ });
+
+ this.issscd = false
+ this.isssscd = false
+ this.isSoilShow = false
+
+ // 设置初始最大ID
+ this.maxMarkerId = this.allStationList.length + 1;
+
+ this.enterpriseRender();
+ this.stationRender();
+ this.monitorRender()
+
+ uni.hideLoading();
+ }).catch(err => {
+ uni.hideLoading();
+ uni.showToast({
+ title: '数据加载失败',
+ icon: 'none'
+ });
+ console.error('加载地图数据失败:', err);
+ })
+
+ // 获取企业列表
+ this.$http.get('/applet/wxclient/getEntList').then(res => {
+ if (res.data.data && res.data.data.result) {
+ this.enterpriseList = res.data.data.result;
+ this.renderEnterpriseMarkers();
+ this.ensureAllMarkersVisible();
+ }
+ uni.hideLoading();
+ }).catch(err => {
+ uni.hideLoading();
+ uni.showToast({
+ title: '企业数据加载失败',
+ icon: 'none'
+ });
+ console.error('加载企业数据失败:', err);
+ })
},
- ensureAllMarkersVisible() {
- // 确保地图上下文已初始化
- if (!this.mapCtx) {
- this.mapCtx = uni.createMapContext('map', this);
- }
-
- // 过滤出有效的坐标点
- const validPoints = this.markers
- .filter(item => {
- const lat = Number(item.latitude);
- 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
- });
- }
- return;
- }
-
- console.log('有效坐标点数量:', validPoints.length);
-
- // 方法1:使用 includePoints(优先)
- try {
- this.mapCtx.includePoints({
- points: validPoints,
- padding: [80, 80, 80, 80], // 增加边距让点位不贴边
- 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: [80, 80, 80, 80]
- });
- } catch (e) {
- console.error('第二次调整失败:', e);
- }
- }
- }, 500);
-
- // 方法3:第三次重试(更长的延迟)
- setTimeout(() => {
- if (this.mapCtx) {
- try {
- this.mapCtx.includePoints({
- points: validPoints,
- padding: [120, 100, 100, 100]
- });
- } catch (e) {
- console.error('第三次调整失败:', e);
- }
- }
- }, 1000);
+
+ renderEnterpriseMarkers() {
+ if (!this.enterpriseList || this.enterpriseList.length === 0) {
+ console.warn('企业列表为空');
+ 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);
+ });
+
},
- 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);
- }
+
+ 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;
+ }
+
+
+ if (marker.stationType === 'enterprise') {
+ this.currentEnterprise = marker.enterpriseData || {
+ entName: marker.stationName || '企业名称',
+ entShortName: marker.entShortName || '',
+ entCharge: marker.entCharge || '',
+ entCredit: marker.entCredit || '',
+ entCode: marker.entCode || '',
+ entIntro: marker.entIntro || '暂无简介',
+ entPhone: marker.entPhone || '暂无',
+ createTime: marker.createTime || ''
+ };
+
+ this.currentMarkerId = marker.id;
+ this.showEnterprisePopup = true;
+ return;
+ }
+
+ // 原有的监测站逻辑
+ if (['orient', 'livestock'].includes(marker.stationType)) {
+ uni.navigateTo({
+ url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(marker))}`
+ })
+ } else if (marker.stationType === 'device') {
+ uni.navigateTo({
+ url: `/packDetail/pages/vidio/soilindex`
+ })
+ }
},
+
+ // 关闭企业信息弹窗
+ closePopup() {
+ this.showEnterprisePopup = false;
+ this.currentEnterprise = {};
+ this.currentMarkerId = null;
+ },
+
enterpriseRender() {
- for (let i = 0; i < this.cusLocationList.length; i++) {
- const item = this.cusLocationList[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 || `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);
- }
+ for (let i = 0; i < this.cusLocationList.length; i++) {
+ const item = this.cusLocationList[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: ++this.maxMarkerId,
+ iconPath: '/static/qiyeIcon.png',
+ latitude: lat,
+ longitude: lng,
+ width: 35,
+ height: 52,
+ 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) {
- const index = e.detail.markerId
- const marker = this.markers.find(m => m.id === index);
- if (marker) {
- if (['orient', 'livestock'].includes(marker.stationType)) {
- uni.navigateTo({
- url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(marker))}`
- })
- } else if (marker.stationType === 'device') {
- uni.navigateTo({
- url: `/packDetail/pages/vidio/soilindex`
- })
+ 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: ++this.maxMarkerId,
+ iconPath: this.baseUrl + '/' + item.stationIcon,
+ latitude: lat,
+ longitude: lng,
+ width: 239,
+ height: 186,
+ stationType: item.stationType,
+ stationName: item.stationName,
+ stationCode: item.stationCode,
+ joinCluster: false,
+ zIndex: this.markersZIndex,
+ };
+ this.markers.push(markerItem);
}
}
},
- switch2Change(name) { // 焦点显示图例
- // 更新对应区域的状态
+
+ 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: ++this.maxMarkerId,
+ iconPath: iconPath,
+ latitude: lat,
+ longitude: lng,
+ width: width,
+ height: height,
+ stationType: 'device',
+ stationName: item.name,
+ stationCode: item.ids,
+ deviceType: item.type,
+ joinCluster: false,
+ zIndex: this.markersZIndex,
+ };
+ this.markers.push(markerItem);
+ });
+ },
+
+ ensureAllMarkersVisible() {
+ if (!this.mapCtx) {
+ this.mapCtx = uni.createMapContext('map', this);
+ }
+
+ const validPoints = this.markers
+ .filter(item => {
+ const lat = Number(item.latitude);
+ 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) {
+ 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);
+ }
+ },
+
+ 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;
if (name === that.lastTap) {
that.adjustMapToFitAllMarkers();
that.lastTap = '';
} else {
- // 聚焦到特定区域
that.adjustMapToRegion(name);
that.lastTap = name;
-
}
},
- // 调整地图视野以包含所有标记点(类似setFitView效果)
+
adjustMapToFitAllMarkers() {
if (this.mapCtx && this.markers.length > 0) {
this.mapCtx.includePoints({
@@ -402,26 +487,24 @@
latitude: item.latitude,
longitude: item.longitude
})),
- padding: [60, 60, 60, 60] // 上下左右的边距
+ padding: [60, 60, 60, 60]
});
}
},
+
adjustMapToRegion(regionName) {
- // 调整地图视野到特定区域的标记点
- //stationType: "orient" 农田
- //stationType: "livestock" 畜禽
- //stationType: "watershed" 小流域
let that = this;
let points = [];
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);
} else if (regionName === 'soil') {
- // 获取所有土壤设备标记点
markers = this.markers.filter(item => item.type === 'soil' || item.deviceType === 'soil');
}
- console.log(this.markers)
+
if (markers.length > 0) {
points = markers.map(item => {
item.zIndex = (that.markersZIndex++);
@@ -431,17 +514,12 @@
}
});
}
+
if (points.length > 0 && this.mapCtx) {
this.mapCtx.includePoints({
points: points,
- padding: [80, 110, 80, 110] // 增加边距以获得更好的显示效果
+ padding: [80, 110, 80, 110]
});
- } else if (points.length === 0) {
- // 如果没有找到对应的标记点,显示提示
- // uni.showToast({
- // title: `未找到${regionName}相关的监测点`,
- // icon: 'none'
- // });
}
},
}
@@ -452,7 +530,6 @@
/* 样式保持不变 */
.bgimg {
position: fixed;
- // z-index: -99;
top: 0;
left: 0;
width: 100%;
@@ -466,7 +543,6 @@
font-size: 24rpx;
text-shadow: 1rpx 2rpx 0rpx #0D1934;
font-weight: bold;
- // background-image: url('@/static/zhandian_icon_nongtian_title.png');
background-repeat: no-repeat;
background-size: 100%;
display: flex;
@@ -481,7 +557,6 @@
font-size: 24rpx;
text-shadow: 1rpx 2rpx 0rpx #0D1934;
font-weight: bold;
- // background-image: url('@/static/zhandian_icon_xuqin_title.png');
background-repeat: no-repeat;
background-size: 100%;
display: flex;
@@ -555,4 +630,91 @@
display: flex;
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;
+ }
\ No newline at end of file