|
@@ -1,7 +1,10 @@
|
|
|
package active
|
|
|
|
|
|
import (
|
|
|
+ "app.yhyue.com/moapp/jybase/redis"
|
|
|
+ "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
"app.yhyue.com/moapp/jypkg/public"
|
|
|
+ "fmt"
|
|
|
"regexp"
|
|
|
|
|
|
util "app.yhyue.com/moapp/jybase/common"
|
|
@@ -48,9 +51,12 @@ type Active struct {
|
|
|
|
|
|
}
|
|
|
|
|
|
-var mongodb = public.MQFW
|
|
|
-var se = encrypt.SimpleEncrypt{Key: "topnet2015topnet2015"}
|
|
|
-var mobileReg = regexp.MustCompile("(?i)(Android|Mobile|Phone)")
|
|
|
+var (
|
|
|
+ mongodb = public.MQFW
|
|
|
+ se = encrypt.SimpleEncrypt{Key: "topnet2015topnet2015"}
|
|
|
+ mobileReg = regexp.MustCompile("(?i)(Android|Mobile|Phone)")
|
|
|
+ cacheTimeOut = 3 * 24 * 60 * 60 //三天
|
|
|
+)
|
|
|
|
|
|
func init() {
|
|
|
//添加模块解析
|
|
@@ -73,6 +79,15 @@ func (a *Active) TransitRoute(key string) error {
|
|
|
if !bm { //如果电脑端 访问电脑端
|
|
|
return a.Redirect("/active/transit/day01")
|
|
|
}
|
|
|
+ case "day04": //PC
|
|
|
+ if bm { //如果是移动端 访问移动端
|
|
|
+ return a.Redirect("/active/transit/day06")
|
|
|
+ }
|
|
|
+ case "day06": //WX
|
|
|
+ if !bm { //如果电脑端 访问电脑端
|
|
|
+ return a.Redirect("/active/transit/day04")
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
shortUrls := public.Mysql.SelectBySql(`SELECT * FROM short_url WHERE mold = 1 AND code = ?`, key)
|
|
|
if shortUrls != nil && len(*shortUrls) > 0 {
|
|
@@ -86,6 +101,12 @@ func (a *Active) TransitRoute(key string) error {
|
|
|
redirectUrl = util.ObjToString(shortUrl["href"])
|
|
|
}
|
|
|
}
|
|
|
+ //未登录
|
|
|
+ if userId, _ := a.GetSession("userId").(string); userId == "" {
|
|
|
+ jy.SetCookieValue(a.ResponseWriter, jy.ChannelCookieName, key, cacheTimeOut) //三天
|
|
|
+ redis.Put("limitation", fmt.Sprintf("firstVisitTagByWX_%s", a.Session().Id()), key, cacheTimeOut) //登录注册 用户标识
|
|
|
+ return a.Redirect(redirectUrl)
|
|
|
+ }
|
|
|
}
|
|
|
return a.Redirect(redirectUrl)
|
|
|
}
|