|
@@ -55,7 +55,7 @@ var (
|
|
|
"indexcontent": true,
|
|
|
"advancedProject": true,
|
|
|
}
|
|
|
- seoAgentReg = regexp.MustCompile("Baiduspider|360Spider|bingbot|Googlebot")
|
|
|
+ //seoAgentReg = regexp.MustCompile("Baiduspider|360Spider|bingbot|Googlebot")
|
|
|
detailNeedMosaic map[string]interface{}
|
|
|
TypeCodeMap = map[string]string{
|
|
|
"拟建": "拟建项目",
|
|
@@ -83,9 +83,35 @@ var (
|
|
|
)
|
|
|
|
|
|
func (s *Short) Article(stype, id string) error {
|
|
|
+ //是否是移动端
|
|
|
+ bm := mobileReg.MatchString(s.Header("User-Agent"))
|
|
|
+ //是否是微信浏览器
|
|
|
+ isWxB := public.CheckWxBrowser(s.Request)
|
|
|
userId, _ := s.GetSession("userId").(string)
|
|
|
+ //未登录用户是否访问的微信浏览器
|
|
|
+ if userId == "" {
|
|
|
+ if IsWxBrowserContent[stype] {
|
|
|
+ if s.GetString("state") == "wx" {
|
|
|
+ //微信跳回来的
|
|
|
+ if code := s.GetString("code"); code != "" {
|
|
|
+ if openid := jyutil.Getopenid(code); openid != "" {
|
|
|
+ if CheckUserIsSubscribe(openid) {
|
|
|
+ FindUserAndCreateSess(openid, s.Session(), "wx", false, true)
|
|
|
+ //生session后 重新获取一下
|
|
|
+ userId, _ = s.GetSession("userId").(string)
|
|
|
+ } else if !bm { //未关注用户 pc端到关注页面
|
|
|
+ return s.Redirect("https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=Mzk0MjIyMzY2Nw==&scene=110#wechat_redirect")
|
|
|
+ } //未关注用户 移动端下面处理
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if isWxB {
|
|
|
+ //所有参数都不再使用,跳到微信验证用户
|
|
|
+ return s.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(s.Site()+s.Url()), "wx"), 302)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//PC端未登录用户程序走此逻辑 WX端走原来逻辑
|
|
|
- if !mobileReg.MatchString(s.Header("User-Agent")) && (stype == "content" || stype == "indexcontent") && userId == "" {
|
|
|
+ if !bm && (stype == "content" || stype == "indexcontent") && userId == "" {
|
|
|
//if seoAgentReg.MatchString(s.UserAgent()) {
|
|
|
sids := encrypt.CommonDecodeArticle(stype, id)
|
|
|
return s.NologinCommon("", stype, id, sids[0])
|
|
@@ -93,12 +119,10 @@ func (s *Short) Article(stype, id string) error {
|
|
|
// return s.Redirect("/notin/page")
|
|
|
//}
|
|
|
}
|
|
|
- return s.LoginCommon(userId, stype, id)
|
|
|
+ return s.LoginCommon(userId, stype, id, bm)
|
|
|
}
|
|
|
|
|
|
-func (s *Short) LoginCommon(userId, stype, id string) error {
|
|
|
- client := s.Header("User-Agent")
|
|
|
- bm := mobileReg.MatchString(client)
|
|
|
+func (s *Short) LoginCommon(userId, stype, id string, bm bool) error {
|
|
|
//电脑端 剑鱼快照页面访问
|
|
|
if stype == "content" && !bm {
|
|
|
//工作桌面内嵌 快照页
|
|
@@ -141,26 +165,6 @@ func (s *Short) LoginCommon(userId, stype, id string) error {
|
|
|
s.Redirect("/not/nottype", 302)
|
|
|
return nil
|
|
|
} else if stype == "content" || stype == "bdcontent" || stype == "advancedProject" {
|
|
|
- if userId == "" && bm {
|
|
|
- if s.GetString("state") == "wx" {
|
|
|
- //微信跳回来的
|
|
|
- if code := s.GetString("code"); code != "" {
|
|
|
- if openid := jyutil.Getopenid(code); openid != "" {
|
|
|
- if CheckUserIsSubscribe(openid) {
|
|
|
- FindUserAndCreateSess(openid, s.Session(), "wx", false, true)
|
|
|
- //生session后 重新获取一下
|
|
|
- userId, _ = s.GetSession("userId").(string)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else if public.CheckWxBrowser(s.Request) {
|
|
|
- //所有参数都不再使用,跳到微信验证用户
|
|
|
- return s.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(s.Site()+s.Url()), "wx"), 302)
|
|
|
- }
|
|
|
- }
|
|
|
- if disWord != "" {
|
|
|
- from_userid = disWordNil(disWord, userId)
|
|
|
- }
|
|
|
if userId == "" { //} && !regclient.MatchString(client) { //没有用户session //搜索引擎让过
|
|
|
s.Session().Set("referer", s.Request.RequestURI)
|
|
|
if bm { //是否是移动端访问
|
|
@@ -190,6 +194,8 @@ func (s *Short) LoginCommon(userId, stype, id string) error {
|
|
|
}
|
|
|
}
|
|
|
return nil
|
|
|
+ } else if disWord != "" {
|
|
|
+ from_userid = disWordNil(disWord, userId)
|
|
|
}
|
|
|
if stype == "bdcontent" {
|
|
|
stype = "content"
|
|
@@ -197,7 +203,7 @@ func (s *Short) LoginCommon(userId, stype, id string) error {
|
|
|
} else if stype == "entservice" { //大客户数据快照展示
|
|
|
//se := util.SimpleEncrypt{"entservice"}
|
|
|
sid := encrypt.SE3.DecodeString(id)
|
|
|
- if len(sid) == 0 || (len(sid) > 0 && sid == "") {
|
|
|
+ if userId == "" || len(sid) == 0 || (len(sid) > 0 && sid == "") { //未登录用户没有权限访问
|
|
|
s.Redirect("/notin/page", 302)
|
|
|
return nil
|
|
|
}
|
|
@@ -1176,7 +1182,7 @@ func (s *Short) NologinArticle(stype, id string) error {
|
|
|
return nil
|
|
|
}
|
|
|
if userId != "" { //已登录用户直接跳转至正常三级页
|
|
|
- return s.LoginCommon(userId, stype, id)
|
|
|
+ return s.LoginCommon(userId, stype, id, mobileReg.MatchString(s.Header("User-Agent"))) //是否是移动端
|
|
|
}
|
|
|
if detailNeedMosaic == nil {
|
|
|
detailNeedMosaic, _ = config.Sysconfig["detailNeedMosaic"].(map[string]interface{})
|
|
@@ -1187,7 +1193,7 @@ func (s *Short) NologinArticle(stype, id string) error {
|
|
|
func (s *Short) NologinCommon(userId, stype, id, sid string) error {
|
|
|
tg := &Tags{}
|
|
|
catchKey := fmt.Sprintf("jypcdetail_nologin_%s_%s", stype, sid)
|
|
|
- if res := redis.Get(redisLimitation, catchKey); true || res == nil || res == "" {
|
|
|
+ if res := redis.Get(redisLimitation, catchKey); res == nil || res == "" {
|
|
|
industry := s.GetString("industry")
|
|
|
var shareid = s.GetString("id")
|
|
|
if len(shareid) == 0 {
|