Merge branch 'jixian' into HEAD

This commit is contained in:
wgx 2026-08-13 16:02:27 +08:00
commit 2f87639314
9 changed files with 706 additions and 386 deletions

View File

@ -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' : '1003'
} }
/* /*
if (!token) { // 如果token不存在调用cancel 会取消本次请求但是该函数的catch() 仍会执行 if (!token) { // 如果token不存在调用cancel 会取消本次请求但是该函数的catch() 仍会执行

File diff suppressed because one or more lines are too long

View File

@ -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" : "wxca651c881cfb603f",
"setting" : { "setting" : {
"urlCheck" : false, "urlCheck" : false,
"es6" : true, "es6" : true,

View File

@ -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">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 67 KiB

View File

@ -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>

View File

@ -4,7 +4,7 @@
{ {
"path": "pages/index/index", "path": "pages/index/index",
"style": { "style": {
"navigationBarTitleText": "县小流域面源污染监测", "navigationBarTitleText": "稷山县县小流域面源污染监测",
"navigationStyle": "custom" "navigationStyle": "custom"
} }
}, },

View File

@ -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">

View File

@ -1,34 +1,33 @@
<template> <template>
<view class="container"> <view class="container">
<map id="map" ref="map" style="width: 100%; height: calc(100vh + 50rpx);" :scale="mapScale" :markers="markers" <map id="map" ref="map" style="width: 100%; height: calc(100vh + 50rpx);" scale="13" :markers="markers"
longitude="112.83100231396601" latitude="36.872032399813556" show-location show-compass show-scale longitude="112.83100231396601" latitude="36.872032399813556" show-location show-compass show-scale @markertap="markertap" >
@markertap="markertap">
</map> </map>
<view class="zdxq"> <view class="zdxq">
<view class="zdxqitem" @click="switch2Change('livestock')"> <view class="zdxqitem" @click="switch2Change('livestock')">
<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> </view>
<view class="zdxqitem" @click="switch2Change('orient')"> <view class="zdxqitem" @click="switch2Change('orient')">
<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> </view>
<!-- <view class="zdxqitem" @click="switch2Change('watershed')"> <view class="zdxqitem" @click="switch2Change('watershed')">
<image src="../../static/zhandian_xiaoliuyu_dingwei.png" mode=""></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')"> <view class="zdxqitem" @click="switch2Change('soil')">
<image src="../../static/iconsheturangzs.png" mode=""></image> <image src="../../static/iconsheturangzs.png" mode=""></image>
<view class="textss"> <view class="textss">
长期定位监测点 长期定位监测点
</view> </view>
</view> --> </view>
</view> </view>
</view> </view>
</template> </template>
@ -45,326 +44,187 @@
latitude: 36.5, latitude: 36.5,
longitude: 111.7 longitude: 111.7
}, },
mapScale: 13, scale: 14,
markers: [], markers: [],
markersZIndex: 1, markersZIndex: 1,
lastTap: '', lastTap: '',
stationList: [], stationList: [],
cusLocationList: [], cusLocationList: [],
soilStationList: [], soilStationList: [],
allStationList: [], allStationList: [],
stationTwoList: [], stationTwoList: [],
mapCtx: null // mapCtx: null //
}; };
}, },
onLoad() {}, onLoad() {
},
onReady() { onReady() {
// onReady // onReady
this.mapCtx = uni.createMapContext('map', this); this.mapCtx = uni.createMapContext('map', this);
}, },
onShow() { onShow() {
api.checkLogin(() => { api.checkLogin(()=>{
this.$nextTick(() => { this.$nextTick(() => {
this.getList() this.getList()
}) })
}, () => { }, () => {
uni.reLaunch({ uni.reLaunch({
url: '/packDetail/pages/login/login' url:'/packDetail/pages/login/login'
}) })
}) })
}, },
methods: { methods: {
// kaihs
getList() { getList() {
this.markers = [] this.markers = []
this.stationList = [] this.stationList = []
this.cusLocationList = [] this.cusLocationList = []
this.soilStationList = [] this.soilStationList = []
this.allStationList = [] this.allStationList = []
this.stationTwoList = []
this.stationTwoList = []
uni.showLoading({
title: '加载中' uni.showLoading({
}); 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];
this.allStationList.push(...this.stationList); this.allStationList.push(...this.stationList);
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) => { // console.log("stationlist+++++", this.allStationList);
item.id = index; // console.log("stationList+++++", this.stationList);
}); // console.log("cusLocationList+++++", this.cusLocationList);
// console.log("soilStationList+++++", this.soilStationList);
this.issscd = false //stationType: "orient"
this.isssscd = false //stationType: "livestock"
this.isSoilShow = false //stationType: "watershed"
this.allStationList.forEach((item, index) => {
// item.id = index;
this.enterpriseRender(); });
this.stationRender();
this.monitorRender() this.issscd = false
this.isssscd = false
// 使 this.isSoilShow = false
this.ensureAllMarkersVisible(); this.enterpriseRender();//
this.stationRender();//
uni.hideLoading(); this.monitorRender() //
}).catch(err => {
uni.hideLoading(); //
uni.showToast({ setTimeout(() => {
title: '数据加载失败', this.adjustMapToFitAllMarkers();
icon: 'none' }, 500);
});
console.error('加载地图数据失败:', err); uni.hideLoading();
}) })
}, },
ensureAllMarkersVisible() { enterpriseRender() {//
// for (let i = 0; i < this.cusLocationList.length; i++) {
if (!this.mapCtx) { const item = this.cusLocationList[i];
this.mapCtx = uni.createMapContext('map', this); item.iconPath = '/static/qiyeIcon.png';
} item.latitude = Number(item.stationLatitude);
item.longitude = Number(item.stationLongitude);
// item.width = 35;
const validPoints = this.markers item.height = 52;
.filter(item => {
const lat = Number(item.latitude); const markerItem = {
const lng = Number(item.longitude); id: item.id,
return !isNaN(lat) && !isNaN(lng) && lat !== 0 && lng !== 0; iconPath: item.iconPath,
}) latitude: item.latitude,
.map(item => ({ longitude: item.longitude,
latitude: Number(item.latitude), width: item.width,
longitude: Number(item.longitude) height: item.height,
})); customCallout: {
anchorY: 0,
if (validPoints.length === 0) { anchorX: 0,
console.warn('没有有效的坐标点'); display: 'ALWAYS'
// 使 },
if (this.center.latitude && this.center.longitude) { stationType: item.stationType,
this.mapCtx.moveToLocation({ stationName: item.stationName,
latitude: this.center.latitude, stationCode: item.stationCode,
longitude: this.center.longitude, joinCluster: false, //
scale: 10 zIndex: this.markersZIndex,
}); };
} this.markers.push(markerItem);
return; }
} },
stationRender() {//
console.log('有效坐标点数量:', validPoints.length); // this.markers = this.markers.filter(item => item.stationType !== 'orient');
if (!this.issscd) {
// 1使 includePoints for (let i = 0; i < this.stationList.length; i++) {
try { const item = this.stationList[i];
this.mapCtx.includePoints({ item.iconPath = this.baseUrl +'/'+ item.stationIcon;
points: validPoints, item.latitude = Number(item.stationLatitude);
padding: [80, 80, 80, 80], // item.longitude = Number(item.stationLongitude);
success: () => { item.width = 239;
console.log('地图视野调整成功'); item.height = 186;
}, const markerItem = {
fail: (err) => { id: item.id,
console.error('includePoints失败:', err); iconPath: item.iconPath,
// 使 latitude: item.latitude,
this.fallbackAdjustMap(validPoints); longitude: item.longitude,
} width: item.width,
}); height: item.height,
} catch (e) { customCallout: {
console.error('调整地图视野异常:', e); anchorY: 0,
this.fallbackAdjustMap(validPoints); anchorX: 0,
} display: 'ALWAYS'
},
// 2 stationType: item.stationType,
setTimeout(() => { stationName: item.stationName,
if (this.mapCtx) { stationCode: item.stationCode,
try { joinCluster: false, //
this.mapCtx.includePoints({ zIndex: this.markersZIndex + 1,
points: validPoints, };
padding: [80, 80, 80, 80] this.markers.push(markerItem);
});
} catch (e) { }
console.error('第二次调整失败:', e); }
} },
} monitorRender() {//
}, 500); this.soilStationList.forEach((item, index) => {
let iconPath = '';
// 3 let width = 35;
setTimeout(() => { let height = 35;
if (this.mapCtx) { //
try { switch(item.type) {
this.mapCtx.includePoints({ case 'soil':
points: validPoints, iconPath = this.baseUrl + '/icon/device/soil.png';
padding: [120, 100, 100, 100] width = 32;
}); height = 47;
} catch (e) { break;
console.error('第三次调整失败:', e); case 'camera':
} iconPath = this.baseUrl + '/icon/device/cam.png';
} width = 45;
}, 1000); height = 45;
}, break;
fallbackAdjustMap(validPoints) { default:
if (!validPoints || validPoints.length === 0) return; iconPath = this.baseUrl + '/icon/device/default.png';
}
try { const markerItem = {
// id: item.id,
const lats = validPoints.map(p => p.latitude); iconPath: iconPath,
const lngs = validPoints.map(p => p.longitude); latitude: Number(item.latitude),
longitude: Number(item.longitude),
const minLat = Math.min(...lats); width: width,
const maxLat = Math.max(...lats); height: height,
const minLng = Math.min(...lngs); customCallout: {
const maxLng = Math.max(...lngs); anchorY: 0,
anchorX: 0,
// display: 'ALWAYS'
const centerLat = (minLat + maxLat) / 2; },
const centerLng = (minLng + maxLng) / 2; stationType: 'device',
stationName: item.name,
// stationCode: item.ids,
const latDiff = maxLat - minLat; deviceType: item.type,
const lngDiff = maxLng - minLng; joinCluster: false, //
const maxDiff = Math.max(latDiff, lngDiff); zIndex: this.markersZIndex,
};
let scale = 13; this.markers.push(markerItem);
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);
});
}, },
markertap(e) { markertap(e) {
const index = e.detail.markerId const index = e.detail.markerId
@ -381,69 +241,69 @@
} }
} }
}, },
switch2Change(name) { // switch2Change(name) {//
// //
let that = this; //:xuqin nongtian xiaoliuyu turang
if (name === that.lastTap) { let that = this;
that.adjustMapToFitAllMarkers(); if(name === that.lastTap){
that.lastTap = ''; that.adjustMapToFitAllMarkers();
} else { that.lastTap = '';
// } else {
that.adjustMapToRegion(name); //
that.lastTap = name; 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'
// });
}
},
} }
} }
</script> </script>