wangchuanjin 7 years ago
parent
commit
5217df799b

+ 3 - 2
src/jfw/modules/app/src/jfw/front/front.go

@@ -48,8 +48,9 @@ type Front struct {
 	captcha         xweb.Mapper `xweb:"/jyapp/free/captcha"`  //生成验证码图片
 	getIndexData    xweb.Mapper `xweb:"/jyapp/free/front/getIndexData"`
 	limitSearchText xweb.Mapper `xweb:"/jyapp/front/limitSearchText"`
-	index           xweb.Mapper `xweb:"/jyapp/free/index"`  //打开app跳转
-	kicked          xweb.Mapper `xweb:"/jyapp/free/kicked"` //被踢人之后跳转
+	index           xweb.Mapper `xweb:"/jyapp/free/index"`    //打开app跳转
+	kicked          xweb.Mapper `xweb:"/jyapp/free/kicked"`   //被踢人之后跳转
+	shareTip        xweb.Mapper `xweb:"/jyapp/info/shareTip"` //分享记录
 }
 
 var sewx util.SimpleEncrypt //微信的加密方法

+ 35 - 0
src/jfw/modules/app/src/jfw/front/swordfish.go

@@ -1124,3 +1124,38 @@ func SaveUserSearchLog(request *http.Request, openid interface{}, count int64, p
 		mongodb.Save("jy_search_log", data)
 	}()
 }
+
+//分享提示
+func (m *Front) ShareTip() {
+	openid, _ := m.GetSession("s_m_openid").(string)
+	if openid == "" {
+		return
+	}
+	id := m.GetString("id")
+	if id == "" {
+		return
+	}
+	id = util.DecodeArticleId2ByCheck(id)[0]
+	reqType := m.GetString("reqType")
+	status := false
+	if reqType == "save" {
+		status = mongodb.Save("cshareinfo", map[string]interface{}{
+			"id":         id,
+			"openid":     openid,
+			"style":      "deepRead",
+			"platform":   "app",
+			"createtime": time.Now().Unix(),
+		}) != ""
+	} else {
+		count, err := mongodb.CountByErr("cshareinfo", map[string]interface{}{
+			"openid": openid,
+			"id":     id,
+		})
+		if err == nil && count == 0 {
+			status = true
+		}
+	}
+	m.ServeJson(map[string]interface{}{
+		"status": status,
+	})
+}

+ 4 - 12
src/jfw/modules/app/src/web/templates/weixin/search/mainSearch.html

