修改地图也页面登录跳转问题
This commit is contained in:
parent
1337f99702
commit
feac3406f9
|
|
@ -87,6 +87,7 @@
|
||||||
pageNo:1,
|
pageNo:1,
|
||||||
pageSize:4,
|
pageSize:4,
|
||||||
isRefresher: false, //下拉刷新状态
|
isRefresher: false, //下拉刷新状态
|
||||||
|
isLoading: false, // 添加加载状态锁
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
|
|
@ -111,62 +112,68 @@
|
||||||
refresherpullingFun() {
|
refresherpullingFun() {
|
||||||
this.isRefresher= true
|
this.isRefresher= true
|
||||||
},
|
},
|
||||||
getList(){
|
getList(isRefresh = false) {
|
||||||
let params = {}
|
// 防止重复请求
|
||||||
params.pageNo = this.pageNo
|
if (this.isLoading) return
|
||||||
params.pageSize = this.pageSize
|
this.isLoading = true
|
||||||
uni.showLoading({
|
|
||||||
title: '加载中'
|
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.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)
|
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){
|
}).catch(err => {
|
||||||
this.List[i].survObj.length = (this.List[i].survObj.length /10000).toFixed(1) + '万'
|
this.isLoading = false
|
||||||
}
|
uni.hideLoading()
|
||||||
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();
|
|
||||||
this.isRefresher = false
|
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() {
|
lower() {
|
||||||
// 最后一页了,取消下拉功能
|
// 最后一页了,取消下拉功能
|
||||||
if (this.isLastpage) {
|
if (this.isLastpage) {
|
||||||
|
|
|
||||||
|
|
@ -97,24 +97,28 @@ export default {
|
||||||
this.CustomTop = this.Custom.top
|
this.CustomTop = this.Custom.top
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
var that = this
|
// 检查是否已登录
|
||||||
|
const token = uni.getStorageSync('constant');
|
||||||
|
if (token) {
|
||||||
|
// 已登录,直接跳转首页
|
||||||
|
uni.reLaunch({
|
||||||
|
url: '/pages/index/index'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 未登录才执行微信登录流程
|
||||||
|
var that = this;
|
||||||
uni.login({
|
uni.login({
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
that.code = res.code
|
that.code = res.code;
|
||||||
let params = {}
|
let params = {};
|
||||||
params.jsCode = that.code
|
params.jsCode = that.code;
|
||||||
api.wxlogin(params).then(res => {
|
api.wxlogin(params).then(res => {
|
||||||
let userInfo = res.data.data;
|
let userInfo = res.data.data;
|
||||||
uni.setStorageSync('third_session', userInfo.thirdSession);
|
uni.setStorageSync('third_session', userInfo.thirdSession);
|
||||||
// api.loginCallback(res, ()=>{
|
// 注意:这里不要自动跳转,只存储 session
|
||||||
// that.login = false
|
});
|
||||||
// uni.reLaunch({
|
|
||||||
// url: '/pages/index/index'
|
|
||||||
// })
|
|
||||||
// }, ()=>{
|
|
||||||
// that.login = true
|
|
||||||
// });
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@
|
||||||
<script>
|
<script>
|
||||||
import api from '@/api/api'
|
import api from '@/api/api'
|
||||||
import selectSwitch from "@/components/xuan-switch/xuan-switch.vue";
|
import selectSwitch from "@/components/xuan-switch/xuan-switch.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
selectSwitch
|
selectSwitch
|
||||||
|
|
@ -72,75 +73,224 @@
|
||||||
stationInfo: [],
|
stationInfo: [],
|
||||||
pestlightMarker: null,
|
pestlightMarker: null,
|
||||||
stationlist: [],
|
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() {
|
onReady() {
|
||||||
// 1.页面准备好后,获取到map组件的执行上下文。注意:这里是取的map的id属性
|
|
||||||
this.mapContext = uni.createMapContext("alarm_map", this);
|
this.mapContext = uni.createMapContext("alarm_map", this);
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
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() {
|
getList() {
|
||||||
this.markers = []
|
// 防止重复加载
|
||||||
this.markersNoPest = []
|
if (this.isDataLoaded) {
|
||||||
this.pointers = []
|
console.log('数据已加载,跳过');
|
||||||
this.list = []
|
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({
|
uni.showLoading({
|
||||||
title: '加载中'
|
title: '加载中'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$http.get('/applet/survStationInfo/stationMap').then(res => {
|
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) => {
|
this.stationlist.forEach((item, index) => {
|
||||||
item.id = index;
|
item.id = index;
|
||||||
if (item.inType == 'pestlight') {
|
if (item.inType == 'pestlight') {
|
||||||
this.pestlight.push(item)
|
this.pestlight.push(item);
|
||||||
}
|
}
|
||||||
if (item.stationType == 'cusLocaltion') {
|
if (item.stationType == 'cusLocaltion') {
|
||||||
this.cusLocation.push(item)
|
this.cusLocation.push(item);
|
||||||
}
|
}
|
||||||
if (item.stationType == 'orient' || item.stationType == 'livestock') {
|
if (item.stationType == 'orient' || item.stationType == 'livestock') {
|
||||||
this.stationInfo.push(item)
|
this.stationInfo.push(item);
|
||||||
}
|
}
|
||||||
this.list.push({
|
this.list.push({
|
||||||
latitude: Number(item.stationLatitude),
|
latitude: Number(item.stationLatitude),
|
||||||
|
|
@ -149,41 +299,51 @@
|
||||||
sortNo: item.sortNo,
|
sortNo: item.sortNo,
|
||||||
stationName: item.stationName,
|
stationName: item.stationName,
|
||||||
stationCode: item.stationCode
|
stationCode: item.stationCode
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
this.issscd = false
|
|
||||||
this.isssscd = false
|
this.issscd = false;
|
||||||
this.qiyeChange()
|
this.isssscd = false;
|
||||||
this.list1query()
|
this.qiyeChange();
|
||||||
this.list2query()
|
this.list1query();
|
||||||
|
this.list2query();
|
||||||
|
|
||||||
|
this.isDataLoaded = true;
|
||||||
|
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
})
|
console.log('地图数据加载完成,共', this.stationlist.length, '个站点');
|
||||||
|
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('加载地图数据失败:', err);
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
|
// 如果是网络错误,提示用户
|
||||||
|
uni.showToast({
|
||||||
|
title: '网络异常,请重试',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 处理 stationlist 数据方法
|
// 处理 stationlist 数据方法
|
||||||
processStationList(stationlist) {
|
processStationList(stationlist) {
|
||||||
if (stationlist) {
|
if (stationlist && Array.isArray(stationlist)) {
|
||||||
stationlist.forEach(item => {
|
stationlist.forEach(item => {
|
||||||
this.list.push({
|
this.list.push({
|
||||||
latitude: item.inType === 'pestlight' ? Number(item.latitude) : Number(item
|
latitude: item.inType === 'pestlight' ? Number(item.latitude) : Number(item.stationLatitude),
|
||||||
.stationLatitude),
|
longitude: item.inType === 'pestlight' ? Number(item.longitude) : Number(item.stationLongitude),
|
||||||
longitude: item.inType === 'pestlight' ? Number(item.longitude) : Number(item
|
|
||||||
.stationLongitude),
|
|
||||||
stationType: item.inType === 'pestlight' ? 'pestlight' : item.stationType,
|
stationType: item.inType === 'pestlight' ? 'pestlight' : item.stationType,
|
||||||
sortNo: item.sortNo,
|
sortNo: item.sortNo,
|
||||||
stationName: item.stationName,
|
stationName: item.stationName,
|
||||||
stationCode: item.stationCode
|
stationCode: item.stationCode
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 生成 pointers 数据方法
|
// 生成 pointers 数据方法
|
||||||
generatePointers() {
|
generatePointers() {
|
||||||
const iconConfig = {
|
const iconConfig = {
|
||||||
// pestlight: {
|
|
||||||
// iconPath: '/static/zhandian_sahchong_dingwei.png',
|
|
||||||
// width: 15,
|
|
||||||
// height: 20
|
|
||||||
// },
|
|
||||||
orient: {
|
orient: {
|
||||||
iconPath: '/static/zhandian_nongtian_dingwei.png',
|
iconPath: '/static/zhandian_nongtian_dingwei.png',
|
||||||
width: 35,
|
width: 35,
|
||||||
|
|
@ -199,12 +359,13 @@
|
||||||
width: 35,
|
width: 35,
|
||||||
height: 52
|
height: 52
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
this.list.forEach((item, i) => {
|
this.list.forEach((item, i) => {
|
||||||
const config = iconConfig[item.stationType] || {}
|
const config = iconConfig[item.stationType] || {};
|
||||||
item.iconPath = config.iconPath || ''
|
item.iconPath = config.iconPath || '';
|
||||||
item.width = config.width || 0
|
item.width = config.width || 0;
|
||||||
item.height = config.height || 0
|
item.height = config.height || 0;
|
||||||
this.pointers.push({
|
this.pointers.push({
|
||||||
id: i,
|
id: i,
|
||||||
iconPath: item.iconPath,
|
iconPath: item.iconPath,
|
||||||
|
|
@ -213,37 +374,40 @@
|
||||||
width: item.width,
|
width: item.width,
|
||||||
height: item.height,
|
height: item.height,
|
||||||
customCallout: {
|
customCallout: {
|
||||||
anchorY: 0, // Y轴偏移量
|
anchorY: 0,
|
||||||
anchorX: 0, // X轴偏移量
|
anchorX: 0,
|
||||||
display: 'ALWAYS' // 一直展示
|
display: 'ALWAYS'
|
||||||
},
|
},
|
||||||
stationType: item.stationType,
|
stationType: item.stationType,
|
||||||
stationName: item.stationName,
|
stationName: item.stationName,
|
||||||
stationCode: item.stationCode,
|
stationCode: item.stationCode,
|
||||||
joinCluster: true // 是否参与点聚合
|
joinCluster: true
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
markertap(e) {
|
markertap(e) {
|
||||||
const index = e.detail.markerId
|
const index = e.detail.markerId;
|
||||||
console.log(e.detail,'index')
|
if (this.list[index] && ['orient', 'livestock'].includes(this.list[index].stationType)) {
|
||||||
if (['orient', 'livestock'].includes(this.list[index].stationType)) {
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(this.list[index]))}`
|
url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(this.list[index]))}`
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
callouttap(e) {
|
callouttap(e) {
|
||||||
const index = e.detail.markerId
|
const index = e.detail.markerId;
|
||||||
if (['orient', 'livestock'].includes(this.list[index].stationType)) {
|
if (this.list[index] && ['orient', 'livestock'].includes(this.list[index].stationType)) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(this.list[index]))}`
|
url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(this.list[index]))}`
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
todetails(item) {
|
todetails(item) {
|
||||||
console.log(item, '还是个然后')
|
console.log(item, '还是个然后');
|
||||||
},
|
},
|
||||||
|
|
||||||
switch1Change() {
|
switch1Change() {
|
||||||
this.isscd = !this.isscd;
|
this.isscd = !this.isscd;
|
||||||
let index = 0;
|
let index = 0;
|
||||||
|
|
@ -257,7 +421,6 @@
|
||||||
item.longitude = Number(item.longitude);
|
item.longitude = Number(item.longitude);
|
||||||
item.width = 15;
|
item.width = 15;
|
||||||
item.height = 20;
|
item.height = 20;
|
||||||
// 创建符合 markers 格式的对象
|
|
||||||
const markerItem = {
|
const markerItem = {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
iconPath: item.iconPath,
|
iconPath: item.iconPath,
|
||||||
|
|
@ -266,32 +429,30 @@
|
||||||
width: item.width,
|
width: item.width,
|
||||||
height: item.height,
|
height: item.height,
|
||||||
customCallout: {
|
customCallout: {
|
||||||
anchorY: 0, // Y轴偏移量
|
anchorY: 0,
|
||||||
anchorX: 0, // X轴偏移量
|
anchorX: 0,
|
||||||
display: 'ALWAYS' // 一直展示
|
display: 'ALWAYS'
|
||||||
},
|
},
|
||||||
// stationType: item.stationType,
|
|
||||||
inType: item.inType,
|
inType: item.inType,
|
||||||
stationName: item.stationName,
|
stationName: item.stationName,
|
||||||
stationCode: item.stationCode,
|
stationCode: item.stationCode,
|
||||||
joinCluster: false // 是否参与点聚合
|
joinCluster: false
|
||||||
};
|
};
|
||||||
this.markers.push(markerItem);
|
this.markers.push(markerItem);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
// this.markers = this.markers.concat(aa);
|
|
||||||
if (index >= this.pestlight.length) {
|
if (index >= this.pestlight.length) {
|
||||||
clearInterval(this.timerSet);
|
clearInterval(this.timerSet);
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
clearInterval(this.timerSet);
|
clearInterval(this.timerSet);
|
||||||
this.markers = this.markers.filter((item) => {
|
this.markers = this.markers.filter((item) => {
|
||||||
return item.inType !== 'pestlight'
|
return item.inType !== 'pestlight';
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
qiyeChange() {
|
qiyeChange() {
|
||||||
for (let i = 0; i < this.cusLocation.length; i++) {
|
for (let i = 0; i < this.cusLocation.length; i++) {
|
||||||
const item = this.cusLocation[i];
|
const item = this.cusLocation[i];
|
||||||
|
|
@ -307,8 +468,7 @@
|
||||||
sortNo: item.sortNo,
|
sortNo: item.sortNo,
|
||||||
stationName: item.stationName,
|
stationName: item.stationName,
|
||||||
stationCode: item.stationCode
|
stationCode: item.stationCode
|
||||||
})
|
});
|
||||||
// 创建符合 markers 格式的对象
|
|
||||||
const markerItem = {
|
const markerItem = {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
iconPath: item.iconPath,
|
iconPath: item.iconPath,
|
||||||
|
|
@ -317,26 +477,29 @@
|
||||||
width: item.width,
|
width: item.width,
|
||||||
height: item.height,
|
height: item.height,
|
||||||
customCallout: {
|
customCallout: {
|
||||||
anchorY: 0, // Y轴偏移量
|
anchorY: 0,
|
||||||
anchorX: 0, // X轴偏移量
|
anchorX: 0,
|
||||||
display: 'ALWAYS' // 一直展示
|
display: 'ALWAYS'
|
||||||
},
|
},
|
||||||
stationType: item.stationType,
|
stationType: item.stationType,
|
||||||
stationName: item.stationName,
|
stationName: item.stationName,
|
||||||
stationCode: item.stationCode,
|
stationCode: item.stationCode,
|
||||||
joinCluster: true // 是否参与点聚合
|
joinCluster: true
|
||||||
};
|
};
|
||||||
this.markers.push(markerItem);
|
this.markers.push(markerItem);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
switch2Change() {
|
switch2Change() {
|
||||||
this.issscd = !this.issscd
|
this.issscd = !this.issscd;
|
||||||
this.list1query()
|
this.list1query();
|
||||||
},
|
},
|
||||||
|
|
||||||
switch3Change() {
|
switch3Change() {
|
||||||
this.isssscd = !this.isssscd
|
this.isssscd = !this.isssscd;
|
||||||
this.list2query()
|
this.list2query();
|
||||||
},
|
},
|
||||||
|
|
||||||
list1query() {
|
list1query() {
|
||||||
if (!this.issscd) {
|
if (!this.issscd) {
|
||||||
for (let i = 0; i < this.stationInfo.length; i++) {
|
for (let i = 0; i < this.stationInfo.length; i++) {
|
||||||
|
|
@ -347,7 +510,6 @@
|
||||||
item.longitude = Number(item.stationLongitude);
|
item.longitude = Number(item.stationLongitude);
|
||||||
item.width = 35;
|
item.width = 35;
|
||||||
item.height = 52;
|
item.height = 52;
|
||||||
// 创建符合 markers 格式的对象
|
|
||||||
const markerItem = {
|
const markerItem = {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
iconPath: item.iconPath,
|
iconPath: item.iconPath,
|
||||||
|
|
@ -356,24 +518,25 @@
|
||||||
width: item.width,
|
width: item.width,
|
||||||
height: item.height,
|
height: item.height,
|
||||||
customCallout: {
|
customCallout: {
|
||||||
anchorY: 0, // Y轴偏移量
|
anchorY: 0,
|
||||||
anchorX: 0, // X轴偏移量
|
anchorX: 0,
|
||||||
display: 'ALWAYS' // 一直展示
|
display: 'ALWAYS'
|
||||||
},
|
},
|
||||||
stationType: item.stationType,
|
stationType: item.stationType,
|
||||||
stationName: item.stationName,
|
stationName: item.stationName,
|
||||||
stationCode: item.stationCode,
|
stationCode: item.stationCode,
|
||||||
joinCluster: true // 是否参与点聚合
|
joinCluster: true
|
||||||
};
|
};
|
||||||
this.markers.push(markerItem);
|
this.markers.push(markerItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.markers = this.markers.filter((item) => {
|
this.markers = this.markers.filter((item) => {
|
||||||
return item.stationType !== 'orient'
|
return item.stationType !== 'orient';
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
list2query() {
|
list2query() {
|
||||||
if (!this.isssscd) {
|
if (!this.isssscd) {
|
||||||
for (let i = 0; i < this.stationInfo.length; i++) {
|
for (let i = 0; i < this.stationInfo.length; i++) {
|
||||||
|
|
@ -384,7 +547,6 @@
|
||||||
item.longitude = Number(item.stationLongitude);
|
item.longitude = Number(item.stationLongitude);
|
||||||
item.width = 35;
|
item.width = 35;
|
||||||
item.height = 52;
|
item.height = 52;
|
||||||
// 创建符合 markers 格式的对象
|
|
||||||
const markerItem = {
|
const markerItem = {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
iconPath: item.iconPath,
|
iconPath: item.iconPath,
|
||||||
|
|
@ -393,22 +555,22 @@
|
||||||
width: item.width,
|
width: item.width,
|
||||||
height: item.height,
|
height: item.height,
|
||||||
customCallout: {
|
customCallout: {
|
||||||
anchorY: 0, // Y轴偏移量
|
anchorY: 0,
|
||||||
anchorX: 0, // X轴偏移量
|
anchorX: 0,
|
||||||
display: 'ALWAYS' // 一直展示
|
display: 'ALWAYS'
|
||||||
},
|
},
|
||||||
stationType: item.stationType,
|
stationType: item.stationType,
|
||||||
stationName: item.stationName,
|
stationName: item.stationName,
|
||||||
stationCode: item.stationCode,
|
stationCode: item.stationCode,
|
||||||
joinCluster: true // 是否参与点聚合
|
joinCluster: true
|
||||||
};
|
};
|
||||||
this.markers.push(markerItem);
|
this.markers.push(markerItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.markers = this.markers.filter((item) => {
|
this.markers = this.markers.filter((item) => {
|
||||||
return item.stationType !== 'livestock'
|
return item.stationType !== 'livestock';
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue