zengh
2022-02-21 e1167b42f509efaceec28c258f8007e6d3f678c6
public/grabOrdersMap/js/vueMain.js
@@ -39,9 +39,58 @@
      onPosition: false, //持续定位指示
   },
   methods: {
      setUniAppMsg(data) {
         window.parent.hBackMsg(data)
      },
      // 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;
@@ -54,20 +103,54 @@
               });
            } else if (that.data.butCT == "begin") {
               // 开始任务
               that.setUniAppMsg({
                  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 {
@@ -360,15 +443,7 @@
                     console.log(res)
                     if (typeof res.intlat === "string") {
                        // that.parent.showTip("获取定位失败")
                        //向uniapp传值
                        uni.postMessage({
                           data: {
                              action: 'message'
                           }
                        });
                        uni.getEnv(function(res) {
                           console.log('当前环境:' + JSON.stringify(res));
                        });
                     } else {
                        that.addIcon([res.intlat[1], res.intlat[0]]);
                     }
@@ -673,14 +748,27 @@
      });
      this.domMove.init();
      // console.log(window.parent.setIntLat)
      window.parent.setIntLat({
         rid: this.data.id,
         fn: (out) => {
            // console.log(out,"1111");
            // that.addIcon(out);
            that.addIcon([out[1], out[0]]);
         }
      })
      // that.setUniAppMsg("setIntLat")
      // window.parent.setIntLat({
      //    rid: this.data.id,
      //    fn: (out) => {
      //       // console.log(out,"1111");
      //       // that.addIcon(out);
      //       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)
      // // HTML 接受APP发送过来的消息 (APP端)
      // function requestData(data) {
      //    console.log(JSON.stringify(data), 'HTML 接受APP发送过来的消息 (APP端)');
      //    app.dataList = data.navigation // 赋值
      // }
   },
   wacth: {}
})