37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
|
import store from '@/store';
|
|||
|
import { getPublishMapVersion, getPublishMapDetail } from '@/api/jmap/map';
|
|||
|
|
|||
|
// 获取地图版本数据,和store里面的map版本做比较,如果不同
|
|||
|
// 获取发布的地图数据
|
|||
|
// 先设置地图数据
|
|||
|
// 清除列车数据
|
|||
|
export function loadMapData(skinStyle) {
|
|||
|
return new Promise((resolve, reject) => {
|
|||
|
getPublishMapVersion(skinStyle).then(resp => {
|
|||
|
let version = resp.data;
|
|||
|
let mapData = store.state.map.mapData[`mapDate_${skinStyle}`];
|
|||
|
if (mapData && mapData.version == version) {
|
|||
|
store.dispatch('map/setMapData', mapData).then(() => {
|
|||
|
store.dispatch('map/clearJlmapTrainView').then(() => {
|
|||
|
resolve();
|
|||
|
});
|
|||
|
});
|
|||
|
} else {
|
|||
|
getPublishMapDetail(skinStyle).then(res => {
|
|||
|
mapData = res.data;
|
|||
|
store.dispatch('map/setMapDataList', mapData); // 缓存地图
|
|||
|
store.dispatch('map/setMapData', mapData).then(() => {
|
|||
|
store.dispatch('map/clearJlmapTrainView').then(() => {
|
|||
|
resolve();
|
|||
|
});
|
|||
|
});
|
|||
|
}).catch(error => {
|
|||
|
reject(error);
|
|||
|
});
|
|||
|
}
|
|||
|
}).catch(error => {
|
|||
|
reject(error);
|
|||
|
});
|
|||
|
});
|
|||
|
}
|