From 0e9887c52e967ba48e8b08c1e3063a2e3b361320 Mon Sep 17 00:00:00 2001
From: zengh <123456>
Date: Mon, 21 Feb 2022 17:13:22 +0800
Subject: [PATCH] 反馈问题修复

---
 public/loginMap/js/geolocation.min.js |   95 -----------------------
 public/loginMap/js/vueMain.js         |   66 +++++++++-------
 public/grabOrdersMap/js/vueMain.js    |   11 ++
 public/loginMap/js/getPosition.js     |   18 ++++
 public/loginMap/loginMap.html         |   14 ++-
 5 files changed, 73 insertions(+), 131 deletions(-)

diff --git a/public/grabOrdersMap/js/vueMain.js b/public/grabOrdersMap/js/vueMain.js
index 414c977..6821248 100644
--- a/public/grabOrdersMap/js/vueMain.js
+++ b/public/grabOrdersMap/js/vueMain.js
@@ -359,7 +359,16 @@
 						if (!res.state) {
 							console.log(res)
 							if (typeof res.intlat === "string") {
-								window.parent.showTip("获取定位失败")
+								// 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]]);
 							}
diff --git a/public/loginMap/js/geolocation.min.js b/public/loginMap/js/geolocation.min.js
index ea0811c..b2ea22e 100644
--- a/public/loginMap/js/geolocation.min.js
+++ b/public/loginMap/js/geolocation.min.js
@@ -1,94 +1 @@
-window.qq = window.qq || {}, qq.maps = qq.maps || {}, window.soso || (window.soso = qq), soso.maps || (soso.maps = qq
-	.maps), qq.maps.Geolocation = function() {
-	"use strict";
-	var e = [],
-		t = null,
-		o = 0,
-		n = "_geoIframe_" + Math.ceil(1e7 * Math.random()),
-		i = document.createElement("iframe"),
-		r = null,
-		s = null,
-		a = null,
-		c = null,
-		u = function(u, l) {
-			if (!u) return void alert("请输入key!");
-			if (!l) return void alert("请输入referer!");
-			var p = document.getElementById(n);
-			if (!p) {
-				i.setAttribute("id", n), i.setAttribute("allow", "geolocation");
-				var g = "https:";
-				i.setAttribute("src", g + "//web.byisf.com/txdw/tools/geolocation?key=" + u + "&referer=" + l), i
-					.setAttribute("style", "display: none; width: 100%; height: 30%"), document.body ? document.body
-					.appendChild(i) : document.write(i.outerHTML);
-				var m = this;
-				window.addEventListener("message", function(n) {
-					var i = n.data;
-					if (i && "geolocation" == i.module) {
-						if (clearTimeout(c), e.length > 0) {
-							var u = e.shift();
-							u.sucCb && u.sucCb(i)
-						}
-						o = 2, m.executeNextGeo(), t && t(i)
-					} else {
-						s = (new Date).getTime();
-						var l = s - r;
-						if (l >= a) {
-							if (e.length > 0 && "geo" === e[0].type) {
-								var u = e.shift(),
-									p = {
-										type: "fail",
-										code: 5,
-										message: "The request"
-									};
-								u.errCb && u.errCb(p)
-							}
-							clearTimeout(c), o = -1, m.executeNextGeo()
-						}
-						if (e.length > 0 && "ip" === e[0].type) {
-							var u = e.shift();
-							u.errCb && u.errCb(p)
-						}
-					}
-				}, !1)
-			}
-		};
-	return u.prototype.executeNextGeo = function() {
-		1 !== o && e.length > 0 && (o = 1, e[0].geoprocess())
-	}, u.prototype.getLocation = function(t, n, i) {
-		if (i && i.timeout) {
-			var r = new RegExp("^[0-9]*$");
-			if (!r.test(i.timeout)) return void alert("timeout 请输入数字")
-		}
-		if (e.length > 10) throw new Error("geolocation queue must be lass than 10");
-		e.push({
-			sucCb: t,
-			errCb: n,
-			option: i,
-			geoprocess: this.getOnceLocation,
-			type: "geo"
-		}), 1 !== o && (o = 1, this.getOnceLocation())
-	}, u.prototype.getOnceLocation = function() {
-		var t = e[0] && e[0].option;
-		r = (new Date).getTime(), a = t && t.timeout ? +t.timeout : 1e4, clearTimeout(c), c = setTimeout(
-			function() {
-				if (e.length > 0) {
-					var t = e.shift();
-					t.errCb && t.errCb()
-				}
-			}, a), document.getElementById(n).contentWindow.postMessage("getLocation", "*")
-	}, u.prototype.getIpLocation = function(t, n) {
-		if (e.length > 10) throw new Error("geolocation queue mast be lass than 10");
-		e.push({
-			sucCb: t,
-			errCb: n,
-			geoprocess: this.getOnceIpLocation,
-			type: "ip"
-		}), 1 !== o && (o = 1, this.getOnceIpLocation())
-	}, u.prototype.getOnceIpLocation = function() {
-		document.getElementById(n).contentWindow.postMessage("getLocation.robust", "*")
-	}, u.prototype.watchPosition = function(e) {
-		t = e, document.getElementById(n).contentWindow.postMessage("watchPosition", "*")
-	}, u.prototype.clearWatch = function() {
-		t = null, document.getElementById(n).contentWindow.postMessage("clearWatch", "*")
-	}, u
-}();
+window.qq = window.qq || {}, qq.maps = qq.maps || {}, window.soso || (window.soso = qq), soso.maps || (soso.maps = qq.maps), qq.maps.Geolocation = function () { "use strict"; var e = [], t = null, o = 0, n = "_geoIframe_" + Math.ceil(1e7 * Math.random()), i = document.createElement("iframe"), r = null, s = null, a = null, c = null, u = function (u, l) { if (!u) return void alert("请输入key!"); if (!l) return void alert("请输入referer!"); var p = document.getElementById(n); if (!p) { i.setAttribute("id", n), i.setAttribute("allow", "geolocation"); var g = "https:"; i.setAttribute("src", g + "//apis.map.qq.com/tools/geolocation?key=" + u + "&referer=" + l), i.setAttribute("style", "display: none; width: 100%; height: 30%"), document.body ? document.body.appendChild(i) : document.write(i.outerHTML); var m = this; window.addEventListener("message", function (n) { var i = n.data; if (i && "geolocation" == i.module) { if (clearTimeout(c), e.length > 0) { var u = e.shift(); u.sucCb && u.sucCb(i) } o = 2, m.executeNextGeo(), t && t(i) } else { s = (new Date).getTime(); var l = s - r; if (l >= a) { if (e.length > 0 && "geo" === e[0].type) { var u = e.shift(), p = { type: "fail", code: 5, message: "The request" }; u.errCb && u.errCb(p) } clearTimeout(c), o = -1, m.executeNextGeo() } if (e.length > 0 && "ip" === e[0].type) { var u = e.shift(); u.errCb && u.errCb(p) } } }, !1) } }; return u.prototype.executeNextGeo = function () { 1 !== o && e.length > 0 && (o = 1, e[0].geoprocess()) }, u.prototype.getLocation = function (t, n, i) { if (i && i.timeout) { var r = new RegExp("^[0-9]*$"); if (!r.test(i.timeout)) return void alert("timeout 请输入数字") } if (e.length > 10) throw new Error("geolocation queue must be lass than 10"); e.push({ sucCb: t, errCb: n, option: i, geoprocess: this.getOnceLocation, type: "geo" }), 1 !== o && (o = 1, this.getOnceLocation()) }, u.prototype.getOnceLocation = function () { var t = e[0] && e[0].option; r = (new Date).getTime(), a = t && t.timeout ? +t.timeout : 1e4, clearTimeout(c), c = setTimeout(function () { if (e.length > 0) { var t = e.shift(); t.errCb && t.errCb() } }, a), document.getElementById(n).contentWindow.postMessage("getLocation", "*") }, u.prototype.getIpLocation = function (t, n) { if (e.length > 10) throw new Error("geolocation queue mast be lass than 10"); e.push({ sucCb: t, errCb: n, geoprocess: this.getOnceIpLocation, type: "ip" }), 1 !== o && (o = 1, this.getOnceIpLocation()) }, u.prototype.getOnceIpLocation = function () { document.getElementById(n).contentWindow.postMessage("getLocation.robust", "*") }, u.prototype.watchPosition = function (e) { t = e, document.getElementById(n).contentWindow.postMessage("watchPosition", "*") }, u.prototype.clearWatch = function () { t = null, document.getElementById(n).contentWindow.postMessage("clearWatch", "*") }, u }();
\ No newline at end of file
diff --git a/public/loginMap/js/getPosition.js b/public/loginMap/js/getPosition.js
new file mode 100644
index 0000000..b861653
--- /dev/null
+++ b/public/loginMap/js/getPosition.js
@@ -0,0 +1,18 @@
+window.qq = window.qq || {}
+qq.maps = qq.maps || {}
+window.soso || (window.soso = qq)
+soso.maps || (soso.maps = qq.maps);
+(function () {
+    function getScript (src) {
+        var protocol = (window.location.protocol == "https:") ? "https://" : "http://"
+        src = src && (src.indexOf("http://") === 0 || src.indexOf("https://") === 0) ? src : protocol + src
+        document.write('<' + 'script src="' + src + '"' + ' type="text/javascript"><' + '/script>')
+    }
+    qq.maps.__load = function (apiLoad) {
+        delete qq.maps.__load
+        apiLoad([["2.4.142", "T7RBZ-62U3X-RSQ4P-ZZVCB-WE7JT-HRBOG", 0], ["https://mapapi.qq.com/", "jsapi_v2/2/4/142/mods/", "https://mapapi.qq.com/jsapi_v2/2/4/142/theme/", true], [1, 18, 34.519469, 104.461761, 4], [1645433081331, "https://pr.map.qq.com/pingd", "https://pr.map.qq.com/pingd"], ["https://apis.map.qq.com/jsapi", "https://apikey.map.qq.com/mkey/index.php/mkey/check", "https://sv.map.qq.com/xf", "https://sv.map.qq.com/boundinfo", "https://sv.map.qq.com/rarp", "https://apis.map.qq.com/api/proxy/search", "https://apis.map.qq.com/api/proxy/routes/", "https://confinfo.map.qq.com/confinfo", "https://overseactrl.map.qq.com"], [[null, ["https://rt0.map.gtimg.com/tile", "https://rt1.map.gtimg.com/tile", "https://rt2.map.gtimg.com/tile", "https://rt3.map.gtimg.com/tile"], "png", [256, 256], 3, 19, "114", true, false], [null, ["https://m0.map.gtimg.com/hwap", "https://m1.map.gtimg.com/hwap", "https://m2.map.gtimg.com/hwap", "https://m3.map.gtimg.com/hwap"], "png", [128, 128], 3, 18, "110", false, false], [null, ["https://p0.map.gtimg.com/sateTiles", "https://p1.map.gtimg.com/sateTiles", "https://p2.map.gtimg.com/sateTiles", "https://p3.map.gtimg.com/sateTiles"], "jpg", [256, 256], 1, 19, "101", false, false], [null, ["https://rt0.map.gtimg.com/tile", "https://rt1.map.gtimg.com/tile", "https://rt2.map.gtimg.com/tile", "https://rt3.map.gtimg.com/tile"], "png", [256, 256], 1, 19, "", false, false], [null, ["https://sv0.map.qq.com/hlrender/", "https://sv1.map.qq.com/hlrender/", "https://sv2.map.qq.com/hlrender/", "https://sv3.map.qq.com/hlrender/"], "png", [256, 256], 1, 19, "", false, false], [null, ["https://rtt2.map.qq.com/rtt/", "https://rtt2a.map.qq.com/rtt/", "https://rtt2b.map.qq.com/rtt/", "https://rtt2c.map.qq.com/rtt/"], "png", [256, 256], 1, 19, "", false, false], null, [["https://rt0.map.gtimg.com/vector/", "https://rt1.map.gtimg.com/vector/", "https://rt2.map.gtimg.com/vector/", "https://rt3.map.gtimg.com/vector/"], [256, 256], 3, 18, "114", ["https://rt0.map.gtimg.com/icons/", "https://rt1.map.gtimg.com/icons/", "https://rt2.map.gtimg.com/icons/", "https://rt3.map.gtimg.com/icons/"], []], null], ["https://s.map.qq.com/TPano/v1.1.2/TPano.js", "map.qq.com/", ""], "{\"ver\":5,\"isup\":1,\"url\":\"https://mapstyle.qpic.cn/fileupdate/jsauto/style?id=30&version=5\"}"], loadScriptTime)
+    }
+    var loadScriptTime = (new Date).getTime()
+    getScript("https://mapapi.qq.com/jsapi_v2/2/4/142/main.js")
+
+})()
\ No newline at end of file
diff --git a/public/loginMap/js/vueMain.js b/public/loginMap/js/vueMain.js
index 61f8ae8..8f30fe0 100644
--- a/public/loginMap/js/vueMain.js
+++ b/public/loginMap/js/vueMain.js
@@ -45,7 +45,6 @@
             //url解码
             this.getdata = this.getQueryVariable('data') || data
 
-            console.log(this.getdata, 456)
             this.map = this.beginMap(this.map, this.getdata) //创建并接受map
             this.map.invalidateSize(true) //应用地图高度
         },
