|
|
@@ -23,12 +23,13 @@
|
|
|
gap="gap.xl"
|
|
|
position="absolute"
|
|
|
inset="0"
|
|
|
+ padding="padding.md"
|
|
|
center
|
|
|
>
|
|
|
- <FlexCol center gap="gap.md" padding="padding.md" backgroundColor="white" radius="radius.md">
|
|
|
+ <FlexCol center gap="gap.xl" padding="padding.md" backgroundColor="white" radius="radius.md">
|
|
|
<Text fontConfig="importantTitle" textAlign="center">您选择的地区还未开通亮乡源数据,可联系客服开通</Text>
|
|
|
<button open-type="contact" class="remove-button-style">
|
|
|
- <FlexCol padding="space.md" radius="radius.lg" center backgroundColor="white">
|
|
|
+ <FlexCol padding="space.md" radius="radius.lg" center backgroundColor="button">
|
|
|
<Text fontConfig="primaryTitle">联系客服</Text>
|
|
|
</FlexCol>
|
|
|
</button>
|
|
|
@@ -105,6 +106,7 @@ import CommonContent from '@/api/CommonContent';
|
|
|
import Icon from '@/components/basic/Icon.vue';
|
|
|
import ActivityIndicator from '@/components/basic/ActivityIndicator.vue';
|
|
|
import type { MapMarker } from '@/types/Map';
|
|
|
+import MapApi from '@/api/map/MapApi';
|
|
|
|
|
|
const instance = getCurrentInstance();
|
|
|
const mapCtx = uni.createMapContext('prevMap', instance);
|
|
|
@@ -119,6 +121,7 @@ const emit = defineEmits([
|
|
|
'regionChanged',
|
|
|
]);
|
|
|
const ready = ref(false);
|
|
|
+const hasResItems = ref(false);
|
|
|
|
|
|
const props = defineProps<{
|
|
|
lonlat?: { longitude: number, latitude: number } | undefined;
|
|
|
@@ -144,7 +147,9 @@ const mapLoader = useSimpleDataLoader<MapMarker[]>(async () => {
|
|
|
if (!selectedRegion.value)
|
|
|
return [];
|
|
|
await waitTimeOut(200);
|
|
|
- const res = (await LightVillageApi.getVillageList(undefined, selectedRegion.value, undefined, 1, 1000)).list.map((p, i) => {
|
|
|
+ const res = (await LightVillageApi.getVillageList(undefined, selectedRegion.value, undefined, 1, 1000)).list;
|
|
|
+ hasResItems.value = res.length > 0;
|
|
|
+ const list = res.map((p, i) => {
|
|
|
villageData.set(p.id, p);
|
|
|
const maker : MapMarker = {
|
|
|
id: p.id ?? i,
|
|
|
@@ -187,37 +192,58 @@ const mapLoader = useSimpleDataLoader<MapMarker[]>(async () => {
|
|
|
}
|
|
|
|
|
|
return maker as MapMarker;
|
|
|
- });
|
|
|
+ }).filter(p =>
|
|
|
+ p.longitude && p.latitude
|
|
|
+ && !isNaN(p.longitude) && !isNaN(p.latitude)
|
|
|
+ && p.longitude > -180 && p.longitude < 180
|
|
|
+ && p.latitude > -90 && p.latitude < 90
|
|
|
+ );
|
|
|
|
|
|
mapCtx.addMarkers({
|
|
|
clear: true,
|
|
|
- markers: res,
|
|
|
+ markers: list,
|
|
|
})
|
|
|
|
|
|
if (nextNeedAutoFocus.value) {
|
|
|
- setTimeout(() => {
|
|
|
- mapCtx.includePoints({
|
|
|
- points: res.map(p => {
|
|
|
- if (!p.longitude || !p.latitude) {
|
|
|
- p.longitude = AppCofig.defaultLonLat[0];
|
|
|
- p.latitude = AppCofig.defaultLonLat[1];
|
|
|
- }
|
|
|
- return {
|
|
|
- latitude: p.latitude,
|
|
|
- longitude: p.longitude,
|
|
|
- }
|
|
|
- }),
|
|
|
- padding: [20, 20, 20, 20],
|
|
|
- });
|
|
|
- }, 200);
|
|
|
+
|
|
|
+ if (res.length > 20) {
|
|
|
+ setTimeout(() => {
|
|
|
+ mapCtx.includePoints({
|
|
|
+ points: list.map(p => {
|
|
|
+ if (!p.longitude || !p.latitude) {
|
|
|
+ p.longitude = AppCofig.defaultLonLat[0];
|
|
|
+ p.latitude = AppCofig.defaultLonLat[1];
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ latitude: p.latitude,
|
|
|
+ longitude: p.longitude,
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ padding: [20, 20, 20, 20],
|
|
|
+ });
|
|
|
+ }, 200);
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ const currentRegionName = regionLoader.content.value?.find(p => p.id == selectedRegion.value)?.name;
|
|
|
+ if (currentRegionName) {
|
|
|
+ const res = (await MapApi.simpleGetRegion(currentRegionName)).requireData();
|
|
|
+ mapCtx.moveToLocation({
|
|
|
+ latitude: Number(res.center.split(',')[1]),
|
|
|
+ longitude: Number(res.center.split(',')[0]),
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
ready.value = true;
|
|
|
- return res;
|
|
|
+ return list;
|
|
|
}, false, false);
|
|
|
|
|
|
const isEmptyRegion = computed(() => {
|
|
|
- return (!mapLoader.content.value?.length) && ready.value;
|
|
|
+ return !hasResItems.value && ready.value;
|
|
|
});
|
|
|
|
|
|
function onMarkerTap(e: any) {
|