zhangxinlei1996 4 năm trước cách đây
mục cha
commit
7a8e262f36

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

@@ -40,11 +40,9 @@ var Map_stype = map[string]bool{
 }
 
 func (s *Short) Article(stype, id string) error {
-	fmt.Println(s.Url())
 	//先判断是否有session
 	source := s.GetString("source")
 	disWord := s.GetString("disWord")
-	log.Println(disWord, "disWord")
 	aboutUrl := "/swordfish/about"
 	//是否已经检查过,默认是检查过-true,分享过来的是未检查过-false
 	//	checkIsSubscribeFlag := true
@@ -54,7 +52,16 @@ func (s *Short) Article(stype, id string) error {
 	if source != "" {
 		aboutUrl += "?source=" + source
 		if strings.Contains(source, "wx_infocontentshare") {
-			aboutUrl += "&from=" + id
+			decodeArr := util.DecodeArticleId2ByCheck(id)
+			if len(decodeArr) > 1 {
+				from_userid := GetUserId(decodeArr[1])
+				encode := se.EncodeStringByCheck(from_userid) //加密用户userid
+				aboutUrl += "&from=" + encode
+			}
+		} else if strings.Contains(source, "app_infocontentshare") {
+			if from := s.GetString("from"); from != "" {
+				aboutUrl += "&from=" + from
+			}
 		}
 	}
 	bm := false
@@ -175,8 +182,6 @@ func (s *Short) Article(stype, id string) error {
 		if ssOpenid != nil && ssOpenid != "" {
 			isSubscribe := CheckUserIsSubscribe(ssOpenid.(string))
 			if !isSubscribe {
-				r := util.DecodeArticleId2ByCheck(id)
-				log.Println(r)
 				return s.Redirect(aboutUrl, 302)
 			}
 			//之前sessionkeep.go中没有放userId,造成关注有问题
@@ -256,7 +261,6 @@ func (s *Short) Article(stype, id string) error {
 	} else {
 		sids := util.CommonDecodeArticle(stype, id)
 		if len(sids) == 0 {
-			fmt.Println("CommonDecodeArticle ==0")
 			s.Redirect("/notin/page", 302)
 			return nil
 		}
@@ -429,3 +433,12 @@ func getwinnertel(company interface{}) string {
 	}
 	return ""
 }
+
+func GetUserId(openid string) string {
+	data, ok := public.MQFW.FindOne("user", map[string]interface{}{"s_m_openid": openid})
+	if data != nil && len(*data) > 0 && ok {
+		userid := BsonIdToSId((*data)["_id"])
+		return userid
+	}
+	return ""
+}

+ 9 - 15
src/jfw/front/swordfish.go

@@ -1621,19 +1621,13 @@ func (m *Front) About() error {
 	if !mobileReg.MatchString(m.UserAgent()) && flag == "" {
 		return m.Redirect("/front/aboutus.html" + util.If(code != "", "?code="+code, "").(string))
 	}
-	from := m.GetString("from") //三级页获取分享用户的openid
-	from_openid := ""
-	if from != "" {
-		fmt.Println("from:", from, util.DecodeArticleId2ByCheck(from))
-		decodeArr := util.DecodeArticleId2ByCheck(from)
-		if len(decodeArr) > 1 {
-			from_openid = decodeArr[1]
-		}
+	from_userid, from_openid := "", ""
+	if from := m.GetString("from"); from != "" {
+		from_userid = se.DecodeStringByCheck(from)
 	}
 	myopenid, _ := m.Session().Get("s_m_openid").(string)
 	mynickname, _ := m.Session().Get("s_nickname").(string)
 	myavatar, _ := m.Session().Get("s_avatar").(string)
-	fmt.Println(myopenid, mynickname, "~~")
 	isSubscribe := false
 	if myopenid == "" {
 		if m.GetString("state") == "wx" {
@@ -1641,7 +1635,6 @@ func (m *Front) About() error {
 			code := m.GetString("code")
 			if code != "" {
 				myopenid = jyutil.Getopenid(code)
-				fmt.Println("myooooooooooo:", myopenid)
 			}
 		} else {
 			if public.CheckWxBrowser(m.Request) {
@@ -1675,14 +1668,15 @@ func (m *Front) About() error {
 		}
 	}
 	if from_openid != "" { //分享关联
-		from_userid := ""
 		fromuser, ok := public.MQFW.FindOne("user", map[string]interface{}{"s_m_openid": from_openid})
 		if fromuser != nil && len(*fromuser) > 0 && ok {
 			from_userid = BsonIdToSId((*fromuser)["_id"])
-			ok := redis.Put("other", "share_jyb_"+myopenid, from_userid, 60*5)
-			if !ok {
-				log.Println("分享用户关联redis出错", "分享者:", from_userid, "被分享者:", myopenid)
-			}
+		}
+	}
+	if from_userid != "" {
+		ok := redis.Put("other", "share_jyb_"+myopenid, from_userid, 60*5)
+		if !ok {
+			log.Println("分享用户关联redis出错", "分享者:", from_userid, "被分享者:", myopenid)
 		}
 	}
 	qrcodeType := m.GetString("qrcodeType")

+ 1 - 0
src/jfw/modules/app/src/app/front/shorturl.go

@@ -137,6 +137,7 @@ func (s *Short) Article(stype, id string) error {
 		s.T["advertUrl"] = config.Sysconfig["advertUrl"]
 		obj["industry"] = industry
 		obj["ucbsId"] = util.EncodeArticleId2ByCheck("ucbs#" + userId + "#" + id)
+		s.T["userId"] = se.EncodeStringByCheck(userId) //加密用户userid
 		if obj["winnertel"] == nil && isbid(obj["subtype"]) {
 			obj["winner_enttel"] = getwinnertel(obj["winner"])
 		}

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

@@ -767,7 +767,7 @@
             content += {{session "s_nickname"}};
         }
         content += "向您推荐了剑鱼标讯";
-        var link = "{{Msg "seo" "jyDomain"}}/swordfish/about?source=app_infocontentshare";
+        var link = "{{Msg "seo" "jyDomain"}}/swordfish/about?source=app_infocontentshare&from={{.T.userId}}";
         var shareTitle = {{.T.obj.title}};
         shareTitle=shareTitle.replace(/<\/?.+?>/g,"");
         shareTitle=shareTitle.replace(/ /g,"");
@@ -778,7 +778,7 @@
             }else{
                 link += "&";
             }
-            link += "source=app_infocontentshare";
+            link += "source=app_infocontentshare&from={{.T.userId}}";
         }else if(shareType == 3){
             if(forceShareFlag){
                 link += "&qrcodeType=app_infocontent_timeline_b";