Просмотр исходного кода

Merge branch 'v2.0.0-ga' of http://192.168.0.115:3000/bill/fuse-code into v2.0.0-ga

xzw 1 месяц назад
Родитель
Сommit
ddd779bc72
6 измененных файлов с 63 добавлено и 26 удалено
  1. 34 5
      src/api/sys.ts
  2. 2 2
      src/layout/show/index.vue
  3. 23 16
      src/store/map.ts
  4. 2 1
      src/store/record.ts
  5. 1 1
      src/utils/index.ts
  6. 1 1
      vite.config.ts

+ 34 - 5
src/api/sys.ts

@@ -1,8 +1,15 @@
-import { UPLOAD_FILE, UPLOAD_HEADS, CASE_INFO, AUTH_PWD, UPDATE_CASE_INFO } from "./constant";
+import {
+  UPLOAD_FILE,
+  UPLOAD_HEADS,
+  CASE_INFO,
+  AUTH_PWD,
+  UPDATE_CASE_INFO,
+} from "./constant";
 import { axios } from "./instance";
 import { jsonToForm } from "@/utils";
 import { params } from "@/env";
 import { Scene } from "./scene";
+import { aMapToWgs84 } from "@/utils/coord";
 
 type UploadFile = LocalFile | string;
 
@@ -27,8 +34,8 @@ export const uploadFile = async (file: UploadFile, suffix = ".png") => {
 
 export interface Case {
   sceneVoList: Scene[];
-  createTime: string
-  fusionTitle?: string
+  createTime: string;
+  fusionTitle?: string;
   platformId: null;
 }
 
@@ -40,9 +47,31 @@ export const getCaseInfo = async () => {
 };
 
 export const updateCaseInfo = async (data: Case) => {
-  return axios.post(UPDATE_CASE_INFO, { ...data })
-}
+  return axios.post(UPDATE_CASE_INFO, { ...data });
+};
 
 // 校验密码
 export const authSharePassword = (randCode: string) =>
   axios<boolean>(AUTH_PWD, { params: { randCode, fusionId: params.caseId } });
+
+export const searchAddress = async (keyword: string, mapId: number) => {
+  const data = await axios.post("/fusion/mapConfig/geocode", {
+    address: keyword,
+    mapId,
+  });
+  return data.map((item: any) => {
+    const latlng = item.location
+      .split(",")
+      .map((it: string) => Number(it.trim()));
+
+    const p = aMapToWgs84({
+      x: Number(latlng[0]),
+      y: Number(latlng[1]),
+    });
+    return {
+      id: item.location,
+      address: item.name + `(${item.address})`,
+      latlng: [p.x, p.y],
+    };
+  });
+};

+ 2 - 2
src/layout/show/index.vue

@@ -109,7 +109,7 @@ const initialSys = async () => {
   await loadModel(fuseModel);
   await asyncTimeout(1000);
   loaded.value = true;
-  custom.showLeftPano = true;
+  // custom.showLeftPano = true;
 };
 initialSys();
 defTitle.value = "";
@@ -118,7 +118,7 @@ initialScenes();
 watchEffect((onCleanup) => {
   if (loaded.value && appEl.value && scenes.value.length && !fuseModels.value.length) {
     loadModel(scenes.value[0] as any);
-    custom.showLeftPano = true;
+    // custom.showLeftPano = true;
   }
 });
 </script>

+ 23 - 16
src/store/map.ts

@@ -1,4 +1,7 @@
 import { params } from "@/env";
+import { aMapToWgs84 } from "@/utils/coord";
+import { searchAddress as searchAddressRaw } from '@/api/sys'
+import { fetchMapTiles } from "@/api/map-tile";
 
 export type Address = { address: string; latlng: number[]; id: string };
 const platform = {
@@ -15,13 +18,21 @@ const platform = {
         }
         console.log(res);
         const items = res.geocodes
-          .map((item: any) => ({
-            id: item.location,
-            address: item.formatted_address,
-            latlng: item.location
+          .map((item: any) => {
+            const ll = item.location
               .split(",")
-              .map((item: string) => Number(item.trim())),
-          }))
+              .map((item: string) => Number(item.trim()));
+            const p = aMapToWgs84({
+              x: Number(ll[0]),
+              y: Number(ll[1]),
+            });
+
+            return {
+              id: item.location,
+              address: item.formatted_address,
+              latlng: [p.x, p.y]
+            };
+          })
           .slice(0, 10);
         return items;
       });
@@ -59,14 +70,10 @@ const platform = {
   },
 };
 
-export const searchAddress = (val: string): Promise<Address[]> => {
-  if (!val) return Promise.resolve([]);
-  console.log(import.meta.env.VITE_MAP_PLATFORM)
-  const p = (
-    params.mapPlatform && params.mapPlatform in platform
-      ? params.mapPlatform
-      : import.meta.env.VITE_MAP_PLATFORM
-  ) as keyof typeof platform;
-
-  return platform[p](val);
+export const searchAddress = async (val: string): Promise<Address[]> => {
+  if (!val) return [];
+  const tiles = await fetchMapTiles()
+  const items = await searchAddressRaw(val, tiles[0].id);
+  console.log(items)
+  return items
 };

+ 2 - 1
src/store/record.ts

@@ -80,7 +80,8 @@ const getRecordMergeFiles = (record: Record) => {
 }
 
 export const initialRecords = async () => {
-  const serviceRecords = await fetchRecords()
+  const serviceRecords: Records = []
+  // const serviceRecords = await fetchRecords()
   unSetModelUpdate(() => records.value = serviceRecords)
   await Promise.all(records.value.map(initRecordFragmentsByRecord))
   for (const record of records.value) {

+ 1 - 1
src/utils/index.ts

@@ -329,7 +329,7 @@ export function isFirefoxBelow(targetVersion = "115.9") {
   const cm = ua.match(/Chrome\/([0-9]+(?:\.[0-9]+)*)/i);
   if (cm && cm[1]) {
     const ver = cm[1];
-    return compareVersionStrings(ver, '108') < 0;
+    return compareVersionStrings(ver, '80') < 0;
   }
 
   // 不是 Firefox 或版本未知

+ 1 - 1
vite.config.ts

@@ -11,7 +11,7 @@ const oss = `http://192.168.0.125:1804/`
 const ip = `http://192.168.0.125:1804/`
 const proxy = {
   '/offlineData': {
-    target: 'http://192.168.0.43:9000/',
+    target: 'http://192.168.0.13:8080/',
     changeOrigin: true,
     rewrite: path => path.replace(/^\/offlineData/, '')
   },