From e3dcaeb0180a4e37347ac9ceb44c8a59ae7af37f Mon Sep 17 00:00:00 2001
From: liuyg <liuyg@qq.com>
Date: Mon, 21 Feb 2022 19:40:20 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.105:10010/r/qfqk-android
---
leafletMapOur/grabOrdersMap/js/vueMain.js | 127 +++++++++++++++++++++++++++++++++++-------
1 files changed, 106 insertions(+), 21 deletions(-)
diff --git a/leafletMapOur/grabOrdersMap/js/vueMain.js b/leafletMapOur/grabOrdersMap/js/vueMain.js
index 1fb8810..43b7ccf 100644
--- a/leafletMapOur/grabOrdersMap/js/vueMain.js
+++ b/leafletMapOur/grabOrdersMap/js/vueMain.js
@@ -39,18 +39,57 @@
onPosition: false, //持续定位指示
},
methods: {
- setUniAppMsg(data) {
- // console.log(data)
- // console.log(uni)
+ unis(data) {
+ //向uniapp传值
uni.postMessage({
data: {
- action: 'message'
+ action: data
}
});
- uni.getEnv(function(res) {
- console.log('当前环境:' + JSON.stringify(res));
- });
+ },
+ 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)
@@ -59,13 +98,25 @@
if (that.data.butCT == "beginUp") {
// 反馈
uni.navigateTo({
- url: '/pages/grabOrders/feedback?data=' + JSON.stringify(this.data)
+ url: '/pages/grabOrders/feedback?data=' + JSON.stringify(this.data) +
+ '&other="11111"'
});
} else if (that.data.butCT == "begin") {
// 开始任务
- this.setUniAppMsg({
- type: "begin",
- data: that.data
+ 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";
+ }
+ }
})
}
} else {
@@ -135,10 +186,10 @@
}
//url解码
this.data = this.getQueryVariable('data') || data;
- if (this.data.team) {
+ console.log(this.data)
+ if (typeof this.data.team === "string") {
this.data.team = this.data.team.split(',');
}
- console.log(this.data)
let lines = this.data.line
let position = lines.slice(lines.indexOf("(") + 1, lines.indexOf(",")).split(" ");
// console.log(position)
@@ -352,21 +403,33 @@
this.oncePosition = new $getPositions({
id: 1,
fn: function(res) {
- console.log(res);
+ // console.log(res);
that.mapPositionLoding = res.state;
if (!res.state) {
- that.addIcon(res.intlat);
+ console.log(res)
+ if (typeof res.intlat === "string") {
+ // that.parent.showTip("获取定位失败")
+ //向uniapp传值
+ that.setUniAppMsg("showTip")
+
+ } else {
+ that.addIcon([res.intlat[1], res.intlat[0]]);
+ }
}
}
}).init();
- }
- if (!this.onPosition) {
- this.oncePosition.continuedTime();
- this.onPosition = !this.onPosition;
+ this.oncePosition.once();
} else {
- this.oncePosition.overContinued();
- this.onPosition = !this.onPosition;
+ this.oncePosition.once();
}
+
+ // if (!this.onPosition) {
+ // this.oncePosition.continuedTime();
+ // this.onPosition = !this.onPosition;
+ // } else {
+ // this.oncePosition.overContinued();
+ // this.onPosition = !this.onPosition;
+ // }
},
//添加图标
addIcon(intlat) {
@@ -652,6 +715,28 @@
},
});
this.domMove.init();
+ // console.log(window.parent.setIntLat)
+ 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: {}
})
--
Gitblit v1.9.3