import { ref } from 'vue';
|
import { defineStore } from 'pinia';
|
import { useFetchData } from '@/composables/fetchData';
|
import sceneInfoApi from '@/api/sceneInfoApi';
|
import { useToolboxStore } from '@/stores/toolbox';
|
|
const toolboxStore = useToolboxStore();
|
|
// 走航设备
|
export const useSceneStore = defineStore('scene', () => {
|
// 默认搜索范围1公里以内
|
const radius = ref(1);
|
const sceneList = ref([]);
|
const { loading, fetchData } = useFetchData();
|
|
function searchScene(lng, lat) {
|
if (toolboxStore.sceneSearchStatus) {
|
return fetchData(() => {
|
return sceneInfoApi
|
.searchByCoordinate(lng, lat, radius.value * 1000)
|
.then((res) => {
|
sceneList.value = res.data.filter((v) => {
|
return v.typeId != 19 && v.typeId != 20;
|
});
|
return res;
|
});
|
});
|
}
|
}
|
|
return { radius, sceneList, loading, searchScene };
|
});
|