Эх сурвалжийг харах

Merge remote-tracking branch 'origin/dev4.5.2' into dev4.5.2

wangkaiyue 4 жил өмнө
parent
commit
373387712c

+ 2 - 1
src/jfw/modules/app/src/seo.json

@@ -98,5 +98,6 @@
 		}
 	},
 	"structedUploadA":"/structuredata/file/【剑鱼标讯】结构化招标数据.xlsx",
-	"buryingPointUrl":"https://md.jianyu360.com"
+	"buryingPointUrl":"https://md.jianyu360.com",
+	"distance":"0"
 }

+ 88 - 0
src/jfw/modules/app/src/web/staticres/jyapp/js/common.js

@@ -316,6 +316,10 @@ var JyObjMessage = new Object();
 $(function () {
   if (mySysIsIos()) {
     window.JyObj = {
+      //获取经纬度
+      getLLitude: function () {
+        return JyObj.IosCall("getLLitude")
+      },
       //调转到指定的webview
       //name 对应的值:search 搜索 subscribe 订阅 box 百宝箱 me 我的
       skipAppointTab: function (name) {
@@ -995,6 +999,7 @@ function afterPageInit () {
   }, 600000);
   try {
     afterJyObjInit();
+    latlongitude();//记录用户经纬度
   } catch (e) {
   }
   var sign = JyObj.getUserToken();
@@ -1418,3 +1423,86 @@ function afterReceivePushMessage (type, url) {
     receivePushMessageHandle(type, url);
   } catch (e) { }
 }
+
+//获取用户经纬度 每天记录一次
+function latlongitude(){
+	//首页
+	if(window.location.href.indexOf("jylab/mainSearch")==-1){
+		return false;
+	}
+	var llitude = "";
+	var lsllitude = localStorage.LLitude;
+	var nowDate = new Date().getDate();
+	var oldDate = new Date().getDate()-1;
+	if (lsllitude!=null&&lsllitude.split("_").length>2){
+		oldDate =  Number(lsllitude.split("_")[2]);
+	}
+	//每天记录一次
+	//alert(nowDate+"--"+oldDate+"--"+parseInt(distance))
+	if (nowDate==oldDate){
+		return false;
+	}
+	try{
+		llitude = JyObj.getLLitude();
+	}catch(e){}
+    if(llitude==""){
+      var ai = 0;
+      var llInterval = setInterval(function(){
+        ai=ai+1;
+        try{
+          llitude = JyObj.getLLitude();
+        }catch(e){}
+        //五次获取不到客户端经纬度 就不再获取,获取位置存localStorage 一天
+        //alert(llitude+"---:"+ai)
+        if((llitude!=""&&llitude!=undefined&&llitude.indexOf("null")<0)||ai>4){
+          clearInterval(llInterval);
+          llrequest(llitude)
+        }
+      },500)
+    }else{
+    	//alert("经纬度:"+llitude)
+    	llrequest(llitude)
+    }
+}
+//判断经纬度是否够收录条件
+function llrequest(ll){
+	//获取不到定位信息
+	if(ll==null||ll.indexOf("_")==-1){
+		return false
+	}
+	//localStorage.removeItem("LLitude");
+	var latitude = parseFloat(ll.split("_")[1]);//纬度
+	var longitude =  parseFloat(ll.split("_")[0]);//经度
+	var _lat = 0.0;
+	var _long = 0.0;
+	var llitude = localStorage.LLitude;
+	if (llitude!=null&&llitude.split("_").length>2){
+		_long =  parseFloat(llitude.split("_")[0]);//经度
+		_lat =  parseFloat(llitude.split("_")[1]);//纬度
+	}
+	//alert(latitude+":::"+longitude+"----"+_lat+":::"+_long)
+	var calculate = calculateLL(latitude,longitude,_lat,_long);
+	if (calculate>parseInt(distance)){
+    	$.post("/publicapply/appLoc/action", {
+	        "longitude": longitude,
+	        "latitude": latitude,
+	        "calculate": calculate
+	    }, function (r) {
+	        if (r.data) {
+				localStorage.LLitude = ll+"_"+new Date().getDate();
+	        }
+      	})
+    }
+}
+/*计算两经纬度点之间的距离(单位:米)*/
+function calculateLL(lat1, lng1, lat2, lng2) {
+	var radLat1 = lat1 * Math.PI / 180.0;
+	var radLat2 = lat2 * Math.PI / 180.0;
+	var a = radLat1 - radLat2;
+	var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
+	var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
+	s = s * 6378.137;
+	s = Math.round(s * 10000) / 10;
+	//alert("距离上个位置:"+s+" 米")
+	return s
+}

+ 2 - 0
src/jfw/modules/app/src/web/templates/weixin/search/mainSearch.html

@@ -578,6 +578,8 @@
     });
 </script>
 <script type="text/javascript">
+    //获取定位距离差
+    var distance = {{Msg "seo" "distance"}};
     var member_status;
     var isMember = false;
     // 子账户判断

+ 6 - 5
src/jfw/modules/publicapply/src/applocation/entity/entity.go

@@ -6,7 +6,6 @@ import (
 	"fmt"
 	"log"
 	"net/http"
-	"qfw/util"
 	"qfw/util/redis"
 	"time"
 )
@@ -15,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"
@@ -27,7 +27,7 @@ var RedisUserKey = "apploc_%s"
 
 //保存定位信息
 func (this *AppLocStruct) SaveAppLocInfo() bool {
-	log.Println(this.Longitude, "---", this.Latitude)
+	log.Println(this.UserId, ":", this.Longitude, "-", this.Latitude)
 	timeNow := time.Now()
 	ref := this.R.Referer()
 	appLocInfo := map[string]interface{}{
@@ -35,7 +35,8 @@ func (this *AppLocStruct) SaveAppLocInfo() bool {
 		"userId":    this.UserId,
 		"longitude": this.Longitude,
 		"latitude":  this.Latitude,
-		"ip":        util.GetIp(this.R),
+		"calculate": this.Calculate,
+		"ip":        this.R.Proto,
 		"refer":     ref,
 		"year":      timeNow.Year(),
 		"month":     timeNow.Month(),

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

@@ -3,7 +3,6 @@ package service
 import (
 	. "api"
 	"applocation/entity"
-	"log"
 	"net/http"
 	qu "qfw/util"
 
@@ -28,12 +27,12 @@ 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()
 		}
-		log.Println("retBool:", retBool)
 		return Result{Data: retBool}
 	}()
 	this.ServeJson(r)

+ 16 - 3
src/jfw/modules/publicapply/src/bidcollection/entity/entity.go

@@ -40,12 +40,25 @@ func IsCollByBidsBackInfo(bids, userid string) map[string]interface{} {
 	if bdinfos := *db.Mysql.SelectBySql(fmt.Sprintf("SELECT labelid FROM %s WHERE userid = ? AND bid = ?", db.DbConf.Bdcollection), userid, bid); len(bdinfos) > 0 {
 		bdinfo := bdinfos[0]
 		label_ids := qu.ObjToString(bdinfo["labelid"])
-		var labArr = []string{}
+		var labArr = []map[string]interface{}{}
 		res["iscoll"] = true
 		if label_ids != "" {
-			if labinfos := *db.Mysql.SelectBySql(fmt.Sprintf("SELECT * FROM %s WHERE id IN (?)", db.DbConf.Bdlabel), strings.Split(label_ids, ",")[0]); len(labinfos) > 0 {
+			label_ids_inter := []interface{}{}
+			var instatus = "?"
+			for k, id := range strings.Split(label_ids, ",") {
+				if k > 0 {
+					instatus += ",?"
+				}
+				label_ids_inter = append(label_ids_inter, id)
+			}
+			if labinfos := *db.Mysql.SelectBySql(fmt.Sprintf("SELECT * FROM %s WHERE id IN (%s)", db.DbConf.Bdlabel, instatus), label_ids_inter...); len(labinfos) > 0 {
 				for _, v := range labinfos {
-					labArr = append(labArr, qu.ObjToString(v["labelname"]))
+					lid := strconv.FormatInt(v["id"].(int64), 10)
+					lid_str := qu.SE.EncodeString(lid)
+					labArr = append(labArr, map[string]interface{}{
+						"labelname": qu.ObjToString(v["labelname"]),
+						"id":        lid_str,
+					})
 				}
 			}
 		}