Forráskód Böngészése

使用编辑地图定位功能

gcz 3 éve
szülő
commit
f5a6d528c2
2 módosított fájl, 25 hozzáadás és 10 törlés
  1. 7 2
      manifest.json
  2. 18 8
      pages/clockIn/clockIn.vue

+ 7 - 2
manifest.json

@@ -26,7 +26,8 @@
         },
         /* 模块配置 */
         "modules" : {
-            "Maps" : {}
+            "Maps" : {},
+            "Geolocation" : {}
         },
         /* 应用发布信息 */
         "distribute" : {
@@ -64,7 +65,11 @@
                         "appkey_android" : "565ad55bec6d286e33a95a9ff1911b55"
                     }
                 },
-                "geolocation" : {},
+                "geolocation" : {
+                    "system" : {
+                        "__platform__" : [ "android" ]
+                    }
+                },
                 "push" : {},
                 "ad" : {}
             },

+ 18 - 8
pages/clockIn/clockIn.vue

@@ -95,11 +95,11 @@
 <script>
 	//#ifdef APP-PLUS
 	// var ALog = uni.requireNativePlugin("AndroidLog")
-	var location = uni.requireNativePlugin("Location")
+	// var location = uni.requireNativePlugin("Location")
 	//#endif
-	//#ifdef H5
+
 	import distance from "utils/getDistance.js"
-	//#endif
+
 	export default{
 		data(){
 			return{
@@ -155,23 +155,33 @@
 				uni.getLocation({
 					type:"gcj02",
 					success : function (res) {
+						// console.log('定位',res)
 						uni.hideLoading();
 						//#ifdef APP-PLUS
-						var dst = `${that.payeeinfo.latitude},${that.payeeinfo.longitude}`;
-						var src = res.latitude + ',' + res.longitude;
-						var locRet = location?.distance?.(src, dst);
+						// var dst = `${that.payeeinfo.latitude},${that.payeeinfo.longitude}`;
+						// var src = res.latitude + ',' + res.longitude;
+						// var locRet = location?.distance?.(src, dst);
 						that.positionInfo = true;
-						that.punchDistance = locRet.distance;
+						// that.punchDistance = locRet.distance;
 						that.punchRange = that.payeeinfo.workDistance;
-						if(locRet.distance <= that.payeeinfo.workDistance){//在打卡范围内
+						// console.log('res.latitude',res.latitude)
+						// console.log('res.longitude',res.longitude)
+						let myDistance = distance(res.latitude,res.longitude,that.payeeinfo.latitude,that.payeeinfo.longitude);
+						// console.log('myDistance',myDistance)
+						// console.log('workDistance',that.payeeinfo.workDistance)
+						that.punchDistance = myDistance;
+						if(myDistance <= that.payeeinfo.workDistance){//在打卡范围内
 						//#endif
 						//#ifdef H5
+						console.log('走H5')
 						that.positionInfo = true;
 						let myDistance = distance(res.latitude,res.longitude,that.payeeinfo.latitude,that.payeeinfo.longitude);
 						that.punchDistance = myDistance;
 						that.punchRange = that.payeeinfo.workDistance;
 						// console.log('res.latitude',res.latitude)
 						// console.log('res.longitude',res.longitude)
+						// console.log('myDistance',myDistance)
+						// console.log('workDistance',that.payeeinfo.workDistance)
 						// console.log('that.payeeinfo.latitude',that.payeeinfo.latitude)
 						if(myDistance <= that.payeeinfo.workDistance){//在打卡范围内
 						//#endif