优化登录、优化图片加载失败等
This commit is contained in:
parent
18e81582f8
commit
8447475eb9
12
App.vue
12
App.vue
|
|
@ -190,20 +190,12 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
if(!uni.getStorageSync('third_session')){
|
console.log('App onLoad!')
|
||||||
uni.reLaunch({
|
|
||||||
url:'/packDetail/pages/login/login'
|
|
||||||
})
|
|
||||||
}else{
|
|
||||||
uni.reLaunch({
|
|
||||||
url:'/pages/index/index'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
},
|
},
|
||||||
onHide: function() {
|
onHide: function() {
|
||||||
console.log('App Hide')
|
console.log('App Hide1')
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
51
api/api.js
51
api/api.js
|
|
@ -1,5 +1,6 @@
|
||||||
import { http } from '@/common/service/service.js'
|
import { http } from '@/common/service/service.js'
|
||||||
import configService from '@/common/service/config.service.js';
|
import configService from '@/common/service/config.service.js';
|
||||||
|
import indexData from "@/pages/index/indexData";
|
||||||
const apiService = {
|
const apiService = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -37,7 +38,55 @@ const apiService = {
|
||||||
}else{
|
}else{
|
||||||
return configService.staticDomainURL + "/" + avatar;
|
return configService.staticDomainURL + "/" + avatar;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
// 检查登录并执行:api.checkLogin(()=>{}, () => {});
|
||||||
|
checkLogin(successCallback,failCallback){
|
||||||
|
let that = this;
|
||||||
|
if (uni.getStorageSync('userInfo') && uni.getStorageSync('third_session')) {
|
||||||
|
if(successCallback){
|
||||||
|
successCallback();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uni.login({
|
||||||
|
success: function(res) {
|
||||||
|
let params = {}
|
||||||
|
params.jsCode = res.code
|
||||||
|
that.wxlogin(params).then(res => {
|
||||||
|
that.loginCallback(res, successCallback, failCallback);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
loginCallback(res, successCallback, failCallback){
|
||||||
|
let that = this;
|
||||||
|
if (res.data.code == 0) {
|
||||||
|
let userInfo = res.data.data;
|
||||||
|
if (!userInfo.id) {
|
||||||
|
console.error('登录失败',userInfo)
|
||||||
|
that.loginFail();
|
||||||
|
if(failCallback){
|
||||||
|
failCallback();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.warn('登录成功',userInfo)
|
||||||
|
uni.setStorageSync('userInfo', userInfo);
|
||||||
|
uni.setStorageSync('third_session', userInfo.thirdSession);
|
||||||
|
if(successCallback){
|
||||||
|
successCallback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
that.loginFail();
|
||||||
|
if(failCallback){
|
||||||
|
failCallback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
loginFail () {
|
||||||
|
uni.removeStorageSync('third_session')
|
||||||
|
uni.removeStorageSync('userInfo');
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default apiService;
|
export default apiService;
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,12 @@ let apiUrl = configService.apiUrl;
|
||||||
|
|
||||||
const http = new Request()
|
const http = new Request()
|
||||||
http.setConfig((config) => { /* 设置全局配置 */
|
http.setConfig((config) => { /* 设置全局配置 */
|
||||||
config.baseUrl = apiUrl /* 根域名不同 */
|
config.baseUrl = apiUrl; /* 根域名不同 */
|
||||||
config.header = {
|
config.header = {
|
||||||
...config.header
|
...config.header
|
||||||
}
|
};
|
||||||
|
console.log(config)
|
||||||
|
// config.headers['X-Access-Token'] = localStorage.getItem("token")
|
||||||
return config
|
return config
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -43,9 +45,10 @@ http.interceptor.request((config, cancel) => { /* 请求之前拦截器 */
|
||||||
config.header = {
|
config.header = {
|
||||||
...config.header,
|
...config.header,
|
||||||
// 'X-Access-Token':getTokenStorage()
|
// 'X-Access-Token':getTokenStorage()
|
||||||
'app-id':uni.getAccountInfoSync().miniProgram.appId,
|
'app-id' : uni.getAccountInfoSync().miniProgram.appId,
|
||||||
"client-type":"MA",
|
"client-type" : "MA",
|
||||||
'third-session':uni.getStorageSync('third_session')
|
'third-session' : uni.getStorageSync('third_session')||'123',
|
||||||
|
'X-Tenant-Id' : '1001'
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
if (!token) { // 如果token不存在,调用cancel 会取消本次请求,但是该函数的catch() 仍会执行
|
if (!token) { // 如果token不存在,调用cancel 会取消本次请求,但是该函数的catch() 仍会执行
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name" : "汾西小流域面源污染监测",
|
"name" : "武乡面源污染监测平台",
|
||||||
"appid" : "__UNI__44A8AB0",
|
"appid" : "__UNI__A58A5D7",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "2.2.22",
|
"versionName" : "2.2.22",
|
||||||
"versionCode" : 233,
|
"versionCode" : 233,
|
||||||
|
|
@ -84,7 +84,7 @@
|
||||||
"quickapp" : {},
|
"quickapp" : {},
|
||||||
/* 快应用特有相关 */
|
/* 快应用特有相关 */
|
||||||
"mp-weixin" : {
|
"mp-weixin" : {
|
||||||
"appid" : "wx54f76f700fe3a498",
|
"appid" : "wx9eda310e459cc7b9",
|
||||||
"setting" : {
|
"setting" : {
|
||||||
"urlCheck" : false,
|
"urlCheck" : false,
|
||||||
"es6" : true,
|
"es6" : true,
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@
|
||||||
</view>
|
</view>
|
||||||
<view class="jczb_bot">
|
<view class="jczb_bot">
|
||||||
<view>
|
<view>
|
||||||
<view class="jccontent" v-if="orientlist.length != 0">
|
<view class="jccontent" v-if="orientlist && orientlist.length != 0">
|
||||||
<view class="titles">
|
<view class="titles">
|
||||||
重要污染物监测
|
重要污染物监测
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -120,7 +120,7 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="jccontent" v-if="livelist.length != 0">
|
<view class="jccontent" v-if="livelist && livelist.length != 0">
|
||||||
<view class="titles">
|
<view class="titles">
|
||||||
重要污染物监测
|
重要污染物监测
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -306,6 +306,7 @@
|
||||||
let items = item.deployCode.split('-')
|
let items = item.deployCode.split('-')
|
||||||
var obj = {
|
var obj = {
|
||||||
url: "https://m.ilhzn.cn/#/pages/cameraView/ysyCamera",
|
url: "https://m.ilhzn.cn/#/pages/cameraView/ysyCamera",
|
||||||
|
// url: "https://m.ilhzn.cn/#/pages/cameraView/cameraView",
|
||||||
deployDes: item.deployDes + '-' + '',
|
deployDes: item.deployDes + '-' + '',
|
||||||
ysToken: this.token,
|
ysToken: this.token,
|
||||||
deviceIotUrl: item.deviceUrl
|
deviceIotUrl: item.deviceUrl
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@
|
||||||
<view class="list_item" v-for="(item,index) in List" :key="index" @click="todetail(item,index)">
|
<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_top">
|
||||||
<view class="list_item_left">
|
<view class="list_item_left">
|
||||||
<image v-if="item.stationType == 'livestock'" src="../../static/zhandian_icon_xuqin.png" mode=""></image>
|
<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-else src="../../static/zd.png" mode=""></image>
|
<image v-else src="../../static/zd.png" mode=""></image>
|
||||||
<view class="item_right" v-if="item.stationName">
|
<view class="item_right" v-if="item.stationName">
|
||||||
<view class="right_top">
|
<view class="right_top">
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<uni-nav-bar :fixed="true" left-icon="left" background-color="#0F6EFF" @clickLeft="back()" status-bar
|
<uni-nav-bar :fixed="true" left-icon="left" background-color="#0F6EFF" @clickLeft="back()" status-bar
|
||||||
:title="details.name" />
|
:title="details.name"/>
|
||||||
<view class="contant">
|
<view class="contant" v-if="details.icon || details.name">
|
||||||
<view class="list_item">
|
<view class="list_item">
|
||||||
<view class="list_item_top">
|
<view class="list_item_top">
|
||||||
<view class="list_item_left">
|
<view class="list_item_left">
|
||||||
<image :src="details.icon" mode=""></image>
|
<image :src="baseUrl + '/' + details.icon" mode=""></image>
|
||||||
<view class="item_right">
|
<view class="item_right">
|
||||||
<view class="right_top" v-if="details.name">
|
<view class="right_top" v-if="details.name">
|
||||||
监测指标-{{details.name}}
|
监测指标-{{details.name}}
|
||||||
|
|
@ -64,12 +64,14 @@
|
||||||
<script>
|
<script>
|
||||||
import uniEcCanvas from '../../components/uni-ec-canvas/uni-ec-canvas.vue'
|
import uniEcCanvas from '../../components/uni-ec-canvas/uni-ec-canvas.vue'
|
||||||
import * as echarts from '../../components/uni-ec-canvas/echarts.js'
|
import * as echarts from '../../components/uni-ec-canvas/echarts.js'
|
||||||
|
import configService from "@/common/service/config.service";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
uniEcCanvas,
|
uniEcCanvas,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
baseUrl:configService.staticDomainURL,
|
||||||
items: {},
|
items: {},
|
||||||
details: {},
|
details: {},
|
||||||
list: [],
|
list: [],
|
||||||
|
|
|
||||||
|
|
@ -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">
|
||||||
|
|
@ -80,7 +80,7 @@ export default {
|
||||||
thirdLoginInfo: "",
|
thirdLoginInfo: "",
|
||||||
thirdLoginState: false,
|
thirdLoginState: false,
|
||||||
bindingPhoneModal: false,
|
bindingPhoneModal: false,
|
||||||
login: false,
|
login: true,
|
||||||
thirdUserUuid: '',
|
thirdUserUuid: '',
|
||||||
url: {
|
url: {
|
||||||
bindingThirdPhone: '/sys/thirdLogin/bindingThirdPhone'
|
bindingThirdPhone: '/sys/thirdLogin/bindingThirdPhone'
|
||||||
|
|
@ -106,20 +106,16 @@ export default {
|
||||||
params.jsCode = that.code
|
params.jsCode = that.code
|
||||||
console.log(params, 152)
|
console.log(params, 152)
|
||||||
api.wxlogin(params).then(res => {
|
api.wxlogin(params).then(res => {
|
||||||
console.log(res, 165)
|
let userInfo = res.data.data;
|
||||||
if (res.data.code == 0) {
|
uni.setStorageSync('third_session', userInfo.thirdSession);
|
||||||
let userInfo = res.data.data;
|
// api.loginCallback(res, ()=>{
|
||||||
uni.setStorageSync('third_session', userInfo.thirdSession);
|
// that.login = false
|
||||||
console.log(that.login, '状态')
|
// uni.reLaunch({
|
||||||
if (userInfo.id) {
|
// url: '/pages/index/index'
|
||||||
that.login = false
|
// })
|
||||||
uni.reLaunch({
|
// }, ()=>{
|
||||||
url: '/pages/index/index'
|
// that.login = true
|
||||||
})
|
// });
|
||||||
} else if (!userInfo.id) {
|
|
||||||
that.login = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -176,23 +172,21 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.$http.post('/applet/userInfo/logins', this.userInfoLoginDTO).then(res => {
|
this.$http.post('/applet/userInfo/logins', this.userInfoLoginDTO).then(res => {
|
||||||
if (res.data.code == 0) {
|
api.loginCallback(res, ()=>{
|
||||||
uni.setStorageSync('constant', res.data.data)
|
uni.setStorageSync('constant', res.data.data)
|
||||||
uni.setStorageSync('password', this.userInfoLoginDTO.password)
|
uni.setStorageSync('password', this.userInfoLoginDTO.password)
|
||||||
uni.setStorageSync('userName', this.userInfoLoginDTO.userName)
|
uni.setStorageSync('userName', this.userInfoLoginDTO.userName)
|
||||||
uni.reLaunch({
|
uni.reLaunch({
|
||||||
url: '/pages/index/index'
|
url: '/pages/index/index'
|
||||||
})
|
})
|
||||||
} else {
|
}, ()=>{
|
||||||
uni.removeStorageSync('constant')
|
uni.removeStorageSync('constant')
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.data.msg,
|
title: res.data.msg,
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
})
|
})
|
||||||
// this.userInfoLoginDTO.password = ''
|
});
|
||||||
// this.userInfoLoginDTO.userName = ''
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 61 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 58 KiB |
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "HJApplet",
|
"name": "FenXiNspUniapp",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
{
|
{
|
||||||
"path": "pages/index/index",
|
"path": "pages/index/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "汾西小流域面源污染监测",
|
"navigationBarTitleText": "武乡小流域面源污染监测",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -196,7 +196,7 @@
|
||||||
{
|
{
|
||||||
"path": "pages/analysis/index",
|
"path": "pages/analysis/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "统计分析",
|
"navigationBarTitleText": "监测数据统计分析",
|
||||||
"navigationStyle": "default",
|
"navigationStyle": "default",
|
||||||
"navigationBarBackgroundColor":"#0F6EFF"
|
"navigationBarBackgroundColor":"#0F6EFF"
|
||||||
}
|
}
|
||||||
|
|
@ -212,7 +212,7 @@
|
||||||
{
|
{
|
||||||
"path": "pages/sjdyj/index",
|
"path": "pages/sjdyj/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "预警信息",
|
"navigationBarTitleText": "智能告警",
|
||||||
"navigationStyle": "default",
|
"navigationStyle": "default",
|
||||||
"navigationBarBackgroundColor":"#0F6EFF"
|
"navigationBarBackgroundColor":"#0F6EFF"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,449 @@
|
||||||
|
const indexData = {
|
||||||
|
bigswiperList : [{
|
||||||
|
"id": "1692474977070829569",
|
||||||
|
"infoId": "1692474921957675010",
|
||||||
|
"detailCode": "图1",
|
||||||
|
"detailValue": "图",
|
||||||
|
"detailValue2": "1",
|
||||||
|
"propsValue1": null,
|
||||||
|
"propsValue2": null,
|
||||||
|
"detailPics": "temp/20230818174636_1692352452041.jpg",
|
||||||
|
"detailExtPics": null,
|
||||||
|
"detailNote": null,
|
||||||
|
"isShow": "1",
|
||||||
|
"sortNo": 1,
|
||||||
|
"tenantId": null,
|
||||||
|
"reVision": 0,
|
||||||
|
"createdBy": "hjadmin",
|
||||||
|
"createTime": "2023-08-18 17:54:14",
|
||||||
|
"updatedBy": null,
|
||||||
|
"isDel": 0,
|
||||||
|
"updatedTime": null
|
||||||
|
}, {
|
||||||
|
"id": "1692475023417888770",
|
||||||
|
"infoId": "1692474921957675010",
|
||||||
|
"detailCode": "图2",
|
||||||
|
"detailValue": "图",
|
||||||
|
"detailValue2": "2",
|
||||||
|
"propsValue1": null,
|
||||||
|
"propsValue2": null,
|
||||||
|
"detailPics": "temp/20230818174638_1692352462933.png",
|
||||||
|
"detailExtPics": null,
|
||||||
|
"detailNote": null,
|
||||||
|
"isShow": "1",
|
||||||
|
"sortNo": 1,
|
||||||
|
"tenantId": null,
|
||||||
|
"reVision": 0,
|
||||||
|
"createdBy": "hjadmin",
|
||||||
|
"createTime": "2023-08-18 17:54:25",
|
||||||
|
"updatedBy": null,
|
||||||
|
"isDel": 0,
|
||||||
|
"updatedTime": null
|
||||||
|
}],
|
||||||
|
wrwlist : [{
|
||||||
|
"unit": "℃",
|
||||||
|
"code": "dataAirTemp",
|
||||||
|
"color": "#22BB8A",
|
||||||
|
"icon": "sys/icon/shebei_icon_qixiang.png",
|
||||||
|
"description": "大气温度"
|
||||||
|
}, {
|
||||||
|
"unit": "%RH",
|
||||||
|
"code": "dataAirWet",
|
||||||
|
"color": "#EE701C",
|
||||||
|
"icon": "sys/icon/zhandian_icon_kongqishidu.png",
|
||||||
|
"description": "大气湿度"
|
||||||
|
}, {
|
||||||
|
"unit": "hPa",
|
||||||
|
"code": "dataAirPress",
|
||||||
|
"color": "#52AC2A",
|
||||||
|
"icon": "sys/icon/zhandian_icon_daqiyali.png",
|
||||||
|
"description": "大气压力"
|
||||||
|
}, {
|
||||||
|
"unit": "mm",
|
||||||
|
"code": "dataRainFall",
|
||||||
|
"color": "#2BADB9",
|
||||||
|
"icon": "sys/icon/zhandian_icon_jiangyuliang.png",
|
||||||
|
"description": "雨量"
|
||||||
|
}, {
|
||||||
|
"unit": "mm",
|
||||||
|
"code": "dataRainTotal",
|
||||||
|
"color": "#102B6A",
|
||||||
|
"icon": "sys/icon/zhandian_icon_jiangyuliang.png",
|
||||||
|
"description": "雨量累计"
|
||||||
|
}, {
|
||||||
|
"unit": "m/s",
|
||||||
|
"code": "dataWindSpeed",
|
||||||
|
"color": "#7CD6CF",
|
||||||
|
"icon": "sys/icon/zhandian_icon_fengsu.png",
|
||||||
|
"description": "风速"
|
||||||
|
}, {
|
||||||
|
"unit": "°",
|
||||||
|
"code": "dataWindDirection",
|
||||||
|
"color": "#26A3CC",
|
||||||
|
"icon": "sys/icon/zhandian_icon_fengxiang.png",
|
||||||
|
"description": "风向"
|
||||||
|
}, {
|
||||||
|
"unit": "MJ/m2",
|
||||||
|
"code": "dataSunTotal",
|
||||||
|
"color": "#6C48C7",
|
||||||
|
"icon": "sys/icon/zhandian_icon_taiyangquanfushe.png",
|
||||||
|
"description": "辐射累计"
|
||||||
|
}, {
|
||||||
|
"unit": "W/m2",
|
||||||
|
"code": "dataSunFallout",
|
||||||
|
"color": "#22BB8A",
|
||||||
|
"icon": "sys/icon/zhandian_icon_taiyangquanfushe.png",
|
||||||
|
"description": "太阳全辐射"
|
||||||
|
}, {
|
||||||
|
"unit": "%",
|
||||||
|
"code": "dataSoilWet",
|
||||||
|
"color": "#6495ED",
|
||||||
|
"icon": "sys/icon/zhandian_icon_turangshidu.png",
|
||||||
|
"description": "20CM土壤湿度"
|
||||||
|
}, {
|
||||||
|
"unit": "%",
|
||||||
|
"code": "dataSoilWet2",
|
||||||
|
"color": "#4169E1",
|
||||||
|
"icon": "sys/icon/zhandian_icon_turangshidu.png",
|
||||||
|
"description": "40CM土壤湿度"
|
||||||
|
}, {
|
||||||
|
"unit": "%",
|
||||||
|
"code": "dataSoilWet3",
|
||||||
|
"color": "#0000CD",
|
||||||
|
"icon": "sys/icon/zhandian_icon_turangshidu.png",
|
||||||
|
"description": "60CM土壤湿度"
|
||||||
|
}, {
|
||||||
|
"unit": "℃",
|
||||||
|
"code": "dataSoilTemp",
|
||||||
|
"color": "#C71585",
|
||||||
|
"icon": "sys/icon/zhandian_icon_turangwendu.png",
|
||||||
|
"description": "20CM土壤温度"
|
||||||
|
}, {
|
||||||
|
"unit": "℃",
|
||||||
|
"code": "dataSoilTemp2",
|
||||||
|
"color": "#FF1493",
|
||||||
|
"icon": "sys/icon/zhandian_icon_turangwendu.png",
|
||||||
|
"description": "40CM土壤温度"
|
||||||
|
}, {
|
||||||
|
"unit": "℃",
|
||||||
|
"code": "dataSoilTemp3",
|
||||||
|
"color": "#FF69B4",
|
||||||
|
"icon": "sys/icon/zhandian_icon_turangwendu.png",
|
||||||
|
"description": "60CM土壤温度"
|
||||||
|
}, {
|
||||||
|
"unit": "uS/cm",
|
||||||
|
"code": "dataSoilDdl",
|
||||||
|
"color": "#92D0D0",
|
||||||
|
"icon": "sys/icon/zhandian_icon_ec.png",
|
||||||
|
"description": "20CM电导率"
|
||||||
|
}, {
|
||||||
|
"unit": "uS/cm",
|
||||||
|
"code": "dataSoilDdl2",
|
||||||
|
"color": "#73A2A2",
|
||||||
|
"icon": "sys/icon/zhandian_icon_ec.png",
|
||||||
|
"description": "40CM电导率"
|
||||||
|
}, {
|
||||||
|
"unit": "uS/cm",
|
||||||
|
"code": "dataSoilDdl3",
|
||||||
|
"color": "#567777",
|
||||||
|
"icon": "sys/icon/zhandian_icon_ec.png",
|
||||||
|
"description": "60CM电导率"
|
||||||
|
}, {
|
||||||
|
"unit": "",
|
||||||
|
"code": "dataSoilSalt",
|
||||||
|
"color": "#4F5555",
|
||||||
|
"icon": "sys/icon/zhandian_icon_ec.png",
|
||||||
|
"description": "土壤盐分"
|
||||||
|
}, {
|
||||||
|
"unit": "%",
|
||||||
|
"code": "dataSoilWetMark",
|
||||||
|
"color": "#6495ED",
|
||||||
|
"icon": "sys/icon/zhandian_icon_turangshidu.png",
|
||||||
|
"description": "土壤湿度"
|
||||||
|
}, {
|
||||||
|
"unit": "℃",
|
||||||
|
"code": "dataSoilMark",
|
||||||
|
"color": "#C71585",
|
||||||
|
"icon": "sys/icon/zhandian_icon_turangwendu.png",
|
||||||
|
"description": "土壤温度"
|
||||||
|
}, {
|
||||||
|
"unit": "uS/cm",
|
||||||
|
"code": "dataSoilDdlMark",
|
||||||
|
"color": "#92D0D0",
|
||||||
|
"icon": "sys/icon/zhandian_icon_ec.png",
|
||||||
|
"description": "电导率"
|
||||||
|
}, {
|
||||||
|
"unit": "mg/L",
|
||||||
|
"code": "dataWaterTp",
|
||||||
|
"color": "#C8CC00",
|
||||||
|
"icon": "sys/icon/shebei_icon_tp.png",
|
||||||
|
"description": "总磷"
|
||||||
|
}, {
|
||||||
|
"unit": "mg/L",
|
||||||
|
"code": "dataWaterTn",
|
||||||
|
"color": "#009DB2",
|
||||||
|
"icon": "sys/icon/shebei_icon_tn.png",
|
||||||
|
"description": "总氮"
|
||||||
|
}, {
|
||||||
|
"unit": "mg/L",
|
||||||
|
"code": "dataWaterNo",
|
||||||
|
"color": "#72BAA7",
|
||||||
|
"icon": "sys/icon/shebei_icon_no3n.png",
|
||||||
|
"description": "硝态氮"
|
||||||
|
}, {
|
||||||
|
"unit": "mg/L",
|
||||||
|
"code": "dataWaterNh",
|
||||||
|
"color": "#225A1F",
|
||||||
|
"icon": "sys/icon/shebei_icon_nh3n.png",
|
||||||
|
"description": "氨氮"
|
||||||
|
}, {
|
||||||
|
"unit": "mg/L",
|
||||||
|
"code": "dataWaterCod",
|
||||||
|
"color": "#FDB933",
|
||||||
|
"icon": "sys/icon/shebei_icon_cod.png",
|
||||||
|
"description": "化学需氧量"
|
||||||
|
}, {
|
||||||
|
"unit": "mg/m³",
|
||||||
|
"code": "dataOu",
|
||||||
|
"color": "#f47a75",
|
||||||
|
"icon": "sys/icon/zhandian_icon_ou.png",
|
||||||
|
"description": "臭气浓度"
|
||||||
|
}, {
|
||||||
|
"unit": "mg/m³",
|
||||||
|
"code": "dataNh3",
|
||||||
|
"color": "#d05c7c",
|
||||||
|
"icon": "sys/icon/zhandian_icon_nh3.png",
|
||||||
|
"description": "氨气"
|
||||||
|
}, {
|
||||||
|
"unit": "mg/m³",
|
||||||
|
"code": "dataH2s",
|
||||||
|
"color": "#d05c9f",
|
||||||
|
"icon": "sys/icon/zhandian_icon_h2s.png",
|
||||||
|
"description": "硫化氢"
|
||||||
|
}, {
|
||||||
|
"unit": "mg/m³",
|
||||||
|
"code": "dataTvoc",
|
||||||
|
"color": "#f06464",
|
||||||
|
"icon": "sys/icon/zhandian_icon_tvoc.png",
|
||||||
|
"description": "总挥发性有机物"
|
||||||
|
}, {
|
||||||
|
"unit": "台",
|
||||||
|
"code": "default",
|
||||||
|
"color": "#DEAB8A",
|
||||||
|
"icon": "",
|
||||||
|
"description": "默认"
|
||||||
|
}],
|
||||||
|
|
||||||
|
list : [{
|
||||||
|
"name": "总氮",
|
||||||
|
"unit": "mg/L",
|
||||||
|
"value": "2.0000",
|
||||||
|
"color": "#009DB2",
|
||||||
|
"trend": null,
|
||||||
|
"survItem": null,
|
||||||
|
"dataDateTime": "2025-05-23 19:33:23",
|
||||||
|
"stationName": "小流域监测站1#站",
|
||||||
|
"stationCode": "S_1",
|
||||||
|
"stationType": null,
|
||||||
|
"dataCounts": 1045510
|
||||||
|
}, {
|
||||||
|
"name": "总磷",
|
||||||
|
"unit": "mg/L",
|
||||||
|
"value": "1.0061",
|
||||||
|
"color": "#C8CC00",
|
||||||
|
"trend": null,
|
||||||
|
"survItem": null,
|
||||||
|
"dataDateTime": "2025-05-23 19:33:23",
|
||||||
|
"stationName": "小流域监测站1#站",
|
||||||
|
"stationCode": "S_1",
|
||||||
|
"stationType": null,
|
||||||
|
"dataCounts": 1045510
|
||||||
|
}, {
|
||||||
|
"name": "硝态氮",
|
||||||
|
"unit": "mg/L",
|
||||||
|
"value": "5.2110",
|
||||||
|
"color": "#72BAA7",
|
||||||
|
"trend": null,
|
||||||
|
"survItem": null,
|
||||||
|
"dataDateTime": "2025-05-23 19:33:23",
|
||||||
|
"stationName": "小流域监测站1#站",
|
||||||
|
"stationCode": "S_1",
|
||||||
|
"stationType": null,
|
||||||
|
"dataCounts": 1045510
|
||||||
|
}, {
|
||||||
|
"name": "总氮",
|
||||||
|
"unit": "mg/L",
|
||||||
|
"value": "2.1114",
|
||||||
|
"color": "#009DB2",
|
||||||
|
"trend": null,
|
||||||
|
"survItem": null,
|
||||||
|
"dataDateTime": "2025-05-23 19:33:50",
|
||||||
|
"stationName": "小流域监测站1#站",
|
||||||
|
"stationCode": "S_2",
|
||||||
|
"stationType": null,
|
||||||
|
"dataCounts": 1045510
|
||||||
|
}, {
|
||||||
|
"name": "总磷",
|
||||||
|
"unit": "mg/L",
|
||||||
|
"value": "0.9864",
|
||||||
|
"color": "#C8CC00",
|
||||||
|
"trend": null,
|
||||||
|
"survItem": null,
|
||||||
|
"dataDateTime": "2025-05-23 19:33:50",
|
||||||
|
"stationName": "小流域监测站1#站",
|
||||||
|
"stationCode": "S_2",
|
||||||
|
"stationType": null,
|
||||||
|
"dataCounts": 1045510
|
||||||
|
}, {
|
||||||
|
"name": "硝态氮",
|
||||||
|
"unit": "mg/L",
|
||||||
|
"value": "1.2373",
|
||||||
|
"color": "#72BAA7",
|
||||||
|
"trend": null,
|
||||||
|
"survItem": null,
|
||||||
|
"dataDateTime": "2025-05-23 19:33:50",
|
||||||
|
"stationName": "小流域监测站1#站",
|
||||||
|
"stationCode": "S_2",
|
||||||
|
"stationType": null,
|
||||||
|
"dataCounts": 1045510
|
||||||
|
}, {
|
||||||
|
"name": "总氮",
|
||||||
|
"unit": "mg/L",
|
||||||
|
"value": "49.6451",
|
||||||
|
"color": "#009DB2",
|
||||||
|
"trend": null,
|
||||||
|
"survItem": null,
|
||||||
|
"dataDateTime": "2025-05-23 19:33:36",
|
||||||
|
"stationName": "畜禽1号站",
|
||||||
|
"stationCode": "S_3",
|
||||||
|
"stationType": null,
|
||||||
|
"dataCounts": 1045510
|
||||||
|
}, {
|
||||||
|
"name": "总磷",
|
||||||
|
"unit": "mg/L",
|
||||||
|
"value": "10.1785",
|
||||||
|
"color": "#C8CC00",
|
||||||
|
"trend": null,
|
||||||
|
"survItem": null,
|
||||||
|
"dataDateTime": "2025-05-23 19:33:36",
|
||||||
|
"stationName": "畜禽1号站",
|
||||||
|
"stationCode": "S_3",
|
||||||
|
"stationType": null,
|
||||||
|
"dataCounts": 1045510
|
||||||
|
}, {
|
||||||
|
"name": "氨氮",
|
||||||
|
"unit": "mg/L",
|
||||||
|
"value": "49.9502",
|
||||||
|
"color": "#225A1F",
|
||||||
|
"trend": null,
|
||||||
|
"survItem": null,
|
||||||
|
"dataDateTime": "2025-05-23 19:33:36",
|
||||||
|
"stationName": "畜禽1号站",
|
||||||
|
"stationCode": "S_3",
|
||||||
|
"stationType": null,
|
||||||
|
"dataCounts": 1045510
|
||||||
|
}, {
|
||||||
|
"name": "化学需氧量",
|
||||||
|
"unit": "mg/L",
|
||||||
|
"value": "501.5000",
|
||||||
|
"color": "#FDB933",
|
||||||
|
"trend": null,
|
||||||
|
"survItem": null,
|
||||||
|
"dataDateTime": "2025-05-23 19:33:36",
|
||||||
|
"stationName": "畜禽1号站",
|
||||||
|
"stationCode": "S_3",
|
||||||
|
"stationType": null,
|
||||||
|
"dataCounts": 1045510
|
||||||
|
}, {
|
||||||
|
"name": "总氮",
|
||||||
|
"unit": "mg/L",
|
||||||
|
"value": "50.6921",
|
||||||
|
"color": "#009DB2",
|
||||||
|
"trend": null,
|
||||||
|
"survItem": null,
|
||||||
|
"dataDateTime": "2025-05-23 19:00:00",
|
||||||
|
"stationName": "畜禽2号站",
|
||||||
|
"stationCode": "S_4",
|
||||||
|
"stationType": null,
|
||||||
|
"dataCounts": 1045510
|
||||||
|
}, {
|
||||||
|
"name": "总磷",
|
||||||
|
"unit": "mg/L",
|
||||||
|
"value": "0.2719",
|
||||||
|
"color": "#C8CC00",
|
||||||
|
"trend": null,
|
||||||
|
"survItem": null,
|
||||||
|
"dataDateTime": "2025-05-23 19:00:00",
|
||||||
|
"stationName": "畜禽2号站",
|
||||||
|
"stationCode": "S_4",
|
||||||
|
"stationType": null,
|
||||||
|
"dataCounts": 1045510
|
||||||
|
}, {
|
||||||
|
"name": "氨氮",
|
||||||
|
"unit": "mg/L",
|
||||||
|
"value": "48.9038",
|
||||||
|
"color": "#225A1F",
|
||||||
|
"trend": null,
|
||||||
|
"survItem": null,
|
||||||
|
"dataDateTime": "2025-05-23 19:00:00",
|
||||||
|
"stationName": "畜禽2号站",
|
||||||
|
"stationCode": "S_4",
|
||||||
|
"stationType": null,
|
||||||
|
"dataCounts": 1045510
|
||||||
|
}, {
|
||||||
|
"name": "化学需氧量",
|
||||||
|
"unit": "mg/L",
|
||||||
|
"value": "498.3486",
|
||||||
|
"color": "#FDB933",
|
||||||
|
"trend": null,
|
||||||
|
"survItem": null,
|
||||||
|
"dataDateTime": "2025-05-23 19:00:00",
|
||||||
|
"stationName": "畜禽2号站",
|
||||||
|
"stationCode": "S_4",
|
||||||
|
"stationType": null,
|
||||||
|
"dataCounts": 1045510
|
||||||
|
}],
|
||||||
|
menu: [
|
||||||
|
{
|
||||||
|
name: '监测站点',
|
||||||
|
img: require('../../static/home_icon_jiance.png'),
|
||||||
|
path: '/packDetail/pages/Site/index'
|
||||||
|
}, {
|
||||||
|
name: '智能告警',
|
||||||
|
img: require('../../static/scd.png'),
|
||||||
|
path: '/packDetail/pages/sjdyj/index'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '视频监控',
|
||||||
|
img: require('../../static/home_icon_shipin.png'),
|
||||||
|
path: '/packDetail1/pages/device/index'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '站点运维',
|
||||||
|
img: require('../../static/home_icon_yunwei.png'),
|
||||||
|
path: '/packDetail/pages/operations/index'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '农业废弃物',
|
||||||
|
img: require('../../static/home_icon_feiqiwu.png'),
|
||||||
|
path: '/packDetail/pages/waste/index'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '粪污台账',
|
||||||
|
img: require('../../static/home_icon_fenwu.png'),
|
||||||
|
path: '/packDetail/pages/fwtz/index'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '设备管理',
|
||||||
|
img: require('../../static/home_icon_shebei.png'),
|
||||||
|
path: '/packDetail/pages/vidio/index'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '统计分析',
|
||||||
|
img: require('../../static/home_icon_shuju.png'),
|
||||||
|
path: '/packDetail/pages/analysis/index'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
export default indexData;
|
||||||
|
|
@ -1,457 +0,0 @@
|
||||||
<template>
|
|
||||||
<view class="container">
|
|
||||||
<map id="map" ref="map" style="width: 100%; height:2000rpx;" scale="13" :markers="markers" longitude="111.436625"
|
|
||||||
latitude="36.771975" show-location @markertap="markertap" @callouttap="callouttap">
|
|
||||||
</map>
|
|
||||||
<view class="zdxq">
|
|
||||||
<view class="zdxqitem" @click="switch2Change('团柏河')">
|
|
||||||
<image src="../../static/zhandian_nongtian_dingwei.png" mode=""></image>
|
|
||||||
<view class="textss">
|
|
||||||
团柏河典型小流域监测站
|
|
||||||
</view>
|
|
||||||
<!-- <view class="crildon" :style="!issscd?'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="!isssscd?'background:#00ff37':'background: #ccc;'"></view> -->
|
|
||||||
</view>
|
|
||||||
<view class="zdxqitem" @click="switch2Change('土壤')">
|
|
||||||
<image src="../../static/iconsheturangzs.png" mode=""></image>
|
|
||||||
<view class="textss">
|
|
||||||
土壤监测
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import api from '@/api/api'
|
|
||||||
import configService from '@/common/service/config.service.js';
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
baseUrl:configService.staticDomainURL,
|
|
||||||
markers: [],
|
|
||||||
list: [],
|
|
||||||
issscd: false, // 团柏河显示状态 (false表示显示)
|
|
||||||
isssscd: false, // 对竹河显示状态 (false表示显示)
|
|
||||||
stationInfo: [],
|
|
||||||
cusLocation: [],
|
|
||||||
stationlist: [],
|
|
||||||
stationTwolist:[],
|
|
||||||
mapCtx: null // 添加地图上下文
|
|
||||||
};
|
|
||||||
},
|
|
||||||
onLoad() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.getList()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
onReady() {
|
|
||||||
// 在onReady中初始化地图上下文
|
|
||||||
this.mapCtx = uni.createMapContext('map', this);
|
|
||||||
},
|
|
||||||
onShow() {
|
|
||||||
if (!uni.getStorageSync('third_session')) {
|
|
||||||
uni.reLaunch({
|
|
||||||
url: '/packDetail/pages/login/login'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
getList() {
|
|
||||||
this.markers = []
|
|
||||||
this.list = []
|
|
||||||
this.stationInfo = []
|
|
||||||
this.cusLocation = []
|
|
||||||
this.stationlist = []
|
|
||||||
this.stationTwolist = []
|
|
||||||
|
|
||||||
uni.showLoading({
|
|
||||||
title: '加载中'
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$http.get('/applet/survStationInfo/stationMap').then(res => {
|
|
||||||
// 合并 stationInfo 和 deviceList
|
|
||||||
const combinedList = [...res.data.data.stationInfo, ...res.data.data.deviceList];
|
|
||||||
this.stationlist = combinedList;
|
|
||||||
this.stationTwolist = [...res.data.data.stationInfo];
|
|
||||||
|
|
||||||
console.log("合并后的stationlist+++++", this.stationlist);
|
|
||||||
|
|
||||||
// 处理所有标记点
|
|
||||||
this.stationlist.forEach((item, index) => {
|
|
||||||
item.id = index;
|
|
||||||
|
|
||||||
// 统一字段名称,处理 deviceList 和 stationInfo 的字段差异
|
|
||||||
const markerItem = {
|
|
||||||
id: item.id,
|
|
||||||
latitude: Number(item.latitude || item.stationLatitude),
|
|
||||||
longitude: Number(item.longitude || item.stationLongitude),
|
|
||||||
stationType: item.stationType || 'device', // deviceList 没有 stationType,默认为 'device'
|
|
||||||
sortNo: item.sortNo || index,
|
|
||||||
stationName: item.name || item.stationName,
|
|
||||||
stationCode: item.ids || item.stationCode || item.id,
|
|
||||||
// 添加分组信息
|
|
||||||
groupName: item.groupName || '',
|
|
||||||
// 设备类型
|
|
||||||
deviceType: item.type || null
|
|
||||||
};
|
|
||||||
|
|
||||||
this.list.push(markerItem);
|
|
||||||
|
|
||||||
// 分类处理
|
|
||||||
if (item.stationType === 'cusLocaltion') {
|
|
||||||
this.cusLocation.push(item);
|
|
||||||
}
|
|
||||||
if (item.stationType === 'orient' || item.stationType === 'livestock') {
|
|
||||||
this.stationInfo.push(item);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.issscd = false
|
|
||||||
this.isssscd = false
|
|
||||||
this.qiyeChange()
|
|
||||||
this.list1query()
|
|
||||||
this.addDeviceMarkers() // 添加设备标记
|
|
||||||
|
|
||||||
// 延迟执行以确保标记已经添加到地图
|
|
||||||
setTimeout(() => {
|
|
||||||
this.adjustMapToFitAllMarkers();
|
|
||||||
}, 500);
|
|
||||||
|
|
||||||
uni.hideLoading();
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
// 添加设备标记
|
|
||||||
addDeviceMarkers() {
|
|
||||||
this.stationlist.forEach((item, index) => {
|
|
||||||
// 如果是 deviceList 中的设备(有 type 字段但没有 stationType 字段)
|
|
||||||
if (item.type && !item.stationType) {
|
|
||||||
let iconPath = '';
|
|
||||||
let width = 35;
|
|
||||||
let height = 35;
|
|
||||||
|
|
||||||
// 根据设备类型设置不同的图标
|
|
||||||
switch(item.type) {
|
|
||||||
case 'soil':
|
|
||||||
iconPath = this.baseUrl + '/icon/device/soil.png';
|
|
||||||
width = 40;
|
|
||||||
height = 40;
|
|
||||||
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: true
|
|
||||||
};
|
|
||||||
this.markers.push(markerItem);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
// 调整地图视野以包含所有标记点
|
|
||||||
adjustMapToFitAllMarkers() {
|
|
||||||
if (this.mapCtx && this.list.length > 0) {
|
|
||||||
this.mapCtx.includePoints({
|
|
||||||
points: this.list.map(item => ({
|
|
||||||
latitude: item.latitude,
|
|
||||||
longitude: item.longitude
|
|
||||||
})),
|
|
||||||
padding: [40, 40, 40, 40] // 上下左右的边距
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// 调整地图视野到特定区域的标记点
|
|
||||||
adjustMapToRegion(regionName) {
|
|
||||||
let points = [];
|
|
||||||
|
|
||||||
if (regionName === '团柏河') {
|
|
||||||
// 获取团柏河区域的所有标记点
|
|
||||||
points = this.stationTwolist
|
|
||||||
.filter(item => item.groupName === '团柏河')
|
|
||||||
.map(item => ({
|
|
||||||
latitude: Number(item.stationLatitude),
|
|
||||||
longitude: Number(item.stationLongitude)
|
|
||||||
}));
|
|
||||||
} else if (regionName === '对竹河') {
|
|
||||||
// 获取对竹河区域的所有标记点
|
|
||||||
points = this.stationTwolist
|
|
||||||
.filter(item => item.groupName === '对竹河')
|
|
||||||
.map(item => ({
|
|
||||||
latitude: Number(item.stationLatitude),
|
|
||||||
longitude: Number(item.stationLongitude)
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (points.length > 0 && this.mapCtx) {
|
|
||||||
this.mapCtx.includePoints({
|
|
||||||
points: points,
|
|
||||||
padding: [60, 60, 60, 60] // 可以调整边距以获得更好的显示效果
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
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.showToast({
|
|
||||||
title: `设备: ${marker.stationName}`,
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
// 可以在这里添加设备详情页面的跳转逻辑
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
callouttap(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.showToast({
|
|
||||||
title: `设备: ${marker.stationName}`,
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
switch2Change(name) {
|
|
||||||
if (name === "团柏河") {
|
|
||||||
this.issscd = !this.issscd;
|
|
||||||
} else {
|
|
||||||
this.isssscd = !this.isssscd;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据当前状态调整地图视野
|
|
||||||
if ((name === "团柏河" && !this.issscd) || (name === "对竹河" && !this.isssscd)) {
|
|
||||||
// 如果是显示状态(绿色圆点),调整到指定区域
|
|
||||||
setTimeout(() => {
|
|
||||||
this.adjustMapToRegion(name);
|
|
||||||
}, 300);
|
|
||||||
} else {
|
|
||||||
// 如果是隐藏状态(灰色圆点),调整到所有标记点
|
|
||||||
setTimeout(() => {
|
|
||||||
this.adjustMapToFitAllMarkers();
|
|
||||||
}, 300);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
list1query() {
|
|
||||||
// 先清除所有orient类型的标记
|
|
||||||
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];
|
|
||||||
if (item.stationType === 'orient') {
|
|
||||||
item.iconPath = this.baseUrl +'/'+ item.stationIcon;
|
|
||||||
item.latitude = Number(item.stationLatitude);
|
|
||||||
item.longitude = Number(item.stationLongitude);
|
|
||||||
item.width = 172;
|
|
||||||
item.height = 148;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
/* 样式保持不变 */
|
|
||||||
.bgimg {
|
|
||||||
position: fixed;
|
|
||||||
// z-index: -99;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.customCallout {
|
|
||||||
width: 349rpx;
|
|
||||||
height: 49rpx;
|
|
||||||
color: #fff;
|
|
||||||
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;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.customCallout1 {
|
|
||||||
width: 349rpx;
|
|
||||||
height: 49rpx;
|
|
||||||
color: #fff;
|
|
||||||
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;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.zdxq {
|
|
||||||
position: fixed;
|
|
||||||
left: 33rpx;
|
|
||||||
bottom: 36rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.zdxqitem {
|
|
||||||
padding: 8rpx 0 7rpx 17rpx;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
font-size: 22rpx;
|
|
||||||
font-family: Source Han Sans SC;
|
|
||||||
font-weight: 500;
|
|
||||||
color: #FFFFFF;
|
|
||||||
text-shadow: 0rpx 1rpx 0rpx rgba(4, 49, 52, 0.55);
|
|
||||||
width: 359rpx;
|
|
||||||
background: rgba(0, 0, 0, 0.52);
|
|
||||||
border: 1px solid #4B677C;
|
|
||||||
border-radius: 6rpx;
|
|
||||||
margin-bottom: 10rpx;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.crildon {
|
|
||||||
width: 10rpx;
|
|
||||||
height: 10rpx;
|
|
||||||
border-radius: 50%;
|
|
||||||
margin-right: 15rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.zdxqitem:last-child {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.zdxqitem image {
|
|
||||||
width: 33rpx;
|
|
||||||
height: 50rpx;
|
|
||||||
margin-right: 15rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.zdxqitem:first-child image {
|
|
||||||
width: 30rpx;
|
|
||||||
height: 40rpx;
|
|
||||||
margin-right: 15rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.textss {
|
|
||||||
flex: 1;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.imgs {
|
|
||||||
position: absolute;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
z-index: -9;
|
|
||||||
}
|
|
||||||
|
|
||||||
.switchs {
|
|
||||||
position: fixed;
|
|
||||||
top: 36rpx;
|
|
||||||
right: 40rpx;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
@ -1,22 +1,28 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<map id="map" ref="map" style="width: 100%; height: calc(100vh + 50rpx);" scale="13" :markers="markers" longitude="111.436625"
|
<map id="map" ref="map" style="width: 100%; height: calc(100vh + 50rpx);" scale="13" :markers="markers"
|
||||||
latitude="36.771975" show-location @markertap="markertap" @callouttap="callouttap">
|
longitude="112.83100231396601" latitude="36.872032399813556" show-location show-compass show-scale @markertap="markertap" >
|
||||||
</map>
|
</map>
|
||||||
<view class="zdxq">
|
<view class="zdxq">
|
||||||
<view class="zdxqitem" @click="switch2Change('团柏河')">
|
<view class="zdxqitem" @click="switch2Change('livestock')">
|
||||||
|
<image src="../../static/zhandian_xuqin_dingwei.png" mode=""></image>
|
||||||
|
<view class="textss">
|
||||||
|
畜禽污染监测站
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<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('对竹河')">
|
<view class="zdxqitem" @click="switch2Change('watershed')">
|
||||||
<image src="../../static/zhandian_xuqin_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('土壤')">
|
<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">
|
||||||
长期定位监测点
|
长期定位监测点
|
||||||
|
|
@ -29,7 +35,7 @@
|
||||||
<script>
|
<script>
|
||||||
import api from '@/api/api'
|
import api from '@/api/api'
|
||||||
import configService from '@/common/service/config.service.js';
|
import configService from '@/common/service/config.service.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -40,128 +46,149 @@
|
||||||
},
|
},
|
||||||
scale: 14,
|
scale: 14,
|
||||||
markers: [],
|
markers: [],
|
||||||
list: [],
|
markersZIndex: 1,
|
||||||
issscd: false, // 团柏河显示状态 (false表示显示)
|
lastTap: '',
|
||||||
isssscd: false, // 对竹河显示状态 (false表示显示)
|
stationList: [],
|
||||||
isSoilShow: false, // 土壤显示状态 (false表示显示)
|
cusLocationList: [],
|
||||||
stationInfo: [],
|
soilStationList: [],
|
||||||
cusLocation: [],
|
allStationList: [],
|
||||||
stationlist: [],
|
stationTwoList: [],
|
||||||
stationTwolist: [],
|
|
||||||
mapCtx: null // 添加地图上下文
|
mapCtx: null // 添加地图上下文
|
||||||
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.$nextTick(() => {
|
|
||||||
this.getList()
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
onReady() {
|
onReady() {
|
||||||
// 在onReady中初始化地图上下文
|
// 在onReady中初始化地图上下文
|
||||||
this.mapCtx = uni.createMapContext('map', this);
|
this.mapCtx = uni.createMapContext('map', this);
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
if(uni.getStorageSync('third_session')){
|
api.checkLogin(()=>{
|
||||||
uni.login({
|
this.$nextTick(() => {
|
||||||
success: function (res) {
|
this.getList()
|
||||||
this.code = res.code
|
})
|
||||||
let params = {}
|
}, () => {
|
||||||
params.jsCode = this.code
|
uni.reLaunch({
|
||||||
api.wxlogin(params).then(res=>{
|
url:'/packDetail/pages/login/login'
|
||||||
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 if(!uni.getStorageSync('third_session')){
|
|
||||||
uni.reLaunch({
|
|
||||||
url:'/packDetail/pages/login/login'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getList() {
|
getList() {
|
||||||
this.markers = []
|
this.markers = []
|
||||||
this.list = []
|
this.stationList = []
|
||||||
this.stationInfo = []
|
this.cusLocationList = []
|
||||||
this.cusLocation = []
|
this.soilStationList = []
|
||||||
this.stationlist = []
|
this.allStationList = []
|
||||||
this.stationTwolist = []
|
|
||||||
|
this.stationTwoList = []
|
||||||
|
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '加载中'
|
title: '加载中'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$http.get('/applet/survStationInfo/stationMap').then(res => {
|
this.$http.get('/applet/survStationInfo/stationMap').then(res => {
|
||||||
// 合并 stationInfo 和 deviceList
|
this.stationList = [...res.data.data.stationInfo];
|
||||||
const combinedList = [...res.data.data.stationInfo, ...res.data.data.deviceList];
|
this.cusLocationList = [...res.data.data.cusLocation];
|
||||||
this.stationlist = combinedList;
|
this.soilStationList = [...res.data.data.deviceList];
|
||||||
this.stationTwolist = [...res.data.data.stationInfo];
|
this.allStationList.push(...this.stationList);
|
||||||
|
this.allStationList.push(...this.cusLocationList);
|
||||||
console.log("合并后的stationlist+++++", this.stationlist);
|
this.allStationList.push(...this.soilStationList);
|
||||||
|
// console.log("合并后的stationlist+++++", this.allStationList);
|
||||||
// 处理所有标记点
|
// console.log("合并后的stationList+++++", this.stationList);
|
||||||
this.stationlist.forEach((item, index) => {
|
// console.log("合并后的cusLocationList+++++", this.cusLocationList);
|
||||||
|
// console.log("合并后的soilStationList+++++", this.soilStationList);
|
||||||
|
//stationType: "orient" 农田
|
||||||
|
//stationType: "livestock" 畜禽
|
||||||
|
//stationType: "watershed" 小流域
|
||||||
|
this.allStationList.forEach((item, index) => {
|
||||||
item.id = index;
|
item.id = index;
|
||||||
|
|
||||||
// 统一字段名称,处理 deviceList 和 stationInfo 的字段差异
|
|
||||||
const markerItem = {
|
|
||||||
id: item.id,
|
|
||||||
latitude: Number(item.latitude || item.stationLatitude),
|
|
||||||
longitude: Number(item.longitude || item.stationLongitude),
|
|
||||||
stationType: item.stationType || 'device', // deviceList 没有 stationType,默认为 'device'
|
|
||||||
sortNo: item.sortNo || index,
|
|
||||||
stationName: item.name || item.stationName,
|
|
||||||
stationCode: item.ids || item.stationCode || item.id,
|
|
||||||
// 添加分组信息
|
|
||||||
groupName: item.groupName || '',
|
|
||||||
// 设备类型
|
|
||||||
deviceType: item.type || null
|
|
||||||
};
|
|
||||||
|
|
||||||
this.list.push(markerItem);
|
|
||||||
|
|
||||||
// 分类处理
|
|
||||||
if (item.stationType === 'cusLocaltion') {
|
|
||||||
this.cusLocation.push(item);
|
|
||||||
}
|
|
||||||
if (item.stationType === 'orient' || item.stationType === 'livestock') {
|
|
||||||
this.stationInfo.push(item);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.issscd = false
|
this.issscd = false
|
||||||
this.isssscd = false
|
this.isssscd = false
|
||||||
this.isSoilShow = false
|
this.isSoilShow = false
|
||||||
this.qiyeChange()
|
this.enterpriseRender();// 企业渲染
|
||||||
this.list1query()
|
this.stationRender();// 站点渲染
|
||||||
this.addDeviceMarkers() // 添加设备标记
|
this.monitorRender() // 监测点渲染
|
||||||
|
|
||||||
// 延迟执行以确保标记已经添加到地图
|
// 延迟执行以确保标记已经添加到地图
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.adjustMapToFitAllMarkers();
|
this.adjustMapToFitAllMarkers();
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
enterpriseRender() {//企业点位地图渲染
|
||||||
// 添加设备标记
|
for (let i = 0; i < this.cusLocationList.length; i++) {
|
||||||
addDeviceMarkers() {
|
const item = this.cusLocationList[i];
|
||||||
this.stationlist.forEach((item, index) => {
|
item.iconPath = '/static/qiyeIcon.png';
|
||||||
// 如果是 deviceList 中的设备(有 type 字段但没有 stationType 字段)
|
item.latitude = Number(item.stationLatitude);
|
||||||
if (item.type && !item.stationType) {
|
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 iconPath = '';
|
||||||
let width = 35;
|
let width = 35;
|
||||||
let height = 35;
|
let height = 35;
|
||||||
|
|
||||||
// 根据设备类型设置不同的图标
|
// 根据设备类型设置不同的图标
|
||||||
switch(item.type) {
|
switch(item.type) {
|
||||||
case 'soil':
|
case 'soil':
|
||||||
|
|
@ -177,7 +204,6 @@
|
||||||
default:
|
default:
|
||||||
iconPath = this.baseUrl + '/icon/device/default.png';
|
iconPath = this.baseUrl + '/icon/device/default.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
const markerItem = {
|
const markerItem = {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
iconPath: iconPath,
|
iconPath: iconPath,
|
||||||
|
|
@ -194,103 +220,12 @@
|
||||||
stationName: item.name,
|
stationName: item.name,
|
||||||
stationCode: item.ids,
|
stationCode: item.ids,
|
||||||
deviceType: item.type,
|
deviceType: item.type,
|
||||||
joinCluster: false //点聚合
|
joinCluster: false, //点聚合
|
||||||
|
zIndex: this.markersZIndex,
|
||||||
};
|
};
|
||||||
this.markers.push(markerItem);
|
this.markers.push(markerItem);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 调整地图视野以包含所有标记点(类似setFitView效果)
|
|
||||||
adjustMapToFitAllMarkers() {
|
|
||||||
if (this.mapCtx && this.list.length > 0) {
|
|
||||||
this.mapCtx.includePoints({
|
|
||||||
points: this.list.map(item => ({
|
|
||||||
latitude: item.latitude,
|
|
||||||
longitude: item.longitude
|
|
||||||
})),
|
|
||||||
padding: [60, 60, 60, 60] // 上下左右的边距
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// 调整地图视野到特定区域的标记点
|
|
||||||
adjustMapToRegion(regionName) {
|
|
||||||
let points = [];
|
|
||||||
|
|
||||||
if (regionName === '团柏河') {
|
|
||||||
// 获取团柏河区域的所有标记点
|
|
||||||
points = this.stationTwolist
|
|
||||||
.filter(item => item.groupName === '团柏河')
|
|
||||||
.map(item => ({
|
|
||||||
latitude: Number(item.stationLatitude),
|
|
||||||
longitude: Number(item.stationLongitude)
|
|
||||||
}));
|
|
||||||
} else if (regionName === '对竹河') {
|
|
||||||
// 获取对竹河区域的所有标记点
|
|
||||||
points = this.stationTwolist
|
|
||||||
.filter(item => item.groupName === '对竹河')
|
|
||||||
.map(item => ({
|
|
||||||
latitude: Number(item.stationLatitude),
|
|
||||||
longitude: Number(item.stationLongitude)
|
|
||||||
}));
|
|
||||||
} else if (regionName === '土壤') {
|
|
||||||
// 获取所有土壤设备标记点
|
|
||||||
points = this.stationlist
|
|
||||||
.filter(item => item.type === 'soil' || item.deviceType === 'soil')
|
|
||||||
.map(item => ({
|
|
||||||
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)
|
|
||||||
preciseMapAdjustment(regionName) {
|
|
||||||
if (!this.mapCtx) return;
|
|
||||||
|
|
||||||
// 根据不同区域设置不同的中心和缩放级别
|
|
||||||
const regionConfigs = {
|
|
||||||
'团柏河': {
|
|
||||||
latitude: 36.5, // 实际中心纬度
|
|
||||||
longitude: 111.7, // 实际中心经度
|
|
||||||
scale: 14
|
|
||||||
},
|
|
||||||
'对竹河': {
|
|
||||||
latitude: 36.4, // 实际中心纬度
|
|
||||||
longitude: 111.6, // 实际中心经度
|
|
||||||
scale: 14
|
|
||||||
},
|
|
||||||
'土壤': {
|
|
||||||
latitude: 36.45, // 实际中心纬度
|
|
||||||
longitude: 111.65, // 实际中心经度
|
|
||||||
scale: 13
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const config = regionConfigs[regionName];
|
|
||||||
if (config) {
|
|
||||||
this.mapCtx.moveToLocation({
|
|
||||||
latitude: config.latitude,
|
|
||||||
longitude: config.longitude,
|
|
||||||
scale: config.scale
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
markertap(e) {
|
markertap(e) {
|
||||||
const index = e.detail.markerId
|
const index = e.detail.markerId
|
||||||
const marker = this.markers.find(m => m.id === index);
|
const marker = this.markers.find(m => m.id === index);
|
||||||
|
|
@ -306,122 +241,69 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
switch2Change(name) {// 焦点显示图例
|
||||||
callouttap(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.showToast({
|
|
||||||
title: `设备: ${marker.stationName}`,
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
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 //点聚合
|
|
||||||
};
|
|
||||||
this.markers.push(markerItem);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
switch2Change(name) {
|
|
||||||
// 更新对应区域的状态
|
// 更新对应区域的状态
|
||||||
const stateMap = {
|
//四种监测站:xuqin nongtian xiaoliuyu turang
|
||||||
'团柏河': 'issscd',
|
let that = this;
|
||||||
'对竹河': 'isssscd',
|
if(name === that.lastTap){
|
||||||
'土壤': 'isSoilShow'
|
that.adjustMapToFitAllMarkers();
|
||||||
};
|
that.lastTap = '';
|
||||||
|
} else {
|
||||||
if (stateMap[name]) {
|
// 聚焦到特定区域
|
||||||
this[stateMap[name]] = !this[stateMap[name]];
|
that.adjustMapToRegion(name);
|
||||||
}
|
that.lastTap = name;
|
||||||
|
// 或者使用更精确的方法:this.preciseMapAdjustment(name);
|
||||||
// 判断是否要聚焦到特定区域
|
|
||||||
const shouldFocus = {
|
}
|
||||||
'团柏河': !this.issscd,
|
|
||||||
'对竹河': !this.isssscd,
|
|
||||||
'土壤': !this.isSoilShow
|
|
||||||
};
|
|
||||||
|
|
||||||
if (shouldFocus[name]) {
|
|
||||||
// 聚焦到特定区域
|
|
||||||
setTimeout(() => {
|
|
||||||
this.adjustMapToRegion(name);
|
|
||||||
// 或者使用更精确的方法:this.preciseMapAdjustment(name);
|
|
||||||
}, 300);
|
|
||||||
} else {
|
|
||||||
// 恢复显示所有标记点
|
|
||||||
setTimeout(() => {
|
|
||||||
this.adjustMapToFitAllMarkers();
|
|
||||||
}, 300);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
// 调整地图视野以包含所有标记点(类似setFitView效果)
|
||||||
list1query() {
|
adjustMapToFitAllMarkers() {
|
||||||
// 先清除所有orient类型的标记
|
if (this.mapCtx && this.markers.length > 0) {
|
||||||
this.markers = this.markers.filter(item => item.stationType !== 'orient');
|
this.mapCtx.includePoints({
|
||||||
|
points: this.markers.map(item => ({latitude: item.latitude, longitude: item.longitude})),
|
||||||
if (!this.issscd) {
|
padding: [60, 60, 60, 60] // 上下左右的边距
|
||||||
for (let i = 0; i < this.stationlist.length; i++) {
|
});
|
||||||
const item = this.stationlist[i];
|
}
|
||||||
if (item.stationType === 'orient') {
|
},
|
||||||
item.iconPath = this.baseUrl +'/'+ item.stationIcon;
|
adjustMapToRegion(regionName) {
|
||||||
item.latitude = Number(item.stationLatitude);
|
// 调整地图视野到特定区域的标记点
|
||||||
item.longitude = Number(item.stationLongitude);
|
//stationType: "orient" 农田
|
||||||
item.width = 239;
|
//stationType: "livestock" 畜禽
|
||||||
item.height = 186;
|
//stationType: "watershed" 小流域
|
||||||
const markerItem = {
|
let that = this;
|
||||||
id: item.id,
|
let points = [];
|
||||||
iconPath: item.iconPath,
|
let markers = [];
|
||||||
latitude: item.latitude,
|
that.markersZIndex ++;
|
||||||
longitude: item.longitude,
|
that.markersZIndex ++;
|
||||||
width: item.width,
|
if (regionName === 'orient' || regionName === 'livestock' || regionName === 'watershed') {
|
||||||
height: item.height,
|
// 获取团柏河区域的所有标记点
|
||||||
customCallout: {
|
markers = this.markers.filter(item => item.stationType === regionName);
|
||||||
anchorY: 0,
|
} else if (regionName === 'soil') {
|
||||||
anchorX: 0,
|
// 获取所有土壤设备标记点
|
||||||
display: 'ALWAYS'
|
markers = this.markers.filter(item => item.type === 'soil' || item.deviceType === 'soil');
|
||||||
},
|
}
|
||||||
stationType: item.stationType,
|
console.log(this.markers)
|
||||||
stationName: item.stationName,
|
if(markers.length > 0){
|
||||||
stationCode: item.stationCode,
|
points = markers.map(item => {
|
||||||
joinCluster: false //点聚合
|
item.zIndex = that.markersZIndex;
|
||||||
};
|
return {
|
||||||
this.markers.push(markerItem);
|
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>
|
||||||
|
|
|
||||||
|
|
@ -78,31 +78,14 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
if(uni.getStorageSync('third_session')){
|
api.checkLogin(()=>{
|
||||||
uni.login({
|
this.getuserInfo();
|
||||||
success: function (res) {
|
}, () => {
|
||||||
this.code = res.code
|
uni.reLaunch({
|
||||||
let params = {}
|
url:'/packDetail/pages/login/login'
|
||||||
params.jsCode = this.code
|
})
|
||||||
api.wxlogin(params).then(res=>{
|
});
|
||||||
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 if(!uni.getStorageSync('third_session')){
|
|
||||||
uni.reLaunch({
|
|
||||||
url:'/packDetail/pages/login/login'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
this.getuserInfo()
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getuserInfo(){
|
getuserInfo(){
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
Loading…
Reference in New Issue