gemercheung 1 год назад
Родитель
Сommit
8356b92ad0

+ 0 - 1
package.json

@@ -34,7 +34,6 @@
     "@iconify/iconify": "^2.1.0",
     "@logicflow/core": "^0.7.16",
     "@logicflow/extension": "^0.7.16",
-    "@types/google.maps": "^3.55.12",
     "@vue/runtime-core": "^3.2.26",
     "@vue/shared": "^3.2.26",
     "@vueuse/core": "^7.4.1",

+ 0 - 8
pnpm-lock.yaml

@@ -28,9 +28,6 @@ importers:
       '@logicflow/extension':
         specifier: ^0.7.16
         version: 0.7.16
-      '@types/google.maps':
-        specifier: ^3.55.12
-        version: 3.55.12
       '@vue/runtime-core':
         specifier: ^3.2.26
         version: 3.2.26
@@ -1314,9 +1311,6 @@ packages:
   '@types/glob@7.2.0':
     resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==}
 
-  '@types/google.maps@3.55.12':
-    resolution: {integrity: sha512-Q8MsLE+YYIrE1H8wdN69YHHAF8h7ApvF5MiMXh/zeCpP9Ut745mV9M0F4X4eobZ2WJe9k8tW2ryYjLa87IO2Sg==}
-
   '@types/graceful-fs@4.1.5':
     resolution: {integrity: sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw==}
 
@@ -7987,8 +7981,6 @@ snapshots:
       '@types/minimatch': 3.0.5
       '@types/node': 17.0.8
 
-  '@types/google.maps@3.55.12': {}
-
   '@types/graceful-fs@4.1.5':
     dependencies:
       '@types/node': 17.0.8

+ 11 - 1
src/api/mapOpt/list.ts

@@ -13,7 +13,7 @@ enum Api {
   addScene = '/service/manage_jp/project/addScene',
   delScene = '/service/manage_jp/project/delScene',
   createshare = '/service/manage_jp/projectScene/createSceneShare',
-  shareGpsScene = '/manage_jp/projectScene/getSceneMap',
+  shareGpsScene = '/service/manage_jp/projectScene/getSceneMap',
 }
 
 type listType = {};
@@ -134,3 +134,13 @@ export const CreateShareMapApi = (type: number) =>
       ignoreCancelToken: true,
     },
   });
+
+export const GetShareMapApi = (params: { ciphertext: string; type: number }) =>
+  defHttp.get<any>({
+    url: Api.shareGpsScene + `/${params.ciphertext}/${params.type}`,
+    // data: { type },
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });

BIN
src/assets/images/share.png


+ 11 - 0
src/router/routes/index.ts

@@ -68,12 +68,23 @@ export const MapRoute: AppRouteRecordRaw = {
   },
 };
 
+export const MapShareRoute: AppRouteRecordRaw = {
+  path: '/map-share',
+  name: 'MapShare',
+  component: () => import('/@/views/map/share.vue'),
+  meta: {
+    title: t('routes.dashboard.mapOpt'),
+    ignoreAuth: true,
+  },
+};
+
 // Basic routing without permission
 export const basicRoutes = [
   LoginRoute,
   MapRoute,
   WelcomeRoute,
   RootRoute,
+  MapShareRoute,
   ...mainOutRoutes,
   REDIRECT_ROUTE,
   PAGE_NOT_FOUND_ROUTE,

+ 34 - 10
src/views/map/index.vue

@@ -81,6 +81,7 @@
             optionFilterProp="label"
             immediate
             show-search
+            :placeholder="t('common.inputText')"
             allow-clear
             @select="handleSelect"
             style="width: 300px"
@@ -105,16 +106,19 @@
 
     <CustomControl position="BOTTOM_CENTER">
       <div class="share-container">
-        <Popover trigger="click" v-model:open="shareOpen">
+        <Popover trigger="click" v-model:open="shareOpen" class="pop">
           <template #content>
             <div class="share-content">
               <p>扫码分享</p>
               <QrCode :value="qrCodeShareUrl" :width="250" :height="250" />
-              <a-button text @click="handleCopy">复制链接</a-button>
+              <a-button type="link" class="btn" @click="handleCopy">复制链接</a-button>
             </div>
           </template>
           <!-- <a-button type="primary">Hover me</a-button> -->
-          <a-button class="custom-btn" @click="handleShare">分享</a-button>
+          <div class="custom-btn" @click="handleShare">
+            <img :src="shareImage" />
+            <span>分享</span>
+          </div>
         </Popover>
       </div>
     </CustomControl>
@@ -142,7 +146,7 @@
   import { QrCode } from '/@/components/Qrcode/index';
   import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
   import { useMessage } from '/@/hooks/web/useMessage';
-
+  import shareImage from '/@/assets/images/share.png';
   const { t } = useI18n();
   const router = useRouter();
   const googleKey = computed(() => import.meta.env.VITE_GOOGLE_KEY);
@@ -157,13 +161,13 @@
   const projectId = useRouteQuery('projectId');
   const type = useRouteQuery('type', 0);
   const form = ref<{
-    searchValue: null | string;
-    projectValue: null | string;
+    searchValue: undefined | string;
+    projectValue: undefined | string;
     sceneValue: null | string;
     type: number;
   }>({
-    searchValue: '',
-    projectValue: '',
+    searchValue: undefined,
+    projectValue: undefined,
     sceneValue: null,
     type: 0,
   });
@@ -246,7 +250,7 @@
     const res = await CreateShareMapApi(form.value.type);
     console.log('handleShare', res);
     const routeData = router.resolve({
-      name: 'Map',
+      name: 'MapShare',
       query: { ciphertext: res.ciphertext, type: form.value.type },
     });
     const url = location.protocol + '//' + location.hostname + '/' + routeData.href;
@@ -291,7 +295,7 @@
     }
   };
 </script>
