shuishen
2022-02-21 dfe23ccb24b9531e9fdbe8157e673d1a4d16d343
pages/grabOrders/map.vue
@@ -13,12 +13,28 @@
            urls: '',
            // dataList: [],
            fn: null,
            rid: ''
            rid: '',
            webV: null,
            wv: null,
         }
      },
      methods: {
         message(event) {
            console.log(event.detail.data);
            let data = event.detail.data;
            console.log(data);
         },
         sendRequestData(res, plt = 0) {
            let param = JSON.stringify(res)
            console.log(param);
            if (plt == 1) {
               this.webV.postMessage({
                  type: 'new',
                  data: param
               })
            } else {
               this.wv.evalJS(`requestData(${param})`);
            }
         }
      },
      computed: {
@@ -79,7 +95,8 @@
         }
      },
      onLoad: function(options) {
         var data = [];
         var data = [],
            that = this;
         if (options.data == undefined) {
            data = JSON.stringify({
               appenUrl: "http://192.168.0.108:83/",
@@ -129,9 +146,28 @@
         // this.urls = a + "grabOrdersMap/xcxmap.html?data=" + data;
         // a = a.slice(0, a.indexOf('api'));
         this.urls = a + "grabOrdersMap/xcxmap.html?data=" + data;
         // this.urls = "http://localhost:80?data=" + data;
         // http://127.0.0.1:8848/qfqk-android/grabOrdersMap/xcxmap.html
         // this.dataList = data;
         // console.log(this.urls);
         let type = uni.getSystemInfoSync().platform;
         if (type == "android") {
            //webView传值
            let currentWebview = this.$scope.$getAppWebview();
            setTimeout(() => {
               that.wv = currentWebview.children()[0];
               console.log(that.wv)
            }, 1000)
            window.addEventListener('message', e => {
               console.log(e)
               that.webV = e.source // window的对象
               console.log(e.data.data.arg, '接收h5页面发来的消息'); // 接收h5页面发来的消息(11)  ====>H5端
            }, false)
            setTimeout(() => {
               that.sendRequestData("给html", 1);
               that.sendRequestData("给html", 2);
            }, 10000)
         }
      },
      beforeDestroy() {
         this.$store.commit("changegotuGrabOrders");