shuishen
2022-02-21 dfe23ccb24b9531e9fdbe8157e673d1a4d16d343
leafletMapOur/grabOrdersMap/js/vueMain.js
@@ -39,58 +39,58 @@
      onPosition: false, //持续定位指示
   },
   methods: {
      unis(data) {
         //向uniapp传值
         uni.postMessage({
            data: {
               action: data
            }
         });
      },
      setUniAppMsg(state, data) {
         let that = this;
         if (window.parent) {
            console.log("有window.parent")
            if (state == "hBackMsg") {
               window.parent.hBackMsg(data);
            }
            if (state == "setIntLat") {
               window.parent.setIntLat({
                  rid: that.data.id,
                  fn: (out) => {
                     // console.log(out,"1111");
                     // that.addIcon(out);
                     that.addIcon([out[1], out[0]]);
                  }
               });
            }
            if (state == "showTip") {
               that.parent.showTip("获取定位失败");
            }
         } else {
            console.log("没window.parent")
            if (state == "hBackMsg") {
               // window.parent.hBackMsg(data);
               that.unis("hBackMsg")
            }
            if (state == "setIntLat") {
               // window.parent.setIntLat({
               //    rid: that.data.id,
               //    fn: (out) => {
               //       // console.log(out,"1111");
               //       // that.addIcon(out);
               //       that.addIcon([out[1], out[0]]);
               //    }
               // });
               that.unis("setIntLat")
            }
            if (state == "showTip") {
               // that.parent.showTip("获取定位失败");
               that.unis("showTip")
            }
      // unis(data) {
      //    //向uniapp传值
      //    uni.postMessage({
      //       data: {
      //          action: data
      //       }
      //    });
      // },
      // setUniAppMsg(state, data) {
      //    let that = this;
      //    if (window.parent) {
      //       console.log("有window.parent")
      //       if (state == "hBackMsg") {
      //          window.parent.hBackMsg(data);
      //       }
      //       if (state == "setIntLat") {
      //          window.parent.setIntLat({
      //             rid: that.data.id,
      //             fn: (out) => {
      //                // console.log(out,"1111");
      //                // that.addIcon(out);
      //                that.addIcon([out[1], out[0]]);
      //             }
      //          });
      //       }
      //       if (state == "showTip") {
      //          that.parent.showTip("获取定位失败");
      //       }
      //    } else {
      //       console.log("没window.parent")
      //       if (state == "hBackMsg") {
      //          // window.parent.hBackMsg(data);
      //          that.unis("hBackMsg")
      //       }
      //       if (state == "setIntLat") {
      //          // window.parent.setIntLat({
      //          //    rid: that.data.id,
      //          //    fn: (out) => {
      //          //       // console.log(out,"1111");
      //          //       // that.addIcon(out);
      //          //       that.addIcon([out[1], out[0]]);
      //          //    }
      //          // });
      //          that.unis("setIntLat")
      //       }
      //       if (state == "showTip") {
      //          // that.parent.showTip("获取定位失败");
      //          that.unis("showTip")
      //       }
         }
      },
      //    }
      // },
      openAPP(type) {
         // console.log(type)
         let that = this;
@@ -103,20 +103,54 @@
               });
            } else if (that.data.butCT == "begin") {
               // 开始任务
               that.setUniAppMsg("hBackMsg", {
                  type: "start",
                  data: {
                     id: that.data.id,
                     serid: that.data.serid
                  },
                  fn: function(val) {
                     if (val == "success") {
                        // console.log("成功开启任务")
                        that.data.butCT = "beginUp";
                        that.data.rtype = '0';
                        that.data.type = "0";
               // that.setUniAppMsg("hBackMsg", {
               //    type: "start",
               //    data: {
               //       id: that.data.id,
               //       serid: that.data.serid
               //    },
               //    fn: function(val) {
               //       if (val == "success") {
               //          // console.log("成功开启任务")
               //          that.data.butCT = "beginUp";
               //          that.data.rtype = '0';
               //          that.data.type = "0";
               //       }
               //    }
               // })
               let rid = that.data.id,
                  serid = that.data.serid,
                  type = 'start',
                  url = that.data.appenUrl + "taskqd/startTask?" +
                  `rid=${rid}&serid=${serid}&type=${type}`;
               axios.get(url).then((res) => {
                  // console.log(res);
                  that.onPosition = new $getPositions({
                     id: rid,
                     fn: function(res) {
                        // console.log(res);
                        // state.isOnTaskValue[id] = {
                        //    id: id,
                        //    intlat: res.intlat
                        // }
                        // state.changes = !state.changes;
                        // console.log(state.isOnTaskValue)
                        // $store.commit("setMsg", {
                        //    id: id,
                        //    intlat: res.intlat
                        // })
                        let out = res.intlat;
                        if (typeof out != "string") {
                           that.addIcon([out[1], out[0]]);
                        } else {
                           console.log("获取定位失败")
                        }
                     }
                  }
                  })
                  that.onPosition.continuedTime();
                  that.data.butCT = "beginUp";
                  that.data.rtype = '0';
                  that.data.type = "0";
               })
            }
         } else {
@@ -409,8 +443,6 @@
                     console.log(res)
                     if (typeof res.intlat === "string") {
                        // that.parent.showTip("获取定位失败")
                        //向uniapp传值
                        that.setUniAppMsg("showTip")
                     } else {
                        that.addIcon([res.intlat[1], res.intlat[0]]);
@@ -716,7 +748,7 @@
      });
      this.domMove.init();
      // console.log(window.parent.setIntLat)
      that.setUniAppMsg("setIntLat")
      // that.setUniAppMsg("setIntLat")
      // window.parent.setIntLat({
      //    rid: this.data.id,
      //    fn: (out) => {
@@ -725,18 +757,18 @@
      //       that.addIcon([out[1], out[0]]);
      //    }
      // })
      window.addEventListener('message', e => {
         console.log(e, 'HTML 接受APP发送过来的消息 (H5端)');
         app.dataList = JSON.parse(e.data.data).navigation
         console.log(app.dataList, '+++++++++');
      }, false)
      // window.addEventListener('message', e => {
      //    console.log(e, 'HTML 接受APP发送过来的消息 (H5端)');
      //    app.dataList = JSON.parse(e.data.data).navigation
      //    console.log(app.dataList, '+++++++++');
      // }, false)
      // HTML 接受APP发送过来的消息 (APP端)
      function requestData(data) {
         console.log(JSON.stringify(data), 'HTML 接受APP发送过来的消息 (APP端)');
         app.dataList = data.navigation // 赋值
      }
      // // HTML 接受APP发送过来的消息 (APP端)
      // function requestData(data) {
      //    console.log(JSON.stringify(data), 'HTML 接受APP发送过来的消息 (APP端)');
      //    app.dataList = data.navigation // 赋值
      // }
   },
   wacth: {}
})