@@ -111,61 +110,68 @@
         getLocationData () {
             var that = this
             var geolocation = new qq.maps.Geolocation("T7RBZ-62U3X-RSQ4P-ZZVCB-WE7JT-HRBOG", "mapqq")
-            var positionNum = 0
-            var options = {
-                timeout: 8000
-            }
 
+            var options = {
+                timeout: 8000 //延时
+            }
+            var geocoder
+            var latLng
+            // 定位成功之后调用的方法
             function showPosition (position) {
 
                 that.regionName = position.district || position.city
 
-                console.log(position)
-
-                var adCode = position.adCode //邮政编码
-                var nation = position.nation //中国
-                var city = position.city //城市
-                var addr = position.addr //详细地址
                 that.lat = position.lat //
                 that.lng = position.lng //火星坐标 //TODO 实现业务代码逻辑 
 
-                if (that.LXdhStart != null) {
-                    that.map.removeLayer(that.LXdhStart)
-                }
+                // 逆地址解析(经纬度到地名转换过程)
+                geocoder = new qq.maps.Geocoder({
+                    complete: function (res) {
+                        if (that.LXdhStart != null) {
+                            that.map.removeLayer(that.LXdhStart)
+                        }
 
-                //绘制起点和终点
-                that.LXdhStart = L.markerClusterGroup()
+                        //绘制起点和终点
+                        that.LXdhStart = L.markerClusterGroup()
 
-                var transportIcon = L.Icon.extend({ //图标初始化
-                    options: {
-                        iconSize: [50, 50], // 图标尺寸
+                        var transportIcon = L.Icon.extend({ //图标初始化
+                            options: {
+                                iconSize: [50, 50], // 图标尺寸
+                            }
+                        })
+
+                        var qd = new transportIcon({
+                            iconUrl: './img/dingw.gif'
+                        })
+
+                        that.LXdhStart.addLayer(L.marker([that.lat, that.lng], {
+                            icon: qd,
+                        }))
+
+                        that.map.addLayer(that.LXdhStart)
+
                     }
                 })
 
-                var qd = new transportIcon({
-                    iconUrl: './img/dingw.gif'
-                })
+                latLng = new qq.maps.LatLng(that.lat, that.lng)
 
-                that.LXdhStart.addLayer(L.marker([that.lat, that.lng], {
-                    icon: qd,
-                }))
-
-                that.map.addLayer(that.LXdhStart)
+                geocoder.getAddress(latLng)
 
             };
 
             function showErr () {
-                //TODO 如果出错了调用此方法 
-            };
+                console.log('定位失败')
+            }
 
             geolocation.getLocation(showPosition, showErr, options)
-        },
+        }
 
     },
     created () { },
     mounted () {
         this.getDataList()
         this.getLocationData()
+
     },
     wacth: {}
 })
