按照租户信息修改河津的新小程序第分支提交

This commit is contained in:
978184212@qq.com 2026-08-18 17:37:23 +08:00
parent 81a0a7ba3d
commit 816306b598
7 changed files with 378 additions and 412 deletions

View File

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

View File

@ -1,5 +1,5 @@
{
"name" : "吉县面源污染监测平台",
"name" : "河津市农业面源污染监测系统",
"appid" : "__UNI__A58A5D7",
"description" : "",
"versionName" : "2.2.22",
@ -84,7 +84,7 @@
"quickapp" : {},
/* */
"mp-weixin" : {
"appid" : "wxc078890f8668ed2e",
"appid" : "wx2fb61322f3042141",
"setting" : {
"urlCheck" : false,
"es6" : true,

View File

@ -35,7 +35,7 @@
</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">
<image class="bigimg" src="../../static/dls.jpg" mode=""></image>
<view class="padding text-center margin-top">

View File

@ -23,7 +23,7 @@
</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>
</template>

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,455 +1,421 @@
<template>
<view class="container">
<map id="map" ref="map" style="width: 100%; height: calc(100vh + 50rpx);" :scale="mapScale" :markers="markers"
longitude="112.83100231396601" latitude="36.872032399813556" show-location show-compass show-scale
@markertap="markertap">
<!-- <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">
<cover-view v-for="(item,index) in markers" :key="index" class="customCallout" :marker-id="item.id">
<cover-image class="imgs" src="@/static/zhandian_icon_xuqin_title.png"
v-if="item.stationType == 'livestock'"></cover-image>
<cover-image class="imgs" src="@/static/zhandian_icon_nongtian_title.png"
v-if="item.stationType == 'orient'"></cover-image>
<cover-image class="imgs" src="@/static/zhandian_icon_qiye_title.png"
v-if="item.stationType == 'cusLocaltion'"></cover-image>
<cover-view class="content"
v-if="item.stationType == 'livestock' || item.stationType == 'orient'|| item.stationType == 'cusLocaltion'">
{{item.stationName}}
</cover-view>
</cover-view>
</cover-view>
</map>
<view class="zdxq">
<view class="zdxqitem" @click="switch2Change('livestock')">
<view class="zdxqitem" @click="switch1Change">
<image src="../../static/zhandian_sahchong_dingwei.png" mode=""></image>
<view class="textss">
联网式太阳能杀虫灯
</view>
<view class="crildon" :style="!isscd?'background:#00ff37':'background: #ccc;'"></view>
</view>
<view class="zdxqitem" @click="switch2Change">
<image src="../../static/zhandian_xuqin_dingwei.png" mode=""></image>
<view class="textss">
畜禽污染监测站
畜禽养殖污染监测站
</view>
<view class="crildon" :style="!issscd?'background:#00ff37':'background: #ccc;'"></view>
</view>
<view class="zdxqitem" @click="switch2Change('orient')">
<view class="zdxqitem" @click="switch3Change">
<image src="../../static/zhandian_nongtian_dingwei.png" mode=""></image>
<view class="textss">
农田污染监测站
农田面源污染监测站
</view>
<view class="crildon" :style="!isssscd?'background:#00ff37':'background: #ccc;'"></view>
</view>
<!-- <view class="zdxqitem" @click="switch2Change('watershed')">
<image src="../../static/zhandian_xiaoliuyu_dingwei.png" mode=""></image>
<view class="textss">
小流域监测站
</view>
</view>
<view class="zdxqitem" @click="switch2Change('soil')">
<image src="../../static/iconsheturangzs.png" mode=""></image>
<view class="textss">
长期定位监测点
</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>
<script>
import api from '@/api/api'
import configService from '@/common/service/config.service.js';
import selectSwitch from "@/components/xuan-switch/xuan-switch.vue";
export default {
components: {
selectSwitch
},
data() {
return {
baseUrl: configService.staticDomainURL,
center: {
latitude: 36.5,
longitude: 111.7
},
mapScale: 13,
markers: [],
markersZIndex: 1,
lastTap: '',
stationList: [],
cusLocationList: [],
soilStationList: [],
allStationList: [],
stationTwoList: [],
mapCtx: null //
markersNoPest: [],
list: [],
pointers: [],
imgurl1: '@/static/zhandian_icon_nongtian_title.png',
imgurl2: '@/static/zhandian_icon_xuqin_title.png',
isscd: true,
issscd: true,
isssscd: true,
pestlight: [],
cusLocation: [],
stationInfo: [],
pestlightMarker: null,
stationlist: [],
timerSet: null
};
},
onLoad() {},
onReady() {
// onReady
this.mapCtx = uni.createMapContext('map', this);
onLoad() {
// this.isscd = true
// this.getList()
this.$nextTick(() => {
this.getList()
})
},
onShow() {
api.checkLogin(() => {
this.$nextTick(() => {
this.getList()
})
}, () => {
var that = this
if (uni.getStorageSync('third_session')) {
uni.login({
success: function(res) {
console.log(res.code)
this.code = res.code
let params = {}
params.jsCode = this.code
console.log(params, 152)
api.wxlogin(params).then(res => {
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
//
}
}
})
}
});
} else if (!uni.getStorageSync('third_session')) {
uni.reLaunch({
url: '/packDetail/pages/login/login'
url: '/pages/loginindex'
})
})
}
},
onReady() {
// 1.mapmapid
this.mapContext = uni.createMapContext("alarm_map", this);
},
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.markersNoPest = []
this.pointers = []
this.list = []
uni.showLoading({
title: '加载中'
});
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.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();
})
},
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: [120, 120, 120, 120], //
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: [150, 150, 150, 150]
});
} catch (e) {
console.error('第二次调整失败:', e);
}
}
}, 500);
// 3
setTimeout(() => {
if (this.mapCtx) {
try {
this.mapCtx.includePoints({
points: validPoints,
padding: [180, 160, 160, 160]
});
} catch (e) {
console.error('第三次调整失败:', e);
}
}
}, 1000);
// stationlist
processStationList(stationlist) {
if (stationlist) {
stationlist.forEach(item => {
this.list.push({
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
})
})
}
},
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);
});
// 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: Number(item.latitude),
longitude: Number(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 //
})
})
},
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`
})
}
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]))}`
})
}
},
switch2Change(name) { //
//
let that = this;
if (name === that.lastTap) {
that.adjustMapToFitAllMarkers();
that.lastTap = '';
} else {
//
that.adjustMapToRegion(name);
that.lastTap = name;
callouttap(e) {
const index = e.detail.markerId
if (['orient', 'livestock'].includes(this.list[index].stationType)) {
uni.navigateTo({
url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(this.list[index]))}`
})
}
},
// 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] //
});
}
todetails(item) {
console.log(item, '还是个然后')
},
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)
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++;
}
});
}
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'
// });
// 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>
<style lang="scss">
/* 样式保持不变 */
.bgimg {
position: fixed;
// z-index: -99;
@ -505,7 +471,7 @@
font-weight: 500;
color: #FFFFFF;
text-shadow: 0rpx 1rpx 0rpx rgba(4, 49, 52, 0.55);
width: 240rpx;
width: 299rpx;
background: rgba(0, 0, 0, 0.52);
border: 1px solid #4B677C;
border-radius: 6rpx;
@ -555,4 +521,4 @@
display: flex;
align-items: center;
}
</style>
</style>