修改地图也页面登录跳转问题
This commit is contained in:
parent
1337f99702
commit
feac3406f9
|
|
@ -87,6 +87,7 @@
|
|||
pageNo:1,
|
||||
pageSize:4,
|
||||
isRefresher: false, //下拉刷新状态
|
||||
isLoading: false, // 添加加载状态锁
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
|
|
@ -111,62 +112,68 @@
|
|||
refresherpullingFun() {
|
||||
this.isRefresher= true
|
||||
},
|
||||
getList(){
|
||||
let params = {}
|
||||
params.pageNo = this.pageNo
|
||||
params.pageSize = this.pageSize
|
||||
uni.showLoading({
|
||||
title: '加载中'
|
||||
});
|
||||
getList(isRefresh = false) {
|
||||
// 防止重复请求
|
||||
if (this.isLoading) return
|
||||
this.isLoading = true
|
||||
|
||||
let params = {
|
||||
pageNo: this.pageNo,
|
||||
pageSize: this.pageSize
|
||||
}
|
||||
|
||||
// 只有首次加载才显示全局loading
|
||||
if (this.pageNo === 1 && !isRefresh) {
|
||||
uni.showLoading({ title: '加载中' })
|
||||
}
|
||||
|
||||
// 首次加载清空列表,下拉刷新时不清空
|
||||
if (this.pageNo === 1 && !isRefresh) {
|
||||
this.List = []
|
||||
this.$http.get('/applet/survStationInfo/page',{params:params}).then(res =>{
|
||||
if(res.data.code == 0){
|
||||
var data = res.data.data.records
|
||||
}
|
||||
|
||||
this.$http.get('/applet/survStationInfo/page', { params }).then(res => {
|
||||
this.isLoading = false
|
||||
uni.hideLoading()
|
||||
this.isRefresher = false
|
||||
|
||||
if (res.data.code === 0) {
|
||||
let data = res.data.data.records || []
|
||||
if (this.pageNo === 1) {
|
||||
this.List = data
|
||||
} else {
|
||||
this.List = this.List.concat(data)
|
||||
for(var i=0;i<this.List.length;i++){
|
||||
if(this.List[i].deviceCount >= 10000 && this.List[i].deviceCount < 100000000){
|
||||
this.List[i].deviceCount = (this.List[i].deviceCount /10000).toFixed(1) + '万'
|
||||
}
|
||||
if(this.List[i].deviceCount >= 100000000){
|
||||
this.List[i].deviceCount = (this.List[i].deviceCount /100000000).toFixed(1) + '亿'
|
||||
|
||||
// 格式化数据
|
||||
this.formatData()
|
||||
|
||||
// 更新分页状态
|
||||
this.updatePaginationStatus(res.data.data.total)
|
||||
}
|
||||
if(this.List[i].survObj.length >= 10000 && this.List[i].survObj.length < 100000000){
|
||||
this.List[i].survObj.length = (this.List[i].survObj.length /10000).toFixed(1) + '万'
|
||||
}
|
||||
if(this.List[i].survObj.length >= 100000000){
|
||||
this.List[i].survObj.length = (this.List[i].survObj.length /100000000).toFixed(1) + '亿'
|
||||
}
|
||||
if(this.List[i].survDataCount >= 10000 && this.List[i].survDataCount < 100000000){
|
||||
this.List[i].survDataCount = (this.List[i].survDataCount /10000).toFixed(1) + '万'
|
||||
}
|
||||
if(this.List[i].survDataCount >= 100000000){
|
||||
this.List[i].survDataCount = (this.List[i].survDataCount /100000000).toFixed(1) + '亿'
|
||||
}
|
||||
}
|
||||
if(res.data.data.total != 0){
|
||||
this.allNum = Number(res.data.data.total)/Number(this.pageSize)+'';
|
||||
if(this.allNum.indexOf('.') == -1) {
|
||||
this.allNum = this.allNum;
|
||||
} else {
|
||||
this.allNum = parseInt(Number(this.allNum)+1);
|
||||
}
|
||||
if(this.pageNo == this.allNum) {
|
||||
this.isLastpage = true;
|
||||
this.loadStatus='nomore'
|
||||
} else {
|
||||
this.isLastpage = false;
|
||||
// this.isLoadMore=true
|
||||
this.loadStatus = 'more'
|
||||
}
|
||||
}else{
|
||||
this.isLastpage = true;
|
||||
this.loadStatus='nomore'
|
||||
}
|
||||
}
|
||||
uni.hideLoading();
|
||||
}).catch(err => {
|
||||
this.isLoading = false
|
||||
uni.hideLoading()
|
||||
this.isRefresher = false
|
||||
})
|
||||
},
|
||||
formatData() {
|
||||
// 将数据格式化逻辑提取出来
|
||||
this.List.forEach(item => {
|
||||
item.deviceCount = this.formatNumber(item.deviceCount)
|
||||
item.survObj.length = this.formatNumber(item.survObj.length)
|
||||
item.survDataCount = this.formatNumber(item.survDataCount)
|
||||
})
|
||||
},
|
||||
|
||||
formatNumber(num) {
|
||||
if (num >= 100000000) {
|
||||
return (num / 100000000).toFixed(1) + '亿'
|
||||
} else if (num >= 10000) {
|
||||
return (num / 10000).toFixed(1) + '万'
|
||||
}
|
||||
return num || 0
|
||||
},
|
||||
lower() {
|
||||
// 最后一页了,取消下拉功能
|
||||
if (this.isLastpage) {
|
||||
|
|
|
|||
|
|
@ -97,24 +97,28 @@ export default {
|
|||
this.CustomTop = this.Custom.top
|
||||
},
|
||||
onShow() {
|
||||
var that = this
|
||||
// 检查是否已登录
|
||||
const token = uni.getStorageSync('constant');
|
||||
if (token) {
|
||||
// 已登录,直接跳转首页
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 未登录才执行微信登录流程
|
||||
var that = this;
|
||||
uni.login({
|
||||
success: function (res) {
|
||||
that.code = res.code
|
||||
let params = {}
|
||||
params.jsCode = that.code
|
||||
that.code = res.code;
|
||||
let params = {};
|
||||
params.jsCode = that.code;
|
||||
api.wxlogin(params).then(res => {
|
||||
let userInfo = res.data.data;
|
||||
uni.setStorageSync('third_session', userInfo.thirdSession);
|
||||
// api.loginCallback(res, ()=>{
|
||||
// that.login = false
|
||||
// uni.reLaunch({
|
||||
// url: '/pages/index/index'
|
||||
// })
|
||||
// }, ()=>{
|
||||
// that.login = true
|
||||
// });
|
||||
})
|
||||
// 注意:这里不要自动跳转,只存储 session
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@
|
|||
<script>
|
||||
import api from '@/api/api'
|
||||
import selectSwitch from "@/components/xuan-switch/xuan-switch.vue";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
selectSwitch
|
||||
|
|
@ -72,75 +73,224 @@
|
|||
stationInfo: [],
|
||||
pestlightMarker: null,
|
||||
stationlist: [],
|
||||
timerSet: null
|
||||
timerSet: null,
|
||||
isDataLoaded: false,
|
||||
isCheckingLogin: false, // 防止重复检查
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
// this.isscd = true
|
||||
// this.getList()
|
||||
this.$nextTick(() => {
|
||||
this.getList()
|
||||
})
|
||||
},
|
||||
onShow() {
|
||||
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: '/pages/loginindex'
|
||||
})
|
||||
}
|
||||
|
||||
onLoad() {
|
||||
console.log('地图页面加载');
|
||||
// 不在这里加载数据
|
||||
},
|
||||
|
||||
onShow() {
|
||||
console.log('地图页面显示');
|
||||
// 如果正在检查登录,不重复执行
|
||||
if (this.isCheckingLogin) {
|
||||
return;
|
||||
}
|
||||
this.checkLoginStatus();
|
||||
},
|
||||
|
||||
onReady() {
|
||||
// 1.页面准备好后,获取到map组件的执行上下文。注意:这里是取的map的id属性
|
||||
this.mapContext = uni.createMapContext("alarm_map", this);
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 统一的登录状态检查方法
|
||||
checkLoginStatus() {
|
||||
this.isCheckingLogin = true;
|
||||
|
||||
const token = uni.getStorageSync('constant');
|
||||
const session = uni.getStorageSync('third_session');
|
||||
|
||||
console.log('登录检查 - token:', !!token, 'session:', !!session);
|
||||
|
||||
// 情况1:没有任何登录凭证 -> 跳转欢迎页
|
||||
if (!token && !session) {
|
||||
console.log('无登录凭证,跳转欢迎页');
|
||||
this.isCheckingLogin = false;
|
||||
uni.reLaunch({
|
||||
url: '/pages/loginindex'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 情况2:有 third_session 但没有用户信息 -> 需要验证
|
||||
if (session && !token) {
|
||||
console.log('有session无token,验证用户');
|
||||
this.verifyUserInfo();
|
||||
return;
|
||||
}
|
||||
|
||||
// 情况3:有完整登录信息 -> 加载数据
|
||||
if (token) {
|
||||
console.log('有完整登录信息,加载地图数据');
|
||||
this.isCheckingLogin = false;
|
||||
if (!this.isDataLoaded) {
|
||||
this.getList();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 验证用户信息
|
||||
verifyUserInfo() {
|
||||
const that = this;
|
||||
|
||||
uni.login({
|
||||
success: (res) => {
|
||||
console.log('微信登录成功,code:', res.code);
|
||||
const params = {
|
||||
jsCode: res.code
|
||||
};
|
||||
|
||||
api.wxlogin(params).then(res => {
|
||||
console.log('wxlogin接口返回:', res.data);
|
||||
|
||||
// 检查接口返回状态
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
const userInfo = res.data.data;
|
||||
|
||||
// 检查用户信息是否完整
|
||||
if (userInfo.id && userInfo.id !== null && userInfo.id !== 'null') {
|
||||
// 登录有效,保存信息
|
||||
uni.setStorageSync('constant', userInfo);
|
||||
console.log('用户验证通过,保存token');
|
||||
that.isCheckingLogin = false;
|
||||
// 加载地图数据
|
||||
if (!that.isDataLoaded) {
|
||||
that.getList();
|
||||
}
|
||||
} else {
|
||||
// 用户信息不完整,跳转登录
|
||||
console.log('用户信息不完整,跳转登录页');
|
||||
that.isCheckingLogin = false;
|
||||
that.clearCacheAndGoLogin();
|
||||
}
|
||||
} else {
|
||||
// 接口返回错误
|
||||
console.log('接口返回错误:', res.data.msg || '未知错误');
|
||||
that.isCheckingLogin = false;
|
||||
that.clearCacheAndGoLogin();
|
||||
}
|
||||
}).catch((err) => {
|
||||
console.error('wxlogin请求失败:', err);
|
||||
that.isCheckingLogin = false;
|
||||
that.clearCacheAndGoLogin();
|
||||
});
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('微信登录失败:', err);
|
||||
that.isCheckingLogin = false;
|
||||
that.clearCacheAndGoLogin();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 验证 token 有效性
|
||||
verifyToken() {
|
||||
this.isCheckingLogin = false;
|
||||
if (!this.isDataLoaded) {
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
|
||||
// 清理缓存并跳转登录
|
||||
clearCacheAndGoLogin() {
|
||||
const keys = ['constant', 'third_session', 'userName', 'password'];
|
||||
keys.forEach(key => {
|
||||
uni.removeStorageSync(key);
|
||||
});
|
||||
|
||||
uni.reLaunch({
|
||||
url: '/packDetail/pages/login/login'
|
||||
});
|
||||
},
|
||||
|
||||
// 获取地图数据(添加错误处理)
|
||||
getList() {
|
||||
this.markers = []
|
||||
this.markersNoPest = []
|
||||
this.pointers = []
|
||||
this.list = []
|
||||
// 防止重复加载
|
||||
if (this.isDataLoaded) {
|
||||
console.log('数据已加载,跳过');
|
||||
return;
|
||||
}
|
||||
|
||||
// 再次检查登录状态
|
||||
const token = uni.getStorageSync('constant');
|
||||
if (!token) {
|
||||
console.log('没有登录token,不加载数据');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('开始加载地图数据');
|
||||
|
||||
this.markers = [];
|
||||
this.markersNoPest = [];
|
||||
this.pointers = [];
|
||||
this.list = [];
|
||||
this.pestlight = [];
|
||||
this.cusLocation = [];
|
||||
this.stationInfo = [];
|
||||
|
||||
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]
|
||||
console.log('地图接口返回:', res.data);
|
||||
|
||||
// ⚠️ 关键:检查数据是否存在
|
||||
if (!res.data || res.data.code !== 0) {
|
||||
console.error('地图数据加载失败:', res.data?.msg || '数据格式错误');
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: res.data?.msg || '加载失败',
|
||||
icon: 'none'
|
||||
});
|
||||
|
||||
// 如果接口返回未登录,跳转登录
|
||||
if (res.data?.code === 401 || res.data?.code === 1001) {
|
||||
this.clearCacheAndGoLogin();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// ⚠️ 检查 data 对象是否存在
|
||||
if (!res.data.data) {
|
||||
console.error('地图数据为空');
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '暂无数据',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 安全地获取数据
|
||||
const data = res.data.data;
|
||||
const pestlightData = data.pestlight || [];
|
||||
const cusLocationData = data.cusLocation || [];
|
||||
const stationInfoData = data.stationInfo || [];
|
||||
|
||||
this.stationlist = [...pestlightData, ...cusLocationData, ...stationInfoData];
|
||||
|
||||
if (this.stationlist.length === 0) {
|
||||
console.log('没有站点数据');
|
||||
uni.hideLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
this.stationlist.forEach((item, index) => {
|
||||
item.id = index;
|
||||
if (item.inType == 'pestlight') {
|
||||
this.pestlight.push(item)
|
||||
this.pestlight.push(item);
|
||||
}
|
||||
if (item.stationType == 'cusLocaltion') {
|
||||
this.cusLocation.push(item)
|
||||
this.cusLocation.push(item);
|
||||
}
|
||||
if (item.stationType == 'orient' || item.stationType == 'livestock') {
|
||||
this.stationInfo.push(item)
|
||||
this.stationInfo.push(item);
|
||||
}
|
||||
this.list.push({
|
||||
latitude: Number(item.stationLatitude),
|
||||
|
|
@ -149,41 +299,51 @@
|
|||
sortNo: item.sortNo,
|
||||
stationName: item.stationName,
|
||||
stationCode: item.stationCode
|
||||
})
|
||||
})
|
||||
this.issscd = false
|
||||
this.isssscd = false
|
||||
this.qiyeChange()
|
||||
this.list1query()
|
||||
this.list2query()
|
||||
});
|
||||
});
|
||||
|
||||
this.issscd = false;
|
||||
this.isssscd = false;
|
||||
this.qiyeChange();
|
||||
this.list1query();
|
||||
this.list2query();
|
||||
|
||||
this.isDataLoaded = true;
|
||||
|
||||
uni.hideLoading();
|
||||
})
|
||||
console.log('地图数据加载完成,共', this.stationlist.length, '个站点');
|
||||
|
||||
}).catch(err => {
|
||||
console.error('加载地图数据失败:', err);
|
||||
uni.hideLoading();
|
||||
|
||||
// 如果是网络错误,提示用户
|
||||
uni.showToast({
|
||||
title: '网络异常,请重试',
|
||||
icon: 'none'
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// 处理 stationlist 数据方法
|
||||
processStationList(stationlist) {
|
||||
if (stationlist) {
|
||||
if (stationlist && Array.isArray(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),
|
||||
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
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 生成 pointers 数据方法
|
||||
generatePointers() {
|
||||
const iconConfig = {
|
||||
// pestlight: {
|
||||
// iconPath: '/static/zhandian_sahchong_dingwei.png',
|
||||
// width: 15,
|
||||
// height: 20
|
||||
// },
|
||||
orient: {
|
||||
iconPath: '/static/zhandian_nongtian_dingwei.png',
|
||||
width: 35,
|
||||
|
|
@ -199,12 +359,13 @@
|
|||
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
|
||||
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,
|
||||
|
|
@ -213,37 +374,40 @@
|
|||
width: item.width,
|
||||
height: item.height,
|
||||
customCallout: {
|
||||
anchorY: 0, // Y轴偏移量
|
||||
anchorX: 0, // X轴偏移量
|
||||
display: 'ALWAYS' // 一直展示
|
||||
anchorY: 0,
|
||||
anchorX: 0,
|
||||
display: 'ALWAYS'
|
||||
},
|
||||
stationType: item.stationType,
|
||||
stationName: item.stationName,
|
||||
stationCode: item.stationCode,
|
||||
joinCluster: true // 是否参与点聚合
|
||||
})
|
||||
})
|
||||
joinCluster: true
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
markertap(e) {
|
||||
const index = e.detail.markerId
|
||||
console.log(e.detail,'index')
|
||||
if (['orient', 'livestock'].includes(this.list[index].stationType)) {
|
||||
const index = e.detail.markerId;
|
||||
if (this.list[index] && ['orient', 'livestock'].includes(this.list[index].stationType)) {
|
||||
uni.navigateTo({
|
||||
url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(this.list[index]))}`
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
callouttap(e) {
|
||||
const index = e.detail.markerId
|
||||
if (['orient', 'livestock'].includes(this.list[index].stationType)) {
|
||||
const index = e.detail.markerId;
|
||||
if (this.list[index] && ['orient', 'livestock'].includes(this.list[index].stationType)) {
|
||||
uni.navigateTo({
|
||||
url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(this.list[index]))}`
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
todetails(item) {
|
||||
console.log(item, '还是个然后')
|
||||
console.log(item, '还是个然后');
|
||||
},
|
||||
|
||||
switch1Change() {
|
||||
this.isscd = !this.isscd;
|
||||
let index = 0;
|
||||
|
|
@ -257,7 +421,6 @@
|
|||
item.longitude = Number(item.longitude);
|
||||
item.width = 15;
|
||||
item.height = 20;
|
||||
// 创建符合 markers 格式的对象
|
||||
const markerItem = {
|
||||
id: item.id,
|
||||
iconPath: item.iconPath,
|
||||
|
|
@ -266,32 +429,30 @@
|
|||
width: item.width,
|
||||
height: item.height,
|
||||
customCallout: {
|
||||
anchorY: 0, // Y轴偏移量
|
||||
anchorX: 0, // X轴偏移量
|
||||
display: 'ALWAYS' // 一直展示
|
||||
anchorY: 0,
|
||||
anchorX: 0,
|
||||
display: 'ALWAYS'
|
||||
},
|
||||
// stationType: item.stationType,
|
||||
inType: item.inType,
|
||||
stationName: item.stationName,
|
||||
stationCode: item.stationCode,
|
||||
joinCluster: false // 是否参与点聚合
|
||||
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'
|
||||
})
|
||||
return item.inType !== 'pestlight';
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
qiyeChange() {
|
||||
for (let i = 0; i < this.cusLocation.length; i++) {
|
||||
const item = this.cusLocation[i];
|
||||
|
|
@ -307,8 +468,7 @@
|
|||
sortNo: item.sortNo,
|
||||
stationName: item.stationName,
|
||||
stationCode: item.stationCode
|
||||
})
|
||||
// 创建符合 markers 格式的对象
|
||||
});
|
||||
const markerItem = {
|
||||
id: item.id,
|
||||
iconPath: item.iconPath,
|
||||
|
|
@ -317,26 +477,29 @@
|
|||
width: item.width,
|
||||
height: item.height,
|
||||
customCallout: {
|
||||
anchorY: 0, // Y轴偏移量
|
||||
anchorX: 0, // X轴偏移量
|
||||
display: 'ALWAYS' // 一直展示
|
||||
anchorY: 0,
|
||||
anchorX: 0,
|
||||
display: 'ALWAYS'
|
||||
},
|
||||
stationType: item.stationType,
|
||||
stationName: item.stationName,
|
||||
stationCode: item.stationCode,
|
||||
joinCluster: true // 是否参与点聚合
|
||||
joinCluster: true
|
||||
};
|
||||
this.markers.push(markerItem);
|
||||
}
|
||||
},
|
||||
|
||||
switch2Change() {
|
||||
this.issscd = !this.issscd
|
||||
this.list1query()
|
||||
this.issscd = !this.issscd;
|
||||
this.list1query();
|
||||
},
|
||||
|
||||
switch3Change() {
|
||||
this.isssscd = !this.isssscd
|
||||
this.list2query()
|
||||
this.isssscd = !this.isssscd;
|
||||
this.list2query();
|
||||
},
|
||||
|
||||
list1query() {
|
||||
if (!this.issscd) {
|
||||
for (let i = 0; i < this.stationInfo.length; i++) {
|
||||
|
|
@ -347,7 +510,6 @@
|
|||
item.longitude = Number(item.stationLongitude);
|
||||
item.width = 35;
|
||||
item.height = 52;
|
||||
// 创建符合 markers 格式的对象
|
||||
const markerItem = {
|
||||
id: item.id,
|
||||
iconPath: item.iconPath,
|
||||
|
|
@ -356,24 +518,25 @@
|
|||
width: item.width,
|
||||
height: item.height,
|
||||
customCallout: {
|
||||
anchorY: 0, // Y轴偏移量
|
||||
anchorX: 0, // X轴偏移量
|
||||
display: 'ALWAYS' // 一直展示
|
||||
anchorY: 0,
|
||||
anchorX: 0,
|
||||
display: 'ALWAYS'
|
||||
},
|
||||
stationType: item.stationType,
|
||||
stationName: item.stationName,
|
||||
stationCode: item.stationCode,
|
||||
joinCluster: true // 是否参与点聚合
|
||||
joinCluster: true
|
||||
};
|
||||
this.markers.push(markerItem);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.markers = this.markers.filter((item) => {
|
||||
return item.stationType !== 'orient'
|
||||
})
|
||||
return item.stationType !== 'orient';
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
list2query() {
|
||||
if (!this.isssscd) {
|
||||
for (let i = 0; i < this.stationInfo.length; i++) {
|
||||
|
|
@ -384,7 +547,6 @@
|
|||
item.longitude = Number(item.stationLongitude);
|
||||
item.width = 35;
|
||||
item.height = 52;
|
||||
// 创建符合 markers 格式的对象
|
||||
const markerItem = {
|
||||
id: item.id,
|
||||
iconPath: item.iconPath,
|
||||
|
|
@ -393,22 +555,22 @@
|
|||
width: item.width,
|
||||
height: item.height,
|
||||
customCallout: {
|
||||
anchorY: 0, // Y轴偏移量
|
||||
anchorX: 0, // X轴偏移量
|
||||
display: 'ALWAYS' // 一直展示
|
||||
anchorY: 0,
|
||||
anchorX: 0,
|
||||
display: 'ALWAYS'
|
||||
},
|
||||
stationType: item.stationType,
|
||||
stationName: item.stationName,
|
||||
stationCode: item.stationCode,
|
||||
joinCluster: true // 是否参与点聚合
|
||||
joinCluster: true
|
||||
};
|
||||
this.markers.push(markerItem);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.markers = this.markers.filter((item) => {
|
||||
return item.stationType !== 'livestock'
|
||||
})
|
||||
return item.stationType !== 'livestock';
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue