修改河津的测试bug

This commit is contained in:
978184212@qq.com 2026-08-20 18:48:46 +08:00
parent 8350978c5e
commit 1337f99702
8 changed files with 287 additions and 322 deletions

View File

@ -1,5 +1,5 @@
{
"name" : "河津市农业面源污染监测系统",
"name" : "农业面源污染监测系统",
"appid" : "__UNI__A58A5D7",
"description" : "",
"versionName" : "2.2.22",

View File

@ -291,6 +291,7 @@
this.livelist = res.data.data.liveSurvData
this.stinklist = res.data.data.stinkSurvData
this.survCamera = res.data.data.survCamera
this.survItemList = res.data.data.stationInfo.survColorItems
}
uni.hideLoading();
})

View File

@ -8,8 +8,8 @@
<view class="list_item" v-for="(item,index) in List" :key="index" @click="todetail(item,index)">
<view class="list_item_top">
<view class="list_item_left">
<image v-if="item.stationType == 'livestock1'" src="../../static/zhandian_icon_xuqin.png" mode=""></image>
<image v-else-if="item.stationType == 'watershed1'" src="../../static/zhandian_icon_xuqin.png" mode=""></image>
<image v-if="item.stationType == 'livestock'" src="../../static/zhandian_icon_xuqin.png" mode=""></image>
<image v-else-if="item.stationType == 'watershed'" src="../../static/zhandian_icon_xuqin.png" mode=""></image>
<image v-else src="../../static/zd.png" mode=""></image>
<view class="item_right" v-if="item.stationName">
<view class="right_top">

View File

