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/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 @@
+
+
+
+
+
+
+
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..77352c4 100644
--- a/pages/maps/index.vue
+++ b/pages/maps/index.vue
@@ -1,34 +1,33 @@
-
@@ -45,326 +44,187 @@
latitude: 36.5,
longitude: 111.7
},
- mapScale: 13,
+ scale: 14,
markers: [],
- markersZIndex: 1,
+ markersZIndex: 1,
lastTap: '',
- stationList: [],
+ stationList: [],
cusLocationList: [],
soilStationList: [],
- allStationList: [],
+ allStationList: [],
stationTwoList: [],
mapCtx: null // 添加地图上下文
};
},
- onLoad() {},
+ onLoad() {
+ },
onReady() {
// 在onReady中初始化地图上下文
this.mapCtx = uni.createMapContext('map', this);
},
onShow() {
- api.checkLogin(() => {
- this.$nextTick(() => {
- this.getList()
- })
- }, () => {
- uni.reLaunch({
- url: '/packDetail/pages/login/login'
- })
- })
+ api.checkLogin(()=>{
+ this.$nextTick(() => {
+ this.getList()
+ })
+ }, () => {
+ uni.reLaunch({
+ url:'/packDetail/pages/login/login'
+ })
+ })
},
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 = []
+
+ 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);
+ // console.log("合并后的stationlist+++++", this.allStationList);
+ // console.log("合并后的stationList+++++", this.stationList);
+ // console.log("合并后的cusLocationList+++++", this.cusLocationList);
+ // console.log("合并后的soilStationList+++++", this.soilStationList);
+ //stationType: "orient" 农田
+ //stationType: "livestock" 畜禽
+ //stationType: "watershed" 小流域
+ this.allStationList.forEach((item, index) => {
+ item.id = index;
+ });
+
+ this.issscd = false
+ this.isssscd = false
+ this.isSoilShow = false
+ this.enterpriseRender();// 企业渲染
+ this.stationRender();// 站点渲染
+ this.monitorRender() // 监测点渲染
+
+ // 延迟执行以确保标记已经添加到地图
+ setTimeout(() => {
+ this.adjustMapToFitAllMarkers();
+ }, 500);
+
+ uni.hideLoading();
+ })
},
- 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);
- },
- 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);
- }
- },
- 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);
- }
- },
-
- 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);
- });
+ enterpriseRender() {//企业点位地图渲染
+ for (let i = 0; i < this.cusLocationList.length; i++) {
+ const item = this.cusLocationList[i];
+ item.iconPath = '/static/qiyeIcon.png';
+ item.latitude = Number(item.stationLatitude);
+ item.longitude = Number(item.stationLongitude);
+ item.width = 35;
+ item.height = 52;
+
+ const markerItem = {
+ id: item.id,
+ iconPath: item.iconPath,
+ latitude: item.latitude,
+ longitude: item.longitude,
+ width: item.width,
+ height: item.height,
+ 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() {// 站房点位置渲染
+ // this.markers = this.markers.filter(item => item.stationType !== 'orient');
+ if (!this.issscd) {
+ for (let i = 0; i < this.stationList.length; i++) {
+ const item = this.stationList[i];
+ item.iconPath = this.baseUrl +'/'+ item.stationIcon;
+ item.latitude = Number(item.stationLatitude);
+ item.longitude = Number(item.stationLongitude);
+ item.width = 239;
+ item.height = 186;
+ const markerItem = {
+ id: item.id,
+ iconPath: item.iconPath,
+ latitude: item.latitude,
+ longitude: item.longitude,
+ width: item.width,
+ height: item.height,
+ customCallout: {
+ anchorY: 0,
+ anchorX: 0,
+ display: 'ALWAYS'
+ },
+ stationType: item.stationType,
+ stationName: item.stationName,
+ stationCode: item.stationCode,
+ joinCluster: false, //点聚合
+ zIndex: this.markersZIndex + 1,
+ };
+ this.markers.push(markerItem);
+
+ }
+ }
+ },
+ monitorRender() {// 监测点位渲染
+ this.soilStationList.forEach((item, index) => {
+ 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,
+ iconPath: iconPath,
+ latitude: Number(item.latitude),
+ longitude: Number(item.longitude),
+ 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
@@ -381,69 +241,69 @@
}
}
},
- switch2Change(name) { // 焦点显示图例
+ switch2Change(name) {// 焦点显示图例
// 更新对应区域的状态
- let that = this;
- if (name === that.lastTap) {
- that.adjustMapToFitAllMarkers();
- that.lastTap = '';
- } else {
- // 聚焦到特定区域
- that.adjustMapToRegion(name);
- that.lastTap = name;
+ //四种监测站:xuqin nongtian xiaoliuyu turang
+ let that = this;
+ if(name === that.lastTap){
+ that.adjustMapToFitAllMarkers();
+ that.lastTap = '';
+ } else {
+ // 聚焦到特定区域
+ that.adjustMapToRegion(name);
+ that.lastTap = name;
+ // 或者使用更精确的方法:this.preciseMapAdjustment(name);
- }
- },
- // 调整地图视野以包含所有标记点(类似setFitView效果)
- adjustMapToFitAllMarkers() {
- 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) {
- // 调整地图视野到特定区域的标记点
- //stationType: "orient" 农田
- //stationType: "livestock" 畜禽
- //stationType: "watershed" 小流域
- let that = this;
- let points = [];
- let markers = [];
- 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++);
- return {
- latitude: Number(item.latitude || item.stationLatitude),
- longitude: Number(item.longitude || item.stationLongitude)
- }
- });
- }
- if (points.length > 0 && this.mapCtx) {
- this.mapCtx.includePoints({
- points: points,
- padding: [80, 110, 80, 110] // 增加边距以获得更好的显示效果
- });
- } else if (points.length === 0) {
- // 如果没有找到对应的标记点,显示提示
- // uni.showToast({
- // title: `未找到${regionName}相关的监测点`,
- // icon: 'none'
- // });
- }
+ }
},
+ // 调整地图视野以包含所有标记点(类似setFitView效果)
+ adjustMapToFitAllMarkers() {
+ 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) {
+ // 调整地图视野到特定区域的标记点
+ //stationType: "orient" 农田
+ //stationType: "livestock" 畜禽
+ //stationType: "watershed" 小流域
+ let that = this;
+ let points = [];
+ let markers = [];
+ that.markersZIndex ++;
+ that.markersZIndex ++;
+ 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;
+ return {
+ latitude: Number(item.latitude || item.stationLatitude),
+ longitude: Number(item.longitude || item.stationLongitude)
+ }});
+ }
+ if (points.length > 0 && this.mapCtx) {
+ this.mapCtx.includePoints({
+ points: points,
+ padding: [80, 110, 80, 110] // 增加边距以获得更好的显示效果
+ });
+ } else if (points.length === 0) {
+ // 如果没有找到对应的标记点,显示提示
+ // uni.showToast({
+ // title: `未找到${regionName}相关的监测点`,
+ // icon: 'none'
+ // });
+ }
+ },
}
}