maxiaoxiao 6 months ago
parent
commit
362886da08
2 changed files with 181 additions and 20 deletions
  1. 97 20
      pages/check/index.vue
  2. 84 0
      pages/check/mapto.js

+ 97 - 20
pages/check/index.vue

@@ -1,26 +1,103 @@
 <template>
-	<view class="">
-		<MapView></MapView>
-	</view>
+  <view class="">
+    <MapView></MapView>
+    <van-list
+      v-model="loading"
+      :immediate-check="false"
+      :error.sync="error"
+      error-text="请求失败,点击重新加载"
+      finished-text="没有更多了~"
+      @load="getList"
+    >
+      <view
+        class="list-item"
+        v-for="(item, key) in tableData"
+        :key="key"
+        @click="goDetail(item)"
+      >
+        <div class="nameTitle">{{ item.name }}</div>
+        <div>下发时间:{{ item.jsdw }}</div>
+        <div>结束时间:{{ item.jsdw }}</div>
+        <div>核查图斑:{{ item.spotsnumber || 0 }}个</div>
+        <div>核查人员:{{ item.jsdw }}</div>
+        <view class="status">{{ item.status }}</view>
+      </view>
+    </van-list>
+  </view>
 </template>
 <script>
-	import MapView from "./MapView.vue";
-	export default {
-		name: "map-view",
-		components: {
-			MapView
-		},
-		data() {
-			return {
-
-			}
-		},
-		mounted() {},
-		unmounted() {},
-		methods: {},
-
-	};
+import MapView from "./MapView.vue";
+import { listPcsjXQList } from "@/api/apis.js";
+import { handleNavigation } from "./mapto.js";
+export default {
+  name: "map-view",
+  components: {
+    MapView,
+  },
+  data() {
+    return {
+      queryParams: {
+        jcbh: "", //监测编号
+        pageNum: 1,
+        pageSize: 10,
+        pcsjid: "",
+      },
+      loading: false,
+      tableData: [{}],
+    };
+  },
+  mounted() {},
+  onShow(options) {
+    uni.getStorage({
+      key: "my_param",
+      success: (res) => {
+        this.queryParams.id = res.data.id;
+        console.log("获取的参数是:", res.data);
+        this.getList();
+        this.navigation();
+      },
+    });
+  },
+  unmounted() {},
+  methods: {
+    getList() {
+      listPcsjXQList(this.queryParams).then((response) => {
+        this.tableData = response.rows;
+        this.total = response.total;
+        // this.open = true;
+        // this.title = "修改监管批次数据";
+        // this.initVectorLayer("mapDiv");
+        // this.initVectorLayer("mapCon1");
+        // this.initVectorLayer("mapCon2");
+        // this.addGeoJson("mapDiv");
+        // this.addGeoJson("mapCon1");
+        // this.addGeoJson("mapCon2");
+      });
+    },
+    navigation() {
+      
+      console.log("s-xsx")
+      handleNavigation({
+        latitude: 39.9042,
+        longitude: 116.4074,
+        name: "地址名称",
+        address: "地址详情",
+      });
+      // uni.openLocation({
+      //   latitude: 39.9042,
+      //   longitude: 116.4074,
+      //   name: "地址名称",
+      //   address: "地址详情",
+      //   success: function (res) {
+      //     console.log("打开系统位置地图成功");
+      //   },
+      //   fail: function (error) {
+      //     console.log(error);
+      //   },
+      // });
+    },
+  },
+};
 </script>
 <style scoped>
-
 </style>

+ 84 - 0
pages/check/mapto.js

@@ -0,0 +1,84 @@
+export function handleNavigation(toData) {
+    console.log("s-xsxd", toData)
+    if (!toData.latitude || !toData.longitude || !toData.name) return
+    // 微信
+    // #ifdef MP-WEIXIN
+    uni.openLocation({
+        ..._obj,
+        latitude: parseFloat(toData.latitude),
+        longitude: parseFloat(toData.longitude),
+        success: function (res) {
+            console.log('打开系统位置地图成功')
+        },
+        fail: function (error) {
+            console.log(error)
+        }
+    })
+    console.log(toData, '---')
+    // #endif
+    console.log(toData, '---')
+    // #ifdef APP-PLUS
+    // 判断系统安装的地图应用有哪些, 并生成菜单按钮
+    let _mapName = [
+        { title: '高德地图', name: 'amap', androidName: 'com.autonavi.minimap', iosName: 'iosamap://' },
+        { title: '百度地图', name: 'baidumap', androidName: 'com.baidu.BaiduMap', iosName: 'baidumap://' },
+        { title: '腾讯地图', name: 'qqmap', androidName: 'com.tencent.map', iosName: 'qqmap://' },
+    ]
+
+    // 根据真机有的地图软件 生成的 操作菜单
+    let buttons = []
+    let platform = uni.getSystemInfoSync().platform
+    platform === 'android' && _mapName.forEach(item => {
+        if (plus.runtime.isApplicationExist({ pname: item.androidName })) {
+            buttons.push(item)
+        }
+    })
+    platform === 'ios' && _mapName.forEach(item => {
+        console.log(item.iosName)
+        if (plus.runtime.isApplicationExist({ action: item.iosName })) {
+            buttons.push(item)
+        }
+    })
+    console.log(buttons, '---')                                
+    if (buttons.length) {
+        plus.nativeUI.actionSheet({ //选择菜单
+            title: "选择地图应用",
+            cancel: "取消",
+            buttons: buttons
+        }, function (e) {
+            let _map = buttons[e.index - 1]
+            openURL(_map, platform, toData)
+        })
+    } else {
+        uni.showToast({
+            title: '请安装地图软件',
+            icon: 'none'
+        })
+        return
+    }
+    // #endif
+}
+
+// 打开第三方程序实际应用
+function openURL(map, platform, toData) {
+    let _defaultUrl = {
+        android: {
+            "amap": `amapuri://route/plan/?sid=&did=&dlat=${toData.latitude}&dlon=${toData.longitude}&dname=${toData.name}&dev=0&t=0`,
+            'qqmap': `qqmap://map/routeplan?type=drive&to=${toData.name}&tocoord=${toData.latitude},${toData.longitude}&referer=fuxishan_uni_client`,
+            'baidumap': `baidumap://map/direction?origin=${toData.selfLocation.latitude},${toData.selfLocation.longitude}&destination=name:${toData.name}|latlng:${toData.latitude},${toData.longitude}&coord_type=wgs84&mode=driving&src=andr.baidu.openAPIdemo"`
+        },
+        ios: {
+            "amap": `iosamap://path?sourceApplication=fuxishan_uni_client&dlat=${toData.latitude}&dlon=${toData.longitude}&dname=${toData.name}&dev=0&t=0`,
+            'qqmap': `qqmap://map/routeplan?type=drive&to=${toData.name}&tocoord=${toData.latitude},${toData.longitude}&referer=fuxishan_uni_client`,
+            'baidumap': `baidumap://map/direction?origin=${toData.selfLocation.latitude},${toData.selfLocation.longitude}&destination=name:${toData.name}|latlng:${toData.latitude},${toData.longitude}&mode=driving&src=ios.baidu.openAPIdemo`
+        }
+    }
+    let newurl = encodeURI(_defaultUrl[platform][map.name]);
+    console.log(newurl)
+    plus.runtime.openURL(newurl, function (res) {
+        console.log(res)
+        uni.showModal({
+            content: res.message
+        })
+    }, map.androidName ? map.androidName : '');
+}