-<style lang="less">
+<style lang="less" scoped>
   // @import './dark.less';
   #map-container {
     width: 100vw;
@@ -318,5 +322,25 @@
     flex-direction: column;
     justify-content: center;
     align-items: center;
+    color: white;
+    .btn {
+      color: rgba(0, 200, 175, 1);
+    }
+  }
+  .custom-btn {
+    width: 80px;
+    height: 80px;
+    background: rgba(26, 26, 26, 0.8);
+    border-radius: 50%;
+    color: white;
+    display: flex;
+    flex-direction: column;
+    justify-content: center;
+    gap: 5px 0;
+    align-items: center;
+    cursor: pointer;
+  }
+  :global(.ant-popover-inner) {
+    background: rgba(26, 26, 26, 0.8);
   }
 </style>

+ 2 - 2
src/views/map/mapSelectModal.vue

@@ -13,7 +13,7 @@
     <GoogleMap
       ref="mapRef"
       :api-key="googleKey"
-      mapId="DEMO_MAP_ID"
+      mapId="japan_4dkankan"
       :center="center"
       :map-type-control="false"
       :disable-default-ui="true"
@@ -163,7 +163,7 @@
             console.log('map', map);
             autocomplete.bindTo('bounds', map);
             // @ts-ignore
-            searchMarkerRef.value = new google.maps.marker.AdvancedMarkerElement({
+            searchMarkerRef.value = new google.maps.Marker({
               map,
               // @ts-ignore
               anchorPoint: new google.maps.Point(0, -29),

+ 26 - 72
src/views/map/share.vue

@@ -47,7 +47,7 @@
       </template>
     </MarkerCluster>
 
-    <CustomControl position="TOP_LEFT">
+    <!-- <CustomControl position="TOP_LEFT">
       <div class="top_left_control">
         <div>
           <ApiSelect
@@ -67,6 +67,7 @@
             style="width: 300px"
             :params="{
               type: 0,
+              ciphertext: ciphertext,
               projectId: projectId,
               searchKey: form.searchValue,
             }"
@@ -101,10 +102,10 @@
           </Select>
         </div>
       </div>
-    </CustomControl>
-
+    </CustomControl> -->
+    <!-- 
     <CustomControl position="BOTTOM_CENTER">
-      <div class="share-container">
+      <div class="share-container" >
         <Popover trigger="click" v-model:open="shareOpen">
           <template #content>
             <div class="share-content">
@@ -113,11 +114,10 @@
               <a-button text @click="handleCopy">复制链接</a-button>
             </div>
           </template>
-          <!-- <a-button type="primary">Hover me</a-button> -->
           <a-button class="custom-btn" @click="handleShare">分享</a-button>
         </Popover>
       </div>
-    </CustomControl>
+    </CustomControl> -->
   </GoogleMap>
 </template>
 
@@ -130,32 +130,29 @@
     MarkerCluster,
     CustomMarker,
     // InfoWindow,
-    CustomControl,
+    // CustomControl,
   } from 'vue3-google-map';
   import { useRouteQuery } from '@vueuse/router';
-  import { Select, SelectOption, Popover } from 'ant-design-vue';
-  import ApiSelect from '/@/components/Form/src/components/ApiSelect.vue';
-  import { useRouter } from 'vue-router';
+  // import { Select, SelectOption, Popover } from 'ant-design-vue';
+  // import ApiSelect from '/@/components/Form/src/components/ApiSelect.vue';
+  // import { useRouter } from 'vue-router';
   const loadingRef = ref(true);
   import { useI18n } from '/@/hooks/web/useI18n';
-  import { AllGpsApi, CreateShareMapApi } from '/@/api/mapOpt/list';
-  import { QrCode } from '/@/components/Qrcode/index';
-  import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
-  import { useMessage } from '/@/hooks/web/useMessage';
+  import { GetShareMapApi } from '/@/api/mapOpt/list';
+  // import { QrCode } from '/@/components/Qrcode/index';
+  // import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
+  // import { useMessage } from '/@/hooks/web/useMessage';
 
   const { t } = useI18n();
-  const router = useRouter();
+  // const router = useRouter();
   const googleKey = computed(() => import.meta.env.VITE_GOOGLE_KEY);
   const center = { lat: 35.717, lng: 139.731 };
-  const { createMessage } = useMessage();
-  // const options = ref([]);
-  // const pinOptions = { background: '#FBBC04' };
-  const shareOpen = ref(false);
-  const qrCodeShareUrl = ref('');
-  const { clipboardRef, isSuccessRef } = useCopyToClipboard(qrCodeShareUrl.value);
+  // const { createMessage } = useMessage();
+
   const lang = useRouteQuery('lang', 'ja');
-  const projectId = useRouteQuery('projectId');
+
   const type = useRouteQuery('type', 0);
+  const ciphertext = useRouteQuery('ciphertext');
   const form = ref<{
     searchValue: null | string;
     projectValue: null | string;
@@ -197,24 +194,16 @@
   );
 
   onMounted(async () => {
-    watchEffect(() => {
-      console.log(projectId.value);
-      if (projectId.value) {
-        form.value.projectValue = String(projectId.value);
-      }
-      if (type.value) {
-        form.value.type = Number(type.value);
+    watchEffect(async () => {
+      if (type.value && ciphertext.value) {
+        await sceneFetch({
+          type: type.value,
+          ciphertext: ciphertext.value,
+        });
       }
     });
   });
 
-  function reloadWithParams() {
-    console.log('reloadWithParams');
-    const routeData = router.resolve({ name: 'Map', query: { type: form.value.type } });
-    location.replace(routeData.href);
-    location.reload();
-  }
-
   function mapFitBounds(mapRef, markers) {
     let bounds;
     const api = mapRef.value.api;
@@ -237,23 +226,6 @@
     console.log('handleMarkerClick', data);
     data.webSite && window.open(data.webSite);
   };
-
-  const handleSelect = (item: any) => {
-    console.log('onSelect', item);
-  };
-
-  const handleShare = async () => {
-    const res = await CreateShareMapApi(form.value.type);
-    console.log('handleShare', res);
-    const routeData = router.resolve({
-      name: 'Map',
-      query: { ciphertext: res.ciphertext, type: form.value.type },
-    });
-    const url = location.protocol + '//' + location.hostname + '/' + routeData.href;
-
-    qrCodeShareUrl.value = url;
-  };
-
   const getMarkerData = (data) => {
     return data.map((item) => {
       const mapper = {} as any;
@@ -265,31 +237,13 @@
     });
   };
 
-  const projectFetch = async (params) => {
-    const res = await AllGpsApi(params);
-    const data = getMarkerData(res);
-    console.log('result', data.length);
-    locations.value = data;
-    return res;
-  };
   const sceneFetch = async (params) => {
-    const res = await AllGpsApi(params);
+    const res = await GetShareMapApi(params);
     const data = getMarkerData(res);
     console.log('result', data.length);
     locations.value = data;
     return res;
   };
-
-  const handleTypeSelect = () => {
-    reloadWithParams();
-  };
-
-  const handleCopy = () => {
-    clipboardRef.value = qrCodeShareUrl.value;
-    if (isSuccessRef.value) {
-      createMessage.success(t('routes.scenes.copyInfi.ok'));
-    }
-  };
 </script>
 <style lang="less">
   // @import './dark.less';