liyongli 1 gadu atpakaļ
vecāks
revīzija
d3e30ef0d1
1 mainītis faili ar 10 papildinājumiem un 15 dzēšanām
  1. 10 15
      src/view/trafficLocation/index.vue

+ 10 - 15
src/view/trafficLocation/index.vue

@@ -2,7 +2,7 @@
   <div class="trafficLocation">
     <van-nav-bar :title="title" />
     <van-cell
-      @click="openMap"
+      @click="()=>openMap(item)"
       v-for="item in che_list"
       :key="item.title"
       :title="item.title"
@@ -92,24 +92,19 @@ const che_list = ref([
 ]);
 
 function openMap(item) {
+    console.log(window.wx, item)
   if (!window.wx) return;
   window.wx.checkJsApi({
     jsApiList: ['getLocation', 'openLocation'],
     success: () => {
-      window.wx.getLocation({
-        type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
-        success: function (loc) {
-          console.log(loc);
-          //打开指定位置
-          window.wx.openLocation({
-            latitude: loc.latitude, // 纬度,浮点数,范围为90 ~ -90
-            longitude: loc.longitude, // 经度,浮点数,范围为180 ~ -180。
-            name: item.title, // 位置名
-            address: item.address, // 地址详情说明
-            scale: 18, // 地图缩放级别,整型值,范围从1~28。默认为最大
-            infoUrl: '', // 在查看位置界面底部显示的超链接,可点击跳转
-          });
-        },
+      //打开指定位置
+      window.wx.openLocation({
+        latitude: item.latitude, // 纬度,浮点数,范围为90 ~ -90
+        longitude: item.longitude, // 经度,浮点数,范围为180 ~ -180。
+        name: item.title, // 位置名
+        address: item.address, // 地址详情说明
+        scale: 18, // 地图缩放级别,整型值,范围从1~28。默认为最大
+        infoUrl: '', // 在查看位置界面底部显示的超链接,可点击跳转
       });
     },
   });