panhui 5 лет назад
Родитель
Сommit
d015325698
2 измененных файлов с 31 добавлено и 17 удалено
  1. 28 6
      src/main/map/src/views/ChooseLocation.vue
  2. 3 11
      src/main/map/src/views/Tim.vue

+ 28 - 6
src/main/map/src/views/ChooseLocation.vue

@@ -1,7 +1,8 @@
 <template>
-    <iframe id="iframe" frameborder="0" scrolling="no" :src="src"> </iframe>
+    <iframe id="iframe" ref="iframe" frameborder="0" scrolling="no"> </iframe>
 </template>
 <script>
+import axios from 'axios'
 window.addEventListener(
     'message',
     function(event) {
@@ -19,14 +20,15 @@ export default {
     name: '',
     data() {
         return {
-            location: '',
+						location: '',
+						tengxunKey:"GLFBZ-ZR2W6-76XSA-MF7CQ-GDJ6Z-6FB5K"
         };
     },
     computed: {
         src() {
             if (this.location) {
                 return (
-                    'https://apis.map.qq.com/tools/locpicker?search=1&type=1&zoom=18&key=GLFBZ-ZR2W6-76XSA-MF7CQ-GDJ6Z-6FB5K&referer=Dingdong&coord=' +
+                    'https://apis.map.qq.com/tools/locpicker?search=1&type=1&zoom=18&key=${}&referer=Dingdong&coord=' +
                     this.location
                 );
             } else {
@@ -35,10 +37,30 @@ export default {
         },
     },
     created() {
-        if (this.$route.query.location) {
-            this.location = this.$route.query.location;
+			if("geolocation" in navigator) {
+				navigator.geolocation.getCurrentPosition((geolocation)=>{
+					const {coords}=geolocation
+					this.ChangeLocation(coords).then(res=>{
+						console.log(res)
+					})
+					// this.location=coords.latitude+','+coords.longitude
+					// console.log(	this.location)
+					// this.$refs.iframe.src=  'https://apis.map.qq.com/tools/locpicker?search=1&type=1&zoom=18&key=GLFBZ-ZR2W6-76XSA-MF7CQ-GDJ6Z-6FB5K&referer=Dingdong&coord=' +
+					// 						this.location
+					});
+			}
+		},
+		methods:{
+			ChangeLocation(coords){
+			 return 	axios.get(
+        `https://apis.map.qq.com/ws/coord/v1/translate?locations=${coords.latitude},${coords.longitude}&type=1&key=${this.tengxunKey}&get_poi=1`,
+        {
+          prefix: "",
+          mode: "no-cors",
         }
-    },
+      )
+			}
+		}
 };
 </script>
 <style lang='less' scoped>

+ 3 - 11
src/main/map/src/views/Tim.vue

@@ -23,7 +23,8 @@ export default {
         ...mapState(['userInfo']),
     },
     mounted() {
-        window.chatLogin = this.chatLogin;
+				window.chatLogin = this.chatLogin;
+				window.sendMessage=this.sendMessage;
     },
     methods: {
         chatLogin(userID, userSig) {
@@ -95,15 +96,11 @@ export default {
                 }
             });
 
+            // eslint-disable-next-line no-unused-vars
             this.tim.on(TIM.EVENT.GROUP_LIST_UPDATED, (event)=>{
                 // 收到群组列表更新通知,可通过遍历 event.data 获取群组列表数据并渲染到页面
                 // event.name - TIM.EVENT.GROUP_LIST_UPDATED
                 // event.data - 存储 Group 对象的数组 - [Group]
-                if (window.ReactNativeWebView) {
-                    window.ReactNativeWebView.postMessage(
-                        JSON.stringify(event.data)
-                    );
-                }
             });
 
             // eslint-disable-next-line no-unused-vars
@@ -126,11 +123,6 @@ export default {
                 // event.name - TIM.EVENT.ERROR
                 // event.data.code - 错误码
                 // event.data.message - 错误信息
-                if (window.ReactNativeWebView) {
-                    window.ReactNativeWebView.postMessage(
-                        JSON.stringify(event)
-                    );
-                }
             });
 
             // eslint-disable-next-line no-unused-vars