Prechádzať zdrojové kódy

feat: 温室控制大棚导航

allen 2 mesiacov pred
rodič
commit
00e3fa3052

+ 23 - 2
pages/cb/wenshizs/components/DeviceCard.vue

@@ -29,6 +29,9 @@
             dataSource.devCityalign || dataSource.devCity || ''
           } ${dataSource.devDistrictalign || dataSource.devDistrict || ''}`
         }}</view>
+        <view class="ntoNative" @tap="toNavigation">
+          <image :src="location" class="icon"></image>
+        </view>
       </view>
     </view>
   </view>
@@ -47,6 +50,8 @@ export default {
   },
   data() {
     return {
+      location:
+        'https://webstaticimg.oss-cn-hangzhou.aliyuncs.com/bigdata_app/image/zhongshui/location.svg',
       successImg:
         'https://webstaticimg.oss-cn-hangzhou.aliyuncs.com/bigdata_app/image/zhongshui/success.png',
       errorImg:
@@ -55,6 +60,9 @@ export default {
   },
   methods: {
     handleClick() {},
+    toNavigation() {
+      this.$emit('navigation');
+    },
   },
 };
 </script>
@@ -145,10 +153,23 @@ export default {
     display: flex;
     align-items: center;
     margin-bottom: 16rpx;
-
+    position: relative;
     &:last-child {
       margin-bottom: 0;
     }
+    .ntoNative {
+      position: absolute;
+      right: 16rpx;
+      width: 80rpx;
+      height: 80rpx;
+      display: flex;
+      align-items: center;
+      justify-content: flex-end;
+      .icon {
+        width: 30rpx;
+        height: 30rpx;
+      }
+    }
   }
 
   &__label {
@@ -159,7 +180,7 @@ export default {
   }
 
   &__value {
-    width: 470rpx;
+    width: 420rpx;
     text-align: left;
     white-space: nowrap;
     overflow: hidden;

+ 43 - 34
pages/cb/wenshizs/wenshizs.vue

@@ -6,13 +6,13 @@
           {{ dataSource.devName }}
         </view> </block
       ><view slot="right">
-        <view class="ntoNative" @tap="toNavigation">
+        <!-- <view class="ntoNative" @tap="toNavigation">
           <image :src="location" class="icon"></image>
-        </view>
+        </view> -->
       </view>
     </custom-card>
     <view class="greenhouse-top">
-      <device-card :dataSource="dataSource" />
+      <device-card :dataSource="dataSource" @navigation="toNavigation" />
     </view>
     <view class="greenhouse-bottom">
       <!-- <Element /> -->
@@ -161,37 +161,46 @@ export default {
         this.dataSource.devLngalign || this.dataSource.devLng;
       const roundedLatitude =
         this.dataSource.devLatalign || this.dataSource.devLat;
-      if (!roundedLongitude) {
-        uni.showToast({
-          title: '当前设备无定位信息',
-          icon: 'none',
-          duration: 3000,
-        });
-        return;
-      }
-      if (
-        plus.runtime.isApplicationExist({
-          pname: 'com.autonavi.minimap',
-          action: 'iosamap://',
-        })
-      ) {
-        let url = `amapuri://route/plan?sourceApplication=yourAppName&dlat=${roundedLatitude}&dlon=${roundedLongitude}&dev=0&t=0&style=0&start=&auto=1&rtdType=1&coordinate=wgs84`;
-        plus.runtime.openURL(url);
-      } else if (
-        plus.runtime.isApplicationExist({
-          pname: 'com.baidu.BaiduMap',
-          action: 'baidumap://',
-        })
-      ) {
-        let url = `baidumap://map/direction?destination=${roundedLongitude},${roundedLatitude}&mode=navigation&output=html&coord_type=wgs84`;
-        plus.runtime.openURL(url);
-      } else {
-        uni.showToast({
-          title: '当前未安装 高德地图或百度地图 无法导航',
-          icon: 'none',
-          duration: 3000,
-        });
-      }
+      uni.openLocation({
+        latitude: Number(roundedLatitude || 0),
+        longitude: Number(roundedLongitude || 0),
+        name: '',
+        address: '',
+        scale: 18, // 地图缩放级别
+        success: () => console.log('导航启动成功'),
+        fail: (err) => console.error('导航失败:', err),
+      });
+      // if (!roundedLongitude) {
+      //   uni.showToast({
+      //     title: '当前设备无定位信息',
+      //     icon: 'none',
+      //     duration: 3000,
+      //   });
+      //   return;
+      // }
+      // if (
+      //   plus.runtime.isApplicationExist({
+      //     pname: 'com.autonavi.minimap',
+      //     action: 'iosamap://',
+      //   })
+      // ) {
+      //   let url = `amapuri://route/plan?sourceApplication=yourAppName&dlat=${roundedLatitude}&dlon=${roundedLongitude}&dev=0&t=0&style=0&start=&auto=1&rtdType=1&coordinate=wgs84`;
+      //   plus.runtime.openURL(url);
+      // } else if (
+      //   plus.runtime.isApplicationExist({
+      //     pname: 'com.baidu.BaiduMap',
+      //     action: 'baidumap://',
+      //   })
+      // ) {
+      //   let url = `baidumap://map/direction?destination=${roundedLongitude},${roundedLatitude}&mode=navigation&output=html&coord_type=wgs84`;
+      //   plus.runtime.openURL(url);
+      // } else {
+      //   uni.showToast({
+      //     title: '当前未安装 高德地图或百度地图 无法导航',
+      //     icon: 'none',
+      //     duration: 3000,
+      //   });
+      // }
     },
     // 获取卷膜设备列表
     async getDpdevicedpkzgjuanmoList(tf) {

+ 2 - 2
util/api.js

@@ -1,9 +1,9 @@
 // let BASE_URL = 'http://114.55.0.7:8002';
 // const BASE_URL='http://8.136.98.49:8002'
 // let BASE_URL = 'http://218.28.198.186:10505'
-let BASE_URL = 'https://wx.hnyfwlw.com';
+// let BASE_URL = 'https://wx.hnyfwlw.com'
 // let BASE_URL = 'https://wx.hnyfwlw.com';
-// let BASE_URL = 'http://218.28.198.186:10508';
+let BASE_URL = 'http://218.28.198.186:10508';
 export const myRequest = (options) => {
   // BASE_URL=uni.getStorageSync('http')
   // if(BASE_URL==''){