Browse Source

附近门店

DESKTOP-SVI9JE1\muzen 1 year ago
parent
commit
d5648f6d59
1 changed files with 27 additions and 20 deletions
  1. 27 20
      src/pages/map/index.vue

+ 27 - 20
src/pages/map/index.vue

@@ -57,7 +57,7 @@
     <uni-popup ref="popup" type="bottom">
       <view class="popup">
         <view class="title" flex center>请选择地图</view>
-        <view class="item" flex center v-for="item in mapList" :key="item.value" @click="openMap(item.value)">
+        <view class="item" flex center v-for="item in mapList" :key="item.value" @click="openMap(item)">
           {{ item.name }}
         </view>
       </view>
@@ -108,14 +108,17 @@ export default {
       geolocation: null,
       // 地图App
       mapList: [{
-        value: 1,
-        name: '腾讯地图'
+        id: 1,
+        name: '腾讯地图',
+        value: 'qqMap'
       }, {
-        value: 2,
-        name: '百度地图'
+        id: 2,
+        name: '百度地图',
+        value: 'baiduMap'
       }, {
-        value: 3,
-        name: '高德地图'
+        id: 3,
+        name: '高德地图',
+        value: 'aMap'
       }],
       // 只触发一次
       only: true
@@ -275,21 +278,25 @@ export default {
     openMap(e) {
       this.$refs.popup.close()
       let url = ''
-      // 腾讯地图
-      if (e === 1) {
-        url = `https://apis.map.qq.com/uri/v1/routeplan?type=drive&from=我的位置&fromcoord=${this.form.latitude},${this.form.longitude}&to=${this.toName}&tocoord=${this.toLat},${this.toLng}&coord_type=2&referer=猫王妙播Pro}`
-      }
+      if (getApp().globalData.inside) {
+        openOtherApp.postMessage(`?page=${e.value}&longitude=${this.toLng}&latitude=${this.toLat}&name=${this.toName}`)
+      } else {
+        // 腾讯地图
+        if (e.id === 1) { 
+          url = `https://apis.map.qq.com/uri/v1/routeplan?type=drive&from=我的位置&fromcoord=${this.form.latitude},${this.form.longitude}&to=${this.toName}&tocoord=${this.toLat},${this.toLng}&coord_type=2&referer=猫王妙播Pro`
+        }
 
-      // 百度地图
-      if (e === 2) {
-        url = `http://api.map.baidu.com/direction?origin=latlng:${this.form.latitude},${this.form.longitude}|name:我的位置&destination=latlng:${this.toLat},${this.toLng}|name:${this.toName}&mode=driving&region=${this.province}&output=html&coord_type=gcj02&src=webapp.airsmart.猫王妙播Pro`
-      }
+        // 百度地图
+        if (e.id  === 2) {
+          url = `http://api.map.baidu.com/direction?origin=latlng:${this.form.latitude},${this.form.longitude}|name:我的位置&destination=latlng:${this.toLat},${this.toLng}|name:${this.toName}&mode=driving&region=${this.province}&output=html&coord_type=gcj02&src=webapp.airsmart.猫王妙播Pro`
+        }
 
-      // 高德地图
-      if (e === 3) {
-        url = `https://uri.amap.com/navigation?from=${this.form.longitude},${this.form.latitude},我的位置&to=${this.toLng},${this.toLat},${this.toName}&callnative=1`
+        // 高德地图
+        if (e.id  === 3) {
+          url = `https://uri.amap.com/navigation?from=${this.form.longitude},${this.form.latitude},我的位置&to=${this.toLng},${this.toLat},${this.toName}&callnative=1`
+        }
+        window.location.href = url
       }
-      window.location.href = url
     },
 
     // 重新定位
@@ -551,7 +558,7 @@ export default {
     border-radius: 16px;
     margin: 0 auto;
     position: absolute;
-    bottom: 0px;
+    bottom: 20px;
     left: 50%;
     transform: translate(-50%);