@ -91,37 +91,22 @@
this.getList()
},
methods:{
getList(){
getList() {
uni.showLoading({
title: '加载中'
});
// 使 Promise.all
Promise.all([
this.$http.get('/applet/survStationInfo/deviceList'),
this.$http.get('/applet/survStationInfo/fdeviceList')
]).then(([res1, res2]) => {
const data1 = res1?.data?.data || [];
//
let data2 = [];
if (res2?.data?.data && Array.isArray(res2.data.data) && res2.data.data.length > 0) {
data2 = res2.data.data[0] || [];
}
// data2
this.list = data2.length > 0 ? data1.concat(data2) : data1;
// 便
if (data2.length === 0) {
console.log('第二个接口无数据,跳过合并');
}
uni.hideLoading();
}).catch(error => {
console.error('请求失败:', error);
uni.hideLoading();
});
//
this.$http.get('/applet/survStationInfo/deviceList')
.then(res => {
const data1 = res?.data?.data || [];
this.list = data1;
uni.hideLoading();
})
.catch(error => {
console.error('请求失败:', error);
uni.hideLoading();
});
},
todetail(item,index){
uni.navigateTo({

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

@ -4,7 +4,7 @@
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "河津市农业面源污染监测系统",
"navigationBarTitleText": "农业面源污染监测系统",
"navigationStyle": "custom"
}
},

View File

@ -1,6 +1,6 @@
<template>
<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>
<scroll-view class="content" scroll-y="true" :style="{height:contentheight + 'rpx'}">
<view class="top_address">

View File

@ -1,5 +1,6 @@
<template>
<view class="container">
<!-- <image src="../../static/zddt.jpg" mode="" class="bgimg" @click="todetail()"></image> -->
<map id="map" style="width: 100%; height:2000rpx;" scale="13" :markers="markers" longitude="110.628279"
latitude="35.546105" show-location @markertap="markertap" @callouttap="callouttap">
<cover-view slot="callout">
@ -40,6 +41,11 @@
<view class="crildon" :style="!isssscd?'background:#00ff37':'background: #ccc;'"></view>
</view>
</view>
<!-- <view class="switchs" :defaultSwitch="isscd">-->
<!-- <selectSwitch @change="switch1Change" :defaultSwitch="isscd" checked_bj_color="#13ce66"/>-->
<!-- <switch style="margin-right: 10rpx;" :checked="isscd" @change="switch1Change" />-->
<!-- &lt;!&ndash; 显示/隐藏杀虫灯 &ndash;&gt;-->
<!-- </view>-->
</view>
</template>
@ -66,17 +72,15 @@
stationInfo: [],
pestlightMarker: null,
stationlist: [],
timerSet: null,
//
mapContext: null,
clusterMarkerIds: [], // marker id
isClusterInited: false //
timerSet: null
};
},
onLoad() {
this.$nextTick(() => {
this.getList()
})
// this.isscd = true
// this.getList()
this.$nextTick(() => {
this.getList()
})
},
onShow() {
var that = this
@ -92,10 +96,14 @@
console.log(res, 165)
if (res.data.code == 0) {
let userInfo = res.data.data;
// uni.setStorageSync('third_session', userInfo.thirdSession);
if (!userInfo.id) {
uni.reLaunch({
url: '/packDetail/pages/login/login'
})
} else {
// that.isscd = true
//
}
}
})
@ -106,137 +114,13 @@
url: '/pages/loginindex'
})
}
},
onReady() {
//
this.mapContext = uni.createMapContext("map", this);
//
this.initCluster()
// 1.mapmapid
this.mapContext = uni.createMapContext("alarm_map", this);
},
methods: {
// ===== =====
initCluster() {
if (!this.mapContext) {
setTimeout(() => {
this.initCluster()
}, 500)
return
}
// 1.
this.mapContext.initMarkerCluster({
enableDefaultStyle: false, // 使
zoomOnClick: true, //
gridSize: 60, //
complete: (res) => {
console.log('initMarkerCluster success', res)
this.isClusterInited = true
//
this.addPestMarkersToCluster()
}
})
// 2.
this.mapContext.on('markerClusterCreate', (res) => {
console.log('markerClusterCreate', res)
const clusters = res.clusters
const clusterMarkers = clusters.map((cluster) => {
// marker
const centerLat = cluster.center.latitude
const centerLng = cluster.center.longitude
const count = cluster.markerIds.length
return {
id: cluster.clusterId,
latitude: centerLat,
longitude: centerLng,
width: 40,
height: 40,
iconPath: '/static/zhandian_sahchong_dingwei.png',
label: {
content: count + '',
color: '#ffffff',
fontSize: 12,
fontWeight: 'bold',
anchorX: 0,
anchorY: -8,
borderWidth: 0,
bgColor: 'rgba(0,0,0,0.6)',
borderRadius: 10,
padding: 2
}
}
})
//
this.mapContext.addMarkers({
markers: clusterMarkers,
clear: false,
complete: (res) => {
console.log('add cluster markers success', res)
}
})
})
},
// ===== =====
addPestMarkersToCluster() {
if (!this.isClusterInited) return
//
if (this.clusterMarkerIds.length > 0) {
this.mapContext.removeMarkers({
markerIds: this.clusterMarkerIds,
complete: (res) => {
console.log('remove old cluster markers', res)
}
})
this.clusterMarkerIds = []
}
//
if (!this.isscd || this.pestlight.length === 0) return
//
const pestMarkers = []
this.pestlight.forEach((item, index) => {
const markerId = 10000 + index
pestMarkers.push({
id: markerId,
latitude: Number(item.latitude),
longitude: Number(item.longitude),
width: 15,
height: 20,
iconPath: '/static/zhandian_sahchong_dingwei.png',
joinCluster: true, //
inType: 'pestlight',
stationName: item.stationName,
stationCode: item.stationCode
})
this.clusterMarkerIds.push(markerId)
})
// addMarkers
this.mapContext.addMarkers({
markers: pestMarkers,
clear: false,
complete: (res) => {
console.log('add pest markers to cluster success', res)
}
})
},
// ===== =====
removePestMarkersFromCluster() {
if (this.clusterMarkerIds.length > 0 && this.mapContext) {
this.mapContext.removeMarkers({
markerIds: this.clusterMarkerIds,
complete: (res) => {
console.log('remove pest markers from cluster', res)
}
})
this.clusterMarkerIds = []
}
},
getList() {
this.markers = []
this.markersNoPest = []
@ -247,178 +131,103 @@
});
this.$http.get('/applet/survStationInfo/stationMap').then(res => {
this.stationlist = [...res.data.data.pestlight, ...res.data.data.cusLocation, ...res.data.data.stationInfo]
this.stationlist.forEach((item,index) => {
item.id = index;
if(item.inType == 'pestlight'){
this.pestlight.push(item)
}
if(item.stationType == 'cusLocaltion'){
this.cusLocation.push(item)
}
if(item.stationType == 'orient' || item.stationType == 'livestock'){
this.stationInfo.push(item)
}
this.stationlist.forEach((item,index) => {
item.id = index;
if(item.inType == 'pestlight'){
this.pestlight.push(item)
}
if(item.stationType == 'cusLocaltion'){
this.cusLocation.push(item)
}
if(item.stationType == 'orient' || item.stationType == 'livestock'){
this.stationInfo.push(item)
}
this.list.push({
latitude:Number(item.stationLatitude),
longitude: Number(item.stationLongitude),
stationType:item.stationType,
sortNo: item.sortNo,
stationName: item.stationName,
stationCode: item.stationCode
})
})
this.issscd = false
this.isssscd = false
this.qiyeChange()
this.list1query()
this.list2query()
uni.hideLoading();
})
},
// stationlist
processStationList(stationlist) {
if (stationlist) {
stationlist.forEach(item => {
this.list.push({
latitude:Number(item.stationLatitude),
longitude: Number(item.stationLongitude),
stationType:item.stationType,
latitude: item.inType === 'pestlight' ? Number(item.latitude) : Number(item
.stationLatitude),
longitude: item.inType === 'pestlight' ? Number(item.longitude) : Number(item
.stationLongitude),
stationType: item.inType === 'pestlight' ? 'pestlight' : item.stationType,
sortNo: item.sortNo,
stationName: item.stationName,
stationCode: item.stationCode
})
})
this.issscd = false
this.isssscd = false
this.qiyeChange()
this.list1query()
this.list2query()
//
if (this.isClusterInited) {
this.addPestMarkersToCluster()
}
uni.hideLoading();
})
},
// ===== =====
switch1Change() {
this.isscd = !this.isscd;
if (this.isscd) {
// -
this.addPestMarkersToCluster()
} else {
// -
this.removePestMarkersFromCluster()
}
},
// ===== =====
qiyeChange() {
for (let i = 0; i < this.cusLocation.length; i++) {
const item = this.cusLocation[i];
item.iconPath = '/static/qiyeIcon.png';
item.latitude = Number(item.stationLatitude);
item.longitude = Number(item.stationLongitude);
item.width = 35;
item.height = 52;
this.list.push({
latitude:Number(item.stationLatitude),
longitude: Number(item.stationLongitude),
stationType:item.stationType,
sortNo: item.sortNo,
stationName: item.stationName,
stationCode: item.stationCode
})
const markerItem = {
id: item.id,
// pointers
generatePointers() {
const iconConfig = {
// pestlight: {
// iconPath: '/static/zhandian_sahchong_dingwei.png',
// width: 15,
// height: 20
// },
orient: {
iconPath: '/static/zhandian_nongtian_dingwei.png',
width: 35,
height: 52
},
livestock: {
iconPath: '/static/zhandian_xuqin_dingwei.png',
width: 35,
height: 52
},
cusLocaltion: {
iconPath: '/static/qiyeIcon.png',
width: 35,
height: 52
}
}
this.list.forEach((item, i) => {
const config = iconConfig[item.stationType] || {}
item.iconPath = config.iconPath || ''
item.width = config.width || 0
item.height = config.height || 0
this.pointers.push({
id: i,
iconPath: item.iconPath,
latitude: item.latitude,
longitude: item.longitude,
latitude: Number(item.latitude),
longitude: Number(item.longitude),
width: item.width,
height: item.height,
customCallout: {
anchorY: 0,
anchorX: 0,
display: 'ALWAYS'
anchorY: 0, // Y
anchorX: 0, // X
display: 'ALWAYS' //
},
stationType: item.stationType,
stationName: item.stationName,
stationCode: item.stationCode,
joinCluster: true
};
this.markers.push(markerItem);
}
},
switch2Change() {
this.issscd = !this.issscd
this.list1query()
},
switch3Change() {
this.isssscd = !this.isssscd
this.list2query()
},
list1query(){
if (!this.issscd) {
for (let i = 0; i < this.stationInfo.length; i++) {
const item = this.stationInfo[i];
if(item.stationType === 'orient'){
item.iconPath = '/static/zhandian_nongtian_dingwei.png';
item.latitude = Number(item.stationLatitude);
item.longitude = Number(item.stationLongitude);
item.width = 35;
item.height = 52;
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: true
};
this.markers.push(markerItem);
}
}
} else {
this.markers = this.markers.filter((item)=>{
return item.stationType !== 'orient'
joinCluster: true //
})
}
},
list2query(){
if (!this.isssscd) {
for (let i = 0; i < this.stationInfo.length; i++) {
const item = this.stationInfo[i];
if(item.stationType === 'livestock'){
item.iconPath = '/static/zhandian_xuqin_dingwei.png';
item.latitude = Number(item.stationLatitude);
item.longitude = Number(item.stationLongitude);
item.width = 35;
item.height = 52;
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: true
};
this.markers.push(markerItem);
}
}
} else {
this.markers = this.markers.filter((item)=>{
return item.stationType !== 'livestock'
})
}
})
},
markertap(e) {
const index = e.detail.markerId
console.log(e.detail,'index')
//
if (e.detail && e.detail.isCluster) {
console.log('点击了聚合点:', e.detail)
return
}
if (['orient', 'livestock'].includes(this.list[index]?.stationType)) {
console.log(e.detail,'index')
if (['orient', 'livestock'].includes(this.list[index].stationType)) {
uni.navigateTo({
url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(this.list[index]))}`
})
@ -426,7 +235,7 @@
},
callouttap(e) {
const index = e.detail.markerId
if (['orient', 'livestock'].includes(this.list[index]?.stationType)) {
if (['orient', 'livestock'].includes(this.list[index].stationType)) {
uni.navigateTo({
url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(this.list[index]))}`
})
@ -434,7 +243,174 @@
},
todetails(item) {
console.log(item, '还是个然后')
}
},
switch1Change() {
this.isscd = !this.isscd;
let index = 0;
if (!this.isscd) {
this.pestlightMarker = [];
this.timerSet = setInterval(() => {
for (let i = 0; i < 50 && index < this.pestlight.length; i++) {
const item = this.pestlight[index];
item.iconPath = '/static/zhandian_sahchong_dingwei.png';
item.latitude = Number(item.latitude);
item.longitude = Number(item.longitude);
item.width = 15;
item.height = 20;
// markers
const markerItem = {
id: item.id,
iconPath: item.iconPath,
latitude: item.latitude,
longitude: item.longitude,
width: item.width,
height: item.height,
customCallout: {
anchorY: 0, // Y
anchorX: 0, // X
display: 'ALWAYS' //
},
// stationType: item.stationType,
inType: item.inType,
stationName: item.stationName,
stationCode: item.stationCode,
joinCluster: false //
};
this.markers.push(markerItem);
index++;
}
// this.markers = this.markers.concat(aa);
if (index >= this.pestlight.length) {
clearInterval(this.timerSet);
}
}, 1000);
} else {
clearInterval(this.timerSet);
this.markers = this.markers.filter((item)=>{
return item.inType !== 'pestlight'
})
}
},
qiyeChange() {
for (let i = 0; i < this.cusLocation.length; i++) {
const item = this.cusLocation[i];
item.iconPath = '/static/qiyeIcon.png';
item.latitude = Number(item.stationLatitude);
item.longitude = Number(item.stationLongitude);
item.width = 35;
item.height = 52;
this.list.push({
latitude:Number(item.stationLatitude),
longitude: Number(item.stationLongitude),
stationType:item.stationType,
sortNo: item.sortNo,
stationName: item.stationName,
stationCode: item.stationCode
})
// markers
const markerItem = {
id: item.id,
iconPath: item.iconPath,
latitude: item.latitude,
longitude: item.longitude,
width: item.width,
height: item.height,
customCallout: {
anchorY: 0, // Y
anchorX: 0, // X
display: 'ALWAYS' //
},
stationType: item.stationType,
stationName: item.stationName,
stationCode: item.stationCode,
joinCluster: true //
};
this.markers.push(markerItem);
}
},
switch2Change() {
this.issscd = !this.issscd
this.list1query()
},
switch3Change() {
this.isssscd = !this.isssscd
this.list2query()
},
list1query(){
if (!this.issscd) {
for (let i = 0; i < this.stationInfo.length; i++) {
const item = this.stationInfo[i];
if(item.stationType === 'orient'){
item.iconPath = '/static/zhandian_nongtian_dingwei.png';
item.latitude = Number(item.stationLatitude);
item.longitude = Number(item.stationLongitude);
item.width = 35;
item.height = 52;
// markers
const markerItem = {
id: item.id,
iconPath: item.iconPath,
latitude: item.latitude,
longitude: item.longitude,
width: item.width,
height: item.height,
customCallout: {
anchorY: 0, // Y
anchorX: 0, // X
display: 'ALWAYS' //
},
stationType: item.stationType,
stationName: item.stationName,
stationCode: item.stationCode,
joinCluster: true //
};
this.markers.push(markerItem);
}
}
} else {
this.markers = this.markers.filter((item)=>{
return item.stationType !== 'orient'
})
}
},
list2query(){
if (!this.isssscd) {
for (let i = 0; i < this.stationInfo.length; i++) {
const item = this.stationInfo[i];
if(item.stationType === 'livestock'){
item.iconPath = '/static/zhandian_xuqin_dingwei.png';
item.latitude = Number(item.stationLatitude);
item.longitude = Number(item.stationLongitude);
item.width = 35;
item.height = 52;
// markers
const markerItem = {
id: item.id,
iconPath: item.iconPath,
latitude: item.latitude,
longitude: item.longitude,
width: item.width,
height: item.height,
customCallout: {
anchorY: 0, // Y
anchorX: 0, // X
display: 'ALWAYS' //
},
stationType: item.stationType,
stationName: item.stationName,
stationCode: item.stationCode,
joinCluster: true //
};
this.markers.push(markerItem);
}
}
} else {
this.markers = this.markers.filter((item)=>{
return item.stationType !== 'livestock'
})
}
}
}
}
</script>
@ -442,6 +418,7 @@
<style lang="scss">
.bgimg {
position: fixed;
// z-index: -99;
top: 0;
left: 0;
width: 100%;
@ -455,6 +432,7 @@
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;
@ -469,6 +447,7 @@
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;