\ No newline at end of file
diff --git a/public/loginMap/loginMap.html b/public/loginMap/loginMap.html
index d2b682c..58435c5 100644
--- a/public/loginMap/loginMap.html
+++ b/public/loginMap/loginMap.html
@@ -23,8 +23,14 @@
     <!-- <script src="../map/lib/layui/layui.js" charset="utf-8"></script> -->
 
     <!-- 百度地图api -->
-    <script type="text/javascript" src="https://mapapi.qq.com/web/mapComponents/geoLocation/v/geolocation.min.js">
-    </script>
+    <!-- <script type="text/javascript" src="https://mapapi.qq.com/web/mapComponents/geoLocation/v/geolocation.min.js">
+    </script> -->
+
+    <script charset="utf-8" src="./js/geolocation.min.js"></script>
+
+    <script charset="utf-8" src="./js/getPosition.js"></script>
+
+
 
     <!-- axios支持 -->
     <script src="../map/lib/axios.js"></script>
@@ -57,10 +63,6 @@
 
 <body>
     <div id="mapVue">
-
-        <div class="dingwei" @click="locationMap">
-            <img style="width: 80%;height: 80%;" src="./img/dingwei.png" alt="">
-        </div>
 
         <div id="map">
 

--
Gitblit v1.9.3