Browse Source

Merge branch 'dev3.6' of http://192.168.3.207:10080/qmx/jy into dev3.6

zhangyuhan 4 years ago
parent
commit
946df8b415

+ 6 - 5
src/jfw/front/shorturl.go

@@ -254,15 +254,16 @@ func (s *Short) Article(stype, id string) error {
 			s.T["forceShareFlag"] = public.CheckUserNeedForceShare(userId, public.ShareType_detail)     //是否强制分享
 			if from_userid != "" && from_userid != userId && util.ObjToString(obj["subtype"]) != "拟建" { //分享开打的
 				article_id := util.CommonDecodeArticle(stype, id)[0]
-				if redis.Get("other", fmt.Sprintf("integral_article_%s_%s_%s", article_id, from_userid, userId)) == nil {
-					fmt.Println("from_userid", se.DecodeStringByCheck(from_userid))
+				key := fmt.Sprintf("integral_article_%s_%s_%s", article_id, from_userid, userId)
+				if redis.Incr("other", key) == 1 {
+					redis.SetExpire("other", key, 60*60*24)
 					err := jy.Publish(public.Mgo_Log, config.Sysconfig["nsq"].(string), jy.Jyweb_article_open, se.DecodeStringByCheck(from_userid), jy.Jywx_node1)
 					if err != nil {
 						log.Println("nsq队列写入失败-->", jy.Jyweb_article_open, se.DecodeStringByCheck(from_userid))
-					} else {
+					} /* else {
 						//integral_article_ +userId+ 三级页id
-						redis.Put("other", fmt.Sprintf("integral_article_%s_%s_%s", article_id, from_userid, userId), "1", 60*60*24)
-					}
+						redis.Put("other", fmt.Sprintf("integral_article_%s_%s_%s", article_id, from_userid, userId), 1, 60*60*24)
+					}*/
 				}
 			}
 			content, _ := s.Render4Cache("/weixin/wxinfocontent"+rec+".html", &s.T)

+ 33 - 24
src/jfw/front/singleLogin.go

@@ -35,40 +35,49 @@ func (this *SingleLogin) ShortUrl(key string) error {
 	return this.Redirect(redirectUrl)
 }
 
-//是否关注处理
+//toHref 已关注跳转页面
+//unHref 为关注跳转页面,若无此字段会跳至关注二维码页面
+//	*已有逻辑 1.线上课程推文,用户点击可登陆跳转;未关注扫码会回复课程链接
+//			2.文库赚积分
 func (this *SingleLogin) SingleLogin() error {
-	userid := qutil.ObjToString(this.GetSession("userId"))
-	toHref := this.GetString("toHref")
-	if userid != "" { //已有session,直接跳转至结果页面
-		return this.Redirect(toHref)
+	openid := qutil.ObjToString(this.Session().Get("s_m_openid"))
+	data := map[string]interface{}{
+		"toHref": this.GetString("toHref"),
+		"unHref": this.GetString("unHref"),
 	}
-	data := map[string]interface{}{}
-	stateKey := this.GetString("state")
-	if stateKey == "" { //公众号回调
-		stateKey = getTmpKey()
-		//暂存参数
-		for k, v := range this.Request.Form {
-			if len(v) > 0 {
-				data[k] = v[0]
+	if openid == "" {
+		stateKey := this.GetString("state")
+		if stateKey == "" { //公众号回调
+			stateKey = getTmpKey()
+			//暂存参数
+			for k, v := range this.Request.Form {
+				if len(v) > 0 {
+					data[k] = v[0]
+				}
 			}
+			redis.Put("other", stateKey, data, 60*5) //存储信息
+			return this.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(this.Site()+this.Url()), stateKey), 302)
 		}
-		redis.Put("other", stateKey, data, 60*5) //存储信息
-		return this.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(this.Site()+this.Url()), stateKey), 302)
-	}
-	//获取wx跳转前参数
-	if redisValue := redis.Get("other", stateKey); redisValue != nil {
-		if param, ok := redisValue.(map[string]interface{}); ok {
-			data = param
+		//获取wx跳转前参数
+		if redisValue := redis.Get("other", stateKey); redisValue != nil {
+			if param, ok := redisValue.(map[string]interface{}); ok {
+				data = param
+			}
 		}
+		//获取用户openid
+		openid = jyutil.Getopenid(this.GetString("code"))
 	}
-	openid := jyutil.Getopenid(this.GetString("code")) //获取用户openid
-	//登录成功跳转
-	if loginCreateSess(openid, this.Session()) {
+	//判断是否关注
+	isSubscribe := CheckUserIsSubscribe(openid)
+	if isSubscribe { //关注跳转
+		if this.GetSession("userId") == nil {
+			loginCreateSess(openid, this.Session())
+		}
 		return this.Redirect(qutil.ObjToString(data["toHref"]))
 	}
 	//未关注跳转
 	if unHref := qutil.ObjToString(data["unHref"]); unHref != "" {
-		return this.Render(unHref)
+		return this.Redirect(unHref)
 	}
 	//跳转二维码关注页面,关注回复链接
 	if data["toHref"] != nil && data["title"] != nil {

+ 5 - 3
src/jfw/modules/app/src/app/front/shorturl.go

@@ -132,14 +132,16 @@ func (s *Short) Article(stype, id string) error {
 	if len(obj) > 0 {
 		if belongUserId != "" && belongUserId != userId && util.ObjToString(obj["subtype"]) != "拟建" { //分享开打的
 			article_id := util.CommonDecodeArticle(stype, id)[0]
-			if redis.Get("other", fmt.Sprintf("integral_article_%s_%s_%s", article_id, belongUserId, userId)) == nil {
+			key := fmt.Sprintf("integral_article_%s_%s_%s", article_id, belongUserId, userId)
+			if redis.Incr("other", key) == 1 {
+				redis.SetExpire("other", key, 60*60*24)
 				err := jy.Publish(public.Mgo_Log, config.Sysconfig["nsq"].(string), jy.Jyweb_article_open, belongUserId, jy.Jyapp_node1)
 				if err != nil {
 					log.Println("nsq队列写入失败-->", jy.Jyweb_article_open, belongUserId)
-				} else {
+				} /* else {
 					//integral_article_ +userId+ 三级页id
 					redis.Put("other", fmt.Sprintf("integral_article_%s_%s_%s", article_id, belongUserId, userId), "1", 60*60*24)
-				}
+				}*/
 			}
 		}
 		//获取打赏文案

+ 2 - 1
src/jfw/modules/app/src/web/templates/commonPay/paySuccess.html

@@ -84,7 +84,7 @@
             </div>
         {{else if eq .T.doType "integral"}}
             <div class="bottom_button">
-                <button style="margin: 0 .32rem; background-color: #2cb7ca; margin-bottom: 0.45rem;height: 0.92rem;border-radius: 0.16rem;" class="right_btn" onclick="window.location.href = '/jyapp/front/myorder/tointegralDetail?order_code={{.T.orderCode}}'">
+                <button id ="order" style="margin: 0 .32rem; background-color: #2cb7ca; margin-bottom: 0.45rem;height: 0.92rem;border-radius: 0.16rem;" class="right_btn" onclick="window.location.href = '/jyapp/front/myorder/tointegralDetail?order_code={{.T.orderCode}}'">
                     查看订单
                 </button>
                 <button style="display:none;margin: 0 .32rem; background-color: #2cb7ca; margin-bottom: 0.45rem;height: 0.92rem;border-radius: 0.16rem;" class="right_btn" id ="read" >
@@ -135,6 +135,7 @@
           $("#read").show().click(function(){
             window.location.href = '/page_docs_app/details/'+docsId;
           });
+          $("#order").css({"background-color":"#EDEFF2","color":"#5F5E64"});
         }
     })
 

+ 1 - 0
src/jfw/modules/subscribepay/src/service/integral.go

@@ -94,6 +94,7 @@ func (b *Integral) CreateOrder() {
 			"user_id":        userId,
 			"pay_way":        "",
 			"original_price": order_money,
+			"user_phone":     phone,
 		}
 		order_phone := b.GetString("order_phone") //p19.3用户信息采集 手机号
 		if order_phone != "" {

+ 1 - 1
src/web/staticres/css/pc.css

@@ -67,7 +67,7 @@ form{
 	margin-top:20px;
 	width:70px;
 	height:35px;
-	margin-left:15px;
+	margin-left:40px;
 	line-height:0px;
 	background:none;
 	color:#666666;

+ 40 - 48
src/web/staticres/js/login.js

@@ -5,13 +5,12 @@ if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.ma
 	bIE9=true
 }
 var wsUrl = "ws"+(!bIE9&&"https:"==document.location.protocol?"s":"")+"://"+window.location.host+"/ws";
-var ws = "";
+var ws = null;
 var openid = "";
 var jylgi = 0;
 var loginflag = false;//登录状态
 var mynum = "";//页面参数num
 var keysorpname = "";//项目名称
-var kzyflag = false;//快照页标识
 var thurl = "";//url
 var semnum = "";//SEM
 var ldpnum = "";//落地页扫码后调整标识
@@ -27,7 +26,7 @@ var sendMsgInterval = null;
 var entjumpflag = false;
 //轮询查询
 var LoginPolling = {
-	isPostLoginPolling: false,//是否发起轮询请求
+	isPostLoginPolling: true,//是否发起轮询请求
 	loginPollingInterval: null,
 	initInterval: null,
 	init: function(){
@@ -51,7 +50,7 @@ var LoginPolling = {
 			timeout: 3000,
 			success: function(r){
 				clearInterval(LoginPolling.initInterval);
-				//LoginPolling.initInterval = null;
+				LoginPolling.initInterval = null;
 			}
 		});
 	},
@@ -60,12 +59,10 @@ var LoginPolling = {
 		if(this.loginPollingInterval != null){
 			return;
 		}
+		this.init();
 		//定时器,定时请求看是否扫码登录,返回用户信息,登录
 		this.loginPollingInterval = setInterval(function(){
 			//如果浏览器不支持webscoket,走ajax轮询方式
-			if(window.WebSocket == undefined) {
-				LoginPolling.isPostLoginPolling = true;
-			}
 			if(WSpolling.isPageHidden || !LoginPolling.isPostLoginPolling){
 				return;
 			}
@@ -92,17 +89,21 @@ var LoginPolling = {
 }
 var webSocketHeartCheck = new WebSocketHeartCheck(LoginPolling);
 //创建websocket连接
-var createWebSocket = function(flag){
-	try{
-		ws = new WebSocket(wsUrl);//实例化websocket对象
-		initEventHandle(flag);
-	}catch(e){
-		reconnect();
-		//console.log(e)
+var createWebSocket = function(){
+	if("WebSocket" in window){
+		try{
+			ws = new WebSocket(wsUrl);//实例化websocket对象
+			initEventHandle();
+		}catch(e){
+			reconnect();
+			//console.log(e)
+		}	
+	}else{
+		LoginPolling.isPostLoginPolling = true;
 	}
 }
 //
-var initEventHandle = function(flag){
+var initEventHandle = function(){
 	ws.onmessage = function(e){
 		//接收消息正常,就不再发ajax轮询
 		LoginPolling.isPostLoginPolling = false;
@@ -126,9 +127,7 @@ var initEventHandle = function(flag){
         reconnect();
     }
 	ws.onopen = function(e) {
-		if(flag){//重连之后发送shareid
-			SendMsg();
-		}
+		SendMsg();
 		//心跳检测重置
         webSocketHeartCheck.reset().start(ws,loginflag);
 	}
@@ -143,7 +142,7 @@ function reconnect() {
 	LoginPolling.init();
     //没连接上会一直重连,设置延迟避免请求过多
     setTimeout(function () {
-        createWebSocket(true);
+        createWebSocket();
 		webSocketHeartCheck.lockReconnect = false;
     }, 2000);
 }
@@ -153,29 +152,25 @@ var JYLogin = function(num){
 	loginfg = setInterval(function(){
 		jylgi++;
 		//console.log(jylgi+"-----")
-		if(jylgi>12*60){
-			getNewShareId(num);
+		if(jylgi>120*60){
+			getNewShareId(num,false);
 			jylgi = 0;
 		}
 	},1000)
-	LoginPolling.init();
-	SendMsg();
 }
 var SendMsg = function(){
-	//向后台发送websocket数据
-	if (window["WebSocket"]){
-		if(ws.readyState==1){
-			//console.log("发送:"+pageshareid+"___"+kopshareid)
-			ws.send(pageshareid+"___"+kopshareid);
-		}else{
-			LoginPolling.isPostLoginPolling = true;
-		}
+	if(pageshareid==""||kopshareid==""){
+		return;
+	}
+	if(ws!=null&&ws.readyState==1){
+		//console.log("发送:"+pageshareid+"___"+kopshareid)
+		ws.send(pageshareid+"___"+kopshareid);
 	}else{
 		LoginPolling.isPostLoginPolling = true;
 	}
 }
 //生成页面二维码,不同页面处理逻辑
-var getNewShareId = function(num){
+var getNewShareId = function(num,isFirst){
 	mynum = num;
 	pageType = "T"
 	var rref = document.referrer;
@@ -192,6 +187,15 @@ var getNewShareId = function(num){
 			pageshareid = data.num;
 			kopshareid = data.numot;
 			mynum = num;
+			if(!loginflag){
+				if(isFirst){
+					LoginPolling.start();
+					createWebSocket();
+				}else if(!isFirst){
+					LoginPolling.init();
+					SendMsg();
+				}
+			}
 			localStorage.setItem("oldshareid", pageshareid);
 			//redisUserInfo(pageshareid,kopshareid);
 			$(".jyhead_qr img").attr("src","/front/share/"+pageshareid);
@@ -265,14 +269,7 @@ var getNewShareId = function(num){
 				case "23"://数据导出
 					break;
 			}
-			if(num=="13"&&!kzyflag){
-				return false;
-			}
-			setTimeout(function(){
-				if(!loginflag){
-					JYLogin(num);
-				}
-			},500);
+			JYLogin(num);
 		}
 	},'json');
 }
@@ -543,7 +540,6 @@ var processpage = function(shareid,num){
 //退出登录
 var signout = function(){
 	clearInterval(loginfg);
-	kzyflag = true;
 	loginflag = false;
 	unseatflag = false;
 	unseatzbqyflag = false;
@@ -567,8 +563,8 @@ var signout = function(){
             }else{
             	window.location.reload();
 				/*LoginPolling.start();
-				createWebSocket(false);
-				getNewShareId(mynum);*/
+				createWebSocket();
+				getNewShareId(mynum,true);*/
 			}
 		}
 	})
@@ -633,15 +629,11 @@ var haslogin = function(num,kyorpn,url){
 				infoListCss();
 				commonMouseEvent();
 			}catch(e){}
-			getNewShareId(num);
 		}else{
 			$("#login").html("<button class='loginBtn' data-toggle='modal' onclick='openLoginDig()'>登录</button>");
 			loginBtnType();
-			getNewShareId(num);
-			LoginPolling.start();
-			createWebSocket(false);
-			kzyflag = true;//未登录进入快照页面
 		}
+		getNewShareId(num,true);
 	})
 }
 function loginBtnType(){

+ 2 - 1
src/web/templates/weixin/commonPay/paySuccess.html

@@ -68,7 +68,7 @@
     {{end}}
      {{if eq .T.doType "integral"}}
     <div class="bottom_button">
-        <button class="right_btn" onclick="window.location.href = '/front/wxMyOrder/integralDetail/{{.T.orderCode}}'">
+        <button id="order" class="right_btn" onclick="window.location.href = '/front/wxMyOrder/integralDetail/{{.T.orderCode}}'">
             查看订单
         </button>
         <button class="right_btn" id ="read" style="display:none">
@@ -101,6 +101,7 @@
           $("#read").show().click(function(){
             window.location.href = '/page_docs_app/details/'+docsId;
           });
+          $("#order").css({"background-color":"#EDEFF2","color":"#5F5E64"});
         }
     })