浏览代码

记录上次的距离

wangshan 4 年之前
父节点
当前提交
77b4a4af11

+ 5 - 3
src/jfw/modules/app/src/web/staticres/jyapp/js/common.js

@@ -1481,10 +1481,12 @@ function llrequest(ll){
 		_lat =  parseFloat(llitude.split("_")[1]);//纬度
 	}
 	//alert(latitude+":::"+longitude+"----"+_lat+":::"+_long)
-	if (caculateLL(latitude,longitude,_lat,_long)>parseInt(distance)){
+	var calculate = calculateLL(latitude,longitude,_lat,_long);
+	if (calculate>parseInt(distance)){
     	$.post("/publicapply/appLoc/action", {
 	        "longitude": longitude,
-	        "latitude": latitude
+	        "latitude": latitude,
+	        "calculate": calculate
 	    }, function (r) {
 	        if (r.data) {
 				localStorage.LLitude = ll+"_"+new Date().getDate();
@@ -1493,7 +1495,7 @@ function llrequest(ll){
     }
 }
 /*计算两经纬度点之间的距离(单位:米)*/
-function caculateLL(lat1, lng1, lat2, lng2) {
+function calculateLL(lat1, lng1, lat2, lng2) {
 	var radLat1 = lat1 * Math.PI / 180.0;
 	var radLat2 = lat2 * Math.PI / 180.0;
 	var a = radLat1 - radLat2;

+ 4 - 2
src/jfw/modules/publicapply/src/applocation/entity/entity.go

@@ -14,11 +14,12 @@ type AppLocStruct struct {
 	UserId    string //用户id
 	Longitude string // 经度
 	Latitude  string //纬度
+	Calculate string //距离上次定位的距离(米)
 	R         *http.Request
 }
 
-func NewAppLoc(userId, longitude, latitude string, r http.Request) *AppLocStruct {
-	return &AppLocStruct{userId, longitude, latitude, &r}
+func NewAppLoc(userId, longitude, latitude, calculate string, r http.Request) *AppLocStruct {
+	return &AppLocStruct{userId, longitude, latitude, calculate, &r}
 }
 
 var AppLocLog = "apploc_log"
@@ -34,6 +35,7 @@ func (this *AppLocStruct) SaveAppLocInfo() bool {
 		"userId":    this.UserId,
 		"longitude": this.Longitude,
 		"latitude":  this.Latitude,
+		"calculate": this.Calculate,
 		"ip":        this.R.Proto,
 		"refer":     ref,
 		"year":      timeNow.Year(),

+ 2 - 1
src/jfw/modules/publicapply/src/applocation/service/service.go

@@ -27,8 +27,9 @@ func (this *ServiceStruct) AppLocAction() {
 		}
 		longitude := this.GetString("longitude") //经度
 		latitude := this.GetString("latitude")   //纬度
+		calculate := this.GetString("calculate") //距离上次定位的距离
 		var r http.Request
-		newAppLoc := entity.NewAppLoc(userId, longitude, latitude, r)
+		newAppLoc := entity.NewAppLoc(userId, longitude, latitude, calculate, r)
 		if newAppLoc.IsSaveBool() {
 			retBool = newAppLoc.SaveAppLocInfo()
 		}