@@ -667,20 +667,16 @@
 	function checkIsOpen(){
 		$(".content ul li a:eq(0)").unbind("click");
 		$(".content ul li a:eq(1)").unbind("click");
+		//超级搜索跳转
+	    $(".content ul li a:eq(0)").click(function(){
+			SuperSearch.init(true,true,true);
+	    });
 		//查询是否开通超级搜索和中标企业搜索
 		if(s_openid != ""){
 		    $.post("/jyapp/jylab/supsearch/getstatus?t="+new Date().getTime(),function(result){
 				open_supersearch=result.supstatus;
 		        open_entsesearch=result.entstatus;
 				onceFlag_tablepro=result.tablepro;
-				//超级搜索跳转
-			    $(".content ul li a:eq(0)").click(function(){
-					if(open_supersearch){
-						SuperSearch.init(true,true,true);
-			        }else{
-			            window.location.href='/jyapp/jylab/laboratory/cjss?v=superSearch_back';
-			        }
-			    });
 				//中标企业搜索跳转
 			    $(".content ul li a:eq(1)").click(function(){
 					if(open_entsesearch){
@@ -692,10 +688,6 @@
 			    });
 		    });
 		}else{
-			//超级搜索跳转
-		    $(".content ul li a:eq(0)").click(function(){
-				SuperSearch.init(true,true,true);
-		    });
 			//中标企业搜索跳转
 		    $(".content ul li a:eq(1)").click(function(){
 				window.location.href='/jyapp/free/login';

+ 78 - 0
src/jfw/modules/app/src/web/templates/weixin/wxinfocontent.html

@@ -1186,6 +1186,12 @@ $(function(){
 		//window.location.href = '/jyapp/free/transfer?url='+encodeURIComponent($(this).attr("href"));
 		JyObj.openExternalLink($(this).attr("href"),"查看原文");
 	});
+	//深度阅读
+	$.post("/jyapp/info/shareTip",{id:{{.T.obj._id}}},function(r){
+		if(r.status){
+			deepReading();
+		}
+	});
 })
 function isFollow(){
 	$.post("/jyapp/follow/checkCStatus",{pcname:{{.T.obj.projectname}},pccode:{{.T.obj.projectcode}}},function(fd){
@@ -1208,6 +1214,78 @@ function openAttachment(o){
 		event.preventDefault();
 	}
 }
+function deepReading(){
+	var infoOffsetTop = $(".info").offset().top;
+	//正文高度
+	var contentHeight = $(".content").height() + $(".content").offset().top - $(".info").offset().top;
+	//窗口高度
+	var windowHeight = $(window).height();
+	//可视区域高度
+	var clientHeight = document.body.clientHeight - $(".app-layout-header").outerHeight();
+	//总屏数
+	var countScreen = Math.floor(contentHeight / clientHeight);
+	//console.info("countScreen---"+countScreen)
+	if(contentHeight <= 0){
+		return;
+	}
+	var screenObj = {};
+	var depthReadTime = setInterval(function(){
+		var thisScrollTop = $(window).scrollTop();
+		var currentScreen = -1;
+		for(var i=1;i<=countScreen;i++){
+			if(thisScrollTop >= i-1*clientHeight && thisScrollTop <= i*clientHeight){
+				currentScreen = i;
+				break;
+			}
+		}
+		if(currentScreen == -1){
+			return;
+		}
+		if(typeof(screenObj[currentScreen]) == "undefined"){
+			screenObj[currentScreen] = 1;	
+		}else{
+			screenObj[currentScreen] = screenObj[currentScreen] + 1;
+		}
+		var isPassShow = false;
+		var gtTenCount = 0;
+		for(var i=1;i<=countScreen;i++){
+			if(typeof(screenObj[i]) == "undefined" || screenObj[i] <= 3){
+				break;
+			}
+			//如果只有一屏,30秒
+			if(countScreen == 1){
+				if(screenObj[i] < 30){
+					break
+				}
+			}else if(countScreen == 2){
+				if(screenObj[i] < 10){
+					break
+				}
+			}else{
+				if(screenObj[i] >= 10){
+					gtTenCount++;
+				}
+			}
+			//
+			if(i == countScreen){
+				if(countScreen <= 2){
+					isPassShow = true;
+				}else{
+					if(screenObj[i] >= 10 && gtTenCount >= Math.ceil(countScreen / 2)){
+						isPassShow = true;
+					}
+				}
+			}
+		}
+		//console.info(screenObj)
+		//console.info(gtTenCount+"----"+countScreen)
+		if(isPassShow){
+			clearInterval(depthReadTime);
+			$.post("/jyapp/info/shareTip",{reqType:"save",id:{{.T.obj._id}}});
+			alert("分享");
+		}
+	},1000);
+}
 </script>
 {{include "/common/baiducc.html"}}
 </body>

+ 74 - 0
src/web/templates/weixin/wxinfocontent.html

@@ -1203,6 +1203,11 @@ $(function(){
 		event.preventDefault();
 		window.location.href = '/front/transfer?url='+encodeURIComponent($(this).attr("href"));
 	});
+	//发起ajax请求,控制之前弹出过就不再弹出
+	//?????
+	//if(){
+		deepReading();
+	//}
 })
 function reward(){
 	window.location.href = "/front/pay/redirect?id={{.T.obj._id}}&source=m";
@@ -1235,6 +1240,75 @@ function isFollow(){
 		}
 	});
 }
+function deepReading(){
+	//正文高度
+	var contentHeight = $(".content").height() + $(".content").offset().top;
+	//可视区域高度
+	var clientHeight = document.body.clientHeight;
+	//总屏数
+	var countScreen = Math.floor(contentHeight / clientHeight);
+	//console.info("countScreen---"+countScreen)
+	if(contentHeight <= 0){
+		return;
+	}
+	var screenObj = {};
+	var depthReadTime = setInterval(function(){
+		var thisScrollTop = $(window).scrollTop();
+		var currentScreen = -1;
+		for(var i=1;i<=countScreen;i++){
+			if(thisScrollTop >= i-1*clientHeight && thisScrollTop <= i*clientHeight){
+				currentScreen = i;
+				break;
+			}
+		}
+		if(currentScreen == -1){
+			return;
+		}
+		if(typeof(screenObj[currentScreen]) == "undefined"){
+			screenObj[currentScreen] = 1;	
+		}else{
+			screenObj[currentScreen] = screenObj[currentScreen] + 1;
+		}
+		var isPassShow = false;
+		var gtTenCount = 0;
+		for(var i=1;i<=countScreen;i++){
+			if(typeof(screenObj[i]) == "undefined" || screenObj[i] <= 3){
+				break;
+			}
+			//如果只有一屏,30秒
+			if(countScreen == 1){
+				if(screenObj[i] < 30){
+					break
+				}
+			}else if(countScreen == 2){
+				if(screenObj[i] < 10){
+					break
+				}
+			}else{
+				if(screenObj[i] >= 10){
+					gtTenCount++;
+				}
+			}
+			//
+			if(i == countScreen){
+				if(countScreen <= 2){
+					isPassShow = true;
+				}else{
+					if(screenObj[i] >= 10 && gtTenCount >= Math.ceil(countScreen / 2)){
+						isPassShow = true;
+					}
+				}
+			}
+		}
+		//console.info(screenObj)
+		//console.info(gtTenCount+"----"+countScreen)
+		if(isPassShow){
+			clearInterval(depthReadTime);
+			//?发起ajax请求,保存记录
+			alert("分享");
+		}
+	},1000);
+}
 </script>
 {{include "/common/baiducc.html"}}